Package org.codehaus.modello.plugin.java
Class JavaModelloGenerator
java.lang.Object
org.codehaus.plexus.logging.AbstractLogEnabled
org.codehaus.modello.plugin.AbstractModelloGenerator
org.codehaus.modello.plugin.java.AbstractJavaModelloGenerator
org.codehaus.modello.plugin.java.JavaModelloGenerator
- All Implemented Interfaces:
ModelloGenerator
,org.codehaus.plexus.logging.LogEnabled
,org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable
@Component(role=ModelloGenerator.class,
hint="java")
public class JavaModelloGenerator
extends AbstractJavaModelloGenerator
-
Field Summary
FieldsFields inherited from class org.codehaus.modello.plugin.java.AbstractJavaModelloGenerator
DEFAULT_DATE_FORMAT, domAsXpp3
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
addParameter
(JMethodSignature jMethod, String type, String name, String comment) private void
appendEntryMethod
(String type, String method, StringBuilder target, ModelAssociation modelAssociation) private String
appendPeriod
(String string) Utility method that adds a period to the end of a string, if the last non-whitespace character of the string is not a punctuation mark or an end-tag.private void
createAdder
(ModelAssociation modelAssociation, JClass jClass) private void
createAdder
(ModelAssociation modelAssociation, JClass jClass, boolean isBuilderMethod) private void
createAssociation
(JClass jClass, ModelAssociation modelAssociation, JSourceCode jConstructorSource) private void
createBreakAssociation
(JClass jClass, ModelAssociation modelAssociation) private void
createBuilderAssociation
(JClass jClass, ModelAssociation modelAssociation) private void
createBuilderField
(JClass jClass, ModelField modelField) private void
createClassCastAssertion
(JSourceCode sc, ModelAssociation modelAssociation, String crudModifier) private void
createCreateAssociation
(JClass jClass, ModelAssociation modelAssociation) private JField
createField
(ModelField modelField) private void
createField
(JClass jClass, ModelField modelField) private JMethod
createGetter
(JField field, ModelField modelField) private String
createHashCodeForField
(ModelField identifier) private void
createInstanceAndSetProperties
(ModelClass modelClass, JConstructor constructor, JSourceCode sc) private void
createSetBuilderAssociationToInstance
(Set<String> ctorArgs, ModelAssociation modelAssociation, JSourceCode sc) private boolean
createSetBuilderFieldToInstance
(Set<String> ctorArgs, ModelField modelField, JSourceCode sc) private JMethod
createSetter
(JField field, ModelField modelField) private JMethod
createSetter
(JField field, ModelField modelField, boolean isBuilderMethod) void
generate
(Model model, Properties parameters) private void
generateBuilder
(ModelClass modelClass, JClass builderClass, JConstructor outherClassConstructor) private JMethod[]
generateClone
(ModelClass modelClass, ModelClass locationClass) private JMethod
generateEquals
(ModelClass modelClass) private JMethod
generateHashCode
(ModelClass modelClass) private void
generateInterface
(ModelInterface modelInterface) private void
private void
generateLocationBean
(JClass jClass, ModelClass locationClass, ModelClass sourceClass) private String
generateLocationTracker
(Model objectModel, ModelClass locationClass) private void
generateLocationTracking
(JClass jClass, ModelClass modelClass, ModelClass locationClass) private void
generateStaticCreator
(ModelClass modelClass, JClass jClass, JConstructor constructor) private JMethod
generateToString
(ModelClass modelClass, boolean onlyIdentifierFields) private String
getCloneHook
(ModelClass modelClass) private String
getCloneMode
(ModelAssociation modelAssociation, String cloneModeClass) private String
getCloneMode
(ModelClass modelClass) private JType
getComponentType
(ModelAssociation modelAssociation, JavaAssociationMetadata javaAssociationMetadata) private String
getDefaultValue
(ModelAssociation modelAssociation, JType componentType) private JType
getDesiredType
(ModelField modelField, boolean useTo) private JavaAssociationMetadata
getJavaAssociationMetadata
(ModelAssociation modelAssociation) private boolean
isBidirectionalAssociation
(ModelAssociation association) Methods inherited from class org.codehaus.modello.plugin.java.AbstractJavaModelloGenerator
addModelImport, addModelImports, getClasses, getDefaultValue, getJavaDefaultValue, getPrefix, getValueChecker, hasJavaSourceSupport, initHeader, initHeader, initialize, isJavaEnabled, isRelevant, isTrackingSupport, newJSourceWriter, suppressAllWarnings
Methods inherited from class org.codehaus.modello.plugin.AbstractModelloGenerator
capitalise, contextualize, getBuildContext, getEncoding, getFieldsForClass, getGeneratedVersion, getHeader, getModel, getOutputDirectory, getParameter, getParameter, getParameter, isClassInModel, isCollection, isEmpty, isInnerAssociation, isMap, isPackageWithVersion, newWriter, newWriter, singular, uncapitalise
Methods inherited from class org.codehaus.plexus.logging.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
Field Details
-
immutableTypes
-
-
Constructor Details
-
JavaModelloGenerator
public JavaModelloGenerator()
-
-
Method Details
-
generate
- Throws:
ModelloException
-
generateJava
- Throws:
ModelloException
IOException
-
generateInterface
- Throws:
ModelloException
IOException
-
generateEquals
-
generateToString
-
generateHashCode
-
generateClone
private JMethod[] generateClone(ModelClass modelClass, ModelClass locationClass) throws ModelloException - Throws:
ModelloException
-
getCloneMode
- Throws:
ModelloException
-
getCloneMode
private String getCloneMode(ModelAssociation modelAssociation, String cloneModeClass) throws ModelloException - Throws:
ModelloException
-
getCloneHook
- Throws:
ModelloException
-
generateLocationTracker
private String generateLocationTracker(Model objectModel, ModelClass locationClass) throws ModelloException, IOException - Throws:
ModelloException
IOException
-
generateLocationTracking
private void generateLocationTracking(JClass jClass, ModelClass modelClass, ModelClass locationClass) throws ModelloException - Throws:
ModelloException
-
generateLocationBean
private void generateLocationBean(JClass jClass, ModelClass locationClass, ModelClass sourceClass) throws ModelloException - Throws:
ModelloException
-
appendPeriod
Utility method that adds a period to the end of a string, if the last non-whitespace character of the string is not a punctuation mark or an end-tag.- Parameters:
string
- The string to work with- Returns:
- The string that came in but with a period at the end
-
createHashCodeForField
-
createField
- Throws:
ModelloException
-
createField
- Throws:
ModelloException
-
createGetter
-
createSetter
- Throws:
ModelloException
-
createSetter
private JMethod createSetter(JField field, ModelField modelField, boolean isBuilderMethod) throws ModelloException - Throws:
ModelloException
-
createClassCastAssertion
private void createClassCastAssertion(JSourceCode sc, ModelAssociation modelAssociation, String crudModifier) throws ModelloException - Throws:
ModelloException
-
createAssociation
private void createAssociation(JClass jClass, ModelAssociation modelAssociation, JSourceCode jConstructorSource) throws ModelloException - Throws:
ModelloException
-
getDefaultValue
-
getJavaAssociationMetadata
private JavaAssociationMetadata getJavaAssociationMetadata(ModelAssociation modelAssociation) throws ModelloException - Throws:
ModelloException
-
getComponentType
private JType getComponentType(ModelAssociation modelAssociation, JavaAssociationMetadata javaAssociationMetadata) -
createCreateAssociation
-
createBreakAssociation
-
createAdder
- Throws:
ModelloException
-
createAdder
private void createAdder(ModelAssociation modelAssociation, JClass jClass, boolean isBuilderMethod) throws ModelloException - Throws:
ModelloException
-
isBidirectionalAssociation
-
getDesiredType
- Throws:
ModelloException
-
addParameter
-
generateBuilder
private void generateBuilder(ModelClass modelClass, JClass builderClass, JConstructor outherClassConstructor) throws ModelloException - Throws:
ModelloException
-
createInstanceAndSetProperties
private void createInstanceAndSetProperties(ModelClass modelClass, JConstructor constructor, JSourceCode sc) throws ModelloException - Throws:
ModelloException
-
createBuilderField
- Throws:
ModelloException
-
createSetBuilderFieldToInstance
private boolean createSetBuilderFieldToInstance(Set<String> ctorArgs, ModelField modelField, JSourceCode sc) throws ModelloException - Throws:
ModelloException
-
createBuilderAssociation
private void createBuilderAssociation(JClass jClass, ModelAssociation modelAssociation) throws ModelloException - Throws:
ModelloException
-
createSetBuilderAssociationToInstance
private void createSetBuilderAssociationToInstance(Set<String> ctorArgs, ModelAssociation modelAssociation, JSourceCode sc) throws ModelloException - Throws:
ModelloException
-
appendEntryMethod
private void appendEntryMethod(String type, String method, StringBuilder target, ModelAssociation modelAssociation) -
generateStaticCreator
private void generateStaticCreator(ModelClass modelClass, JClass jClass, JConstructor constructor) throws ModelloException - Throws:
ModelloException
-