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 void
addParameter(JMethodSignature jMethod, java.lang.String type, java.lang.String name, java.lang.String comment)
private void
appendEntryMethod(java.lang.String type, java.lang.String method, java.lang.StringBuilder target, ModelAssociation modelAssociation)
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.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, java.lang.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 java.lang.String
createHashCodeForField(ModelField identifier)
private void
createInstanceAndSetProperties(ModelClass modelClass, JConstructor constructor, JSourceCode sc)
private void
createSetBuilderAssociationToInstance(java.util.Set<java.lang.String> ctorArgs, ModelAssociation modelAssociation, JSourceCode sc)
private boolean
createSetBuilderFieldToInstance(java.util.Set<java.lang.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, java.util.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
generateJava()
private void
generateLocationBean(JClass jClass, ModelClass locationClass, ModelClass sourceClass)
private java.lang.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 java.lang.String
getCloneHook(ModelClass modelClass)
private java.lang.String
getCloneMode(ModelAssociation modelAssociation, java.lang.String cloneModeClass)
private java.lang.String
getCloneMode(ModelClass modelClass)
private JType
getComponentType(ModelAssociation modelAssociation, JavaAssociationMetadata javaAssociationMetadata)
private java.lang.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, 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:
ModelloException
java.io.IOException
-
generateInterface
private void generateInterface(ModelInterface modelInterface) throws ModelloException, java.io.IOException
- Throws:
ModelloException
java.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:
ModelloException
java.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
-
-