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
public class JavaModelloGenerator extends AbstractJavaModelloGenerator
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Collection<java.lang.String>immutableTypes-
Fields inherited from class org.codehaus.modello.plugin.java.AbstractJavaModelloGenerator
DEFAULT_DATE_FORMAT, domAsXpp3, useJava5
-
-
Constructor Summary
Constructors Constructor Description JavaModelloGenerator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidaddParameter(JMethodSignature jMethod, java.lang.String type, java.lang.String name, java.lang.String comment)private voidappendEntryMethod(java.lang.String type, java.lang.String method, java.lang.StringBuilder target, ModelAssociation modelAssociation)private java.lang.StringappendPeriod(java.lang.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 voidcreateAdder(ModelAssociation modelAssociation, JClass jClass)private voidcreateAdder(ModelAssociation modelAssociation, JClass jClass, boolean isBuilderMethod)private voidcreateAssociation(JClass jClass, ModelAssociation modelAssociation, JSourceCode jConstructorSource)private voidcreateBreakAssociation(JClass jClass, ModelAssociation modelAssociation)private voidcreateBuilderAssociation(JClass jClass, ModelAssociation modelAssociation)private voidcreateBuilderField(JClass jClass, ModelField modelField)private voidcreateClassCastAssertion(JSourceCode sc, ModelAssociation modelAssociation, java.lang.String crudModifier)private voidcreateCreateAssociation(JClass jClass, ModelAssociation modelAssociation)private JFieldcreateField(ModelField modelField)private voidcreateField(JClass jClass, ModelField modelField)private JMethodcreateGetter(JField field, ModelField modelField)private java.lang.StringcreateHashCodeForField(ModelField identifier)private voidcreateInstanceAndSetProperties(ModelClass modelClass, JConstructor constructor, JSourceCode sc)private voidcreateSetBuilderAssociationToInstance(java.util.Set<java.lang.String> ctorArgs, ModelAssociation modelAssociation, JSourceCode sc)private booleancreateSetBuilderFieldToInstance(java.util.Set<java.lang.String> ctorArgs, ModelField modelField, JSourceCode sc)private JMethodcreateSetter(JField field, ModelField modelField)private JMethodcreateSetter(JField field, ModelField modelField, boolean isBuilderMethod)voidgenerate(Model model, java.util.Properties parameters)private voidgenerateBuilder(ModelClass modelClass, JClass builderClass, JConstructor outherClassConstructor)private JMethod[]generateClone(ModelClass modelClass, ModelClass locationClass)private JMethodgenerateEquals(ModelClass modelClass)private JMethodgenerateHashCode(ModelClass modelClass)private voidgenerateInterface(ModelInterface modelInterface)private voidgenerateJava()private voidgenerateLocationBean(JClass jClass, ModelClass locationClass, ModelClass sourceClass)private java.lang.StringgenerateLocationTracker(Model objectModel, ModelClass locationClass)private voidgenerateLocationTracking(JClass jClass, ModelClass modelClass, ModelClass locationClass)private voidgenerateStaticCreator(ModelClass modelClass, JClass jClass, JConstructor constructor)private JMethodgenerateToString(ModelClass modelClass, boolean onlyIdentifierFields)private java.lang.StringgetCloneHook(ModelClass modelClass)private java.lang.StringgetCloneMode(ModelAssociation modelAssociation, java.lang.String cloneModeClass)private java.lang.StringgetCloneMode(ModelClass modelClass)private JTypegetComponentType(ModelAssociation modelAssociation, JavaAssociationMetadata javaAssociationMetadata)private java.lang.StringgetDefaultValue(ModelAssociation modelAssociation, JType componentType)private JTypegetDesiredType(ModelField modelField, boolean useTo)private JavaAssociationMetadatagetJavaAssociationMetadata(ModelAssociation modelAssociation)private booleanisBidirectionalAssociation(ModelAssociation association)-
Methods inherited from class org.codehaus.modello.plugin.java.AbstractJavaModelloGenerator
addModelImport, addModelImports, getClasses, getDefaultValue, getJavaDefaultValue, getPrefix, getValueChecker, 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, singular, uncapitalise
-
-
-
-
Method Detail
-
generate
public void generate(Model model, java.util.Properties parameters) throws ModelloException
- Throws:
ModelloException
-
generateJava
private void generateJava() throws ModelloException, java.io.IOException- Throws:
ModelloExceptionjava.io.IOException
-
generateInterface
private void generateInterface(ModelInterface modelInterface) throws ModelloException, java.io.IOException
- Throws:
ModelloExceptionjava.io.IOException
-
generateEquals
private JMethod generateEquals(ModelClass modelClass)
-
generateToString
private JMethod generateToString(ModelClass modelClass, boolean onlyIdentifierFields)
-
generateHashCode
private JMethod generateHashCode(ModelClass modelClass)
-
generateClone
private JMethod[] generateClone(ModelClass modelClass, ModelClass locationClass) throws ModelloException
- Throws:
ModelloException
-
getCloneMode
private java.lang.String getCloneMode(ModelClass modelClass) throws ModelloException
- Throws:
ModelloException
-
getCloneMode
private java.lang.String getCloneMode(ModelAssociation modelAssociation, java.lang.String cloneModeClass) throws ModelloException
- Throws:
ModelloException
-
getCloneHook
private java.lang.String getCloneHook(ModelClass modelClass) throws ModelloException
- Throws:
ModelloException
-
generateLocationTracker
private java.lang.String generateLocationTracker(Model objectModel, ModelClass locationClass) throws ModelloException, java.io.IOException
- Throws:
ModelloExceptionjava.io.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
private java.lang.String appendPeriod(java.lang.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.- Parameters:
string- The string to work with- Returns:
- The string that came in but with a period at the end
-
createHashCodeForField
private java.lang.String createHashCodeForField(ModelField identifier)
-
createField
private JField createField(ModelField modelField) throws ModelloException
- Throws:
ModelloException
-
createField
private void createField(JClass jClass, ModelField modelField) throws ModelloException
- Throws:
ModelloException
-
createGetter
private JMethod createGetter(JField field, ModelField modelField)
-
createSetter
private JMethod createSetter(JField field, ModelField modelField) throws ModelloException
- Throws:
ModelloException
-
createSetter
private JMethod createSetter(JField field, ModelField modelField, boolean isBuilderMethod) throws ModelloException
- Throws:
ModelloException
-
createClassCastAssertion
private void createClassCastAssertion(JSourceCode sc, ModelAssociation modelAssociation, java.lang.String crudModifier) throws ModelloException
- Throws:
ModelloException
-
createAssociation
private void createAssociation(JClass jClass, ModelAssociation modelAssociation, JSourceCode jConstructorSource) throws ModelloException
- Throws:
ModelloException
-
getDefaultValue
private java.lang.String getDefaultValue(ModelAssociation modelAssociation, JType componentType)
-
getJavaAssociationMetadata
private JavaAssociationMetadata getJavaAssociationMetadata(ModelAssociation modelAssociation) throws ModelloException
- Throws:
ModelloException
-
getComponentType
private JType getComponentType(ModelAssociation modelAssociation, JavaAssociationMetadata javaAssociationMetadata)
-
createCreateAssociation
private void createCreateAssociation(JClass jClass, ModelAssociation modelAssociation)
-
createBreakAssociation
private void createBreakAssociation(JClass jClass, ModelAssociation modelAssociation)
-
createAdder
private void createAdder(ModelAssociation modelAssociation, JClass jClass) throws ModelloException
- Throws:
ModelloException
-
createAdder
private void createAdder(ModelAssociation modelAssociation, JClass jClass, boolean isBuilderMethod) throws ModelloException
- Throws:
ModelloException
-
isBidirectionalAssociation
private boolean isBidirectionalAssociation(ModelAssociation association)
-
getDesiredType
private JType getDesiredType(ModelField modelField, boolean useTo) throws ModelloException
- Throws:
ModelloException
-
addParameter
private void addParameter(JMethodSignature jMethod, java.lang.String type, java.lang.String name, java.lang.String comment)
-
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
private void createBuilderField(JClass jClass, ModelField modelField) throws ModelloException
- Throws:
ModelloException
-
createSetBuilderFieldToInstance
private boolean createSetBuilderFieldToInstance(java.util.Set<java.lang.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(java.util.Set<java.lang.String> ctorArgs, ModelAssociation modelAssociation, JSourceCode sc) throws ModelloException- Throws:
ModelloException
-
appendEntryMethod
private void appendEntryMethod(java.lang.String type, java.lang.String method, java.lang.StringBuilder target, ModelAssociation modelAssociation)
-
generateStaticCreator
private void generateStaticCreator(ModelClass modelClass, JClass jClass, JConstructor constructor) throws ModelloException
- Throws:
ModelloException
-
-