Package org.nuiton.eugene.java
Class BeanTransformer
- java.lang.Object
-
- org.nuiton.eugene.Template<I>
-
- org.nuiton.eugene.Transformer<ObjectModel,O>
-
- org.nuiton.eugene.models.object.ObjectModelTransformer<ObjectModel>
-
- org.nuiton.eugene.java.ObjectModelTransformerToJava
-
- org.nuiton.eugene.java.BeanTransformer
-
- All Implemented Interfaces:
TemplateConfiguration
@Component(role=org.nuiton.eugene.Template.class, hint="org.nuiton.eugene.java.BeanTransformer") public class BeanTransformer extends ObjectModelTransformerToJava
Generates a bean and a helper class around it.Generates also a model initializer contract which permits you to interact with all selectedClasses of your model.
For example:
GeneratedBoat Boat (extends GeneratedBoat) GeneratedBoatHelper BoatHelper (extends AbstractBoats)- Since:
- 3.0
- Author:
- Tony Chemit - dev@tchemit.fr
-
-
Field Summary
Fields Modifier and Type Field Description protected BeanTransformerTagValuesbeanTagValuesprotected BeanTransformerContextcontextprotected EugeneCoreTagValuescoreTagValuesprotected com.google.common.collect.ImmutableSet<ObjectModelClass>helpersprotected com.google.common.collect.ImmutableMap<ObjectModelClass,String>helpersNameTranslationprotected EugeneJavaTagValuesjavaTemplatesTagValues-
Fields inherited from class org.nuiton.eugene.java.ObjectModelTransformerToJava
builder, eugeneTagValues
-
Fields inherited from class org.nuiton.eugene.Transformer
outputModel, outputProperties, outputTemplate, previousTransformer
-
Fields inherited from class org.nuiton.eugene.Template
configuration, excludeTemplates, generatedPackages, model, resourcesHelper
-
Fields inherited from interface org.nuiton.eugene.TemplateConfiguration
PROP_CLASS_LOADER, PROP_DEFAULT_PACKAGE, PROP_ENCODING, PROP_EXCLUDE_TEMPLATES, PROP_GENERATED_PACKAGES, PROP_I18N_GETTER_FILE, PROP_LAST_MODIFIED_SOURCE, PROP_OUTPUT_DIRECTORY, PROP_OVERWRITE, PROP_RESOURCE_DIRECTORY, PROP_VERBOSE, PROP_WRITER_REPORT
-
-
Constructor Summary
Constructors Constructor Description BeanTransformer()
-
Method Summary
-
Methods inherited from class org.nuiton.eugene.java.ObjectModelTransformerToJava
addAnnotation, addAnnotation, addAnnotationClassParameter, addAnnotationClassParameter, addAnnotationClassParameter, addAnnotationClassParameter, addAnnotationParameter, addAttribute, addAttribute, addAttribute, addAttribute, addBlock, addComment, addConstant, addConstant, addConstantsFromDependency, addConstructor, addConstructor, addException, addException, addGeneratedAnnotation, addI18n, addImport, addImport, addImport, addInnerClassifier, addInterface, addInterface, addLiteral, addOperation, addOperation, addOperation, addParameter, addParameter, addStereotype, addTagValue, addTagValue, cloneAttribute, cloneClass, cloneClassifier, cloneClassifier, cloneEnumeration, cloneInterface, cloneOperation, cloneOperationSignature, cloneStereotypes, cloneTagValues, copyClassifier, createAbstractClass, createClass, createEnumeration, createInterface, debugOutputModel, generateI18nBlock, getConstantName, getConstantPrefix, getConstantPrefix, getFileInClassPath, getImportManager, getJavaBeanMethodName, getJavaBeanMethodName, getMethodName, getPackage, getPackage, importAndSimplify, initConstantPrefixFromModel, initOutputModel, initOutputTemplate, isInClassPath, isInClassPath, isInClassPath, setConstantPrefix, setDocumentation, setMaxMultiplicity, setMinMultiplicity, setNavigable, setOperationBody, setSuperClass, setSuperClass, storeServiceLoaderFile, toQualifiedNames
-
Methods inherited from class org.nuiton.eugene.models.object.ObjectModelTransformer
transform, transformFromClassifier, transformFromElement, transformFromEnumeration, transformFromInterface
-
Methods inherited from class org.nuiton.eugene.Transformer
addOutputProperty, applyTemplate, getDefaultPackageName, getOutputModel, getOutputProperties, getOutputTemplate, init, initPreviousTransformer, transform
-
Methods inherited from class org.nuiton.eugene.Template
getClassLoader, getConfiguration, getEncoding, getExcludeTemplates, getGeneratedPackages, getLastModifiedSource, getLog, getModel, getOverwrite, getProperties, getProperty, getProperty, getResourcesHelper, getWriterReport, isOverwrite, isVerbose, setConfiguration, setLog, setProperty
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.nuiton.eugene.TemplateConfiguration
getI18nGetterFile, setI18nGetterFile
-
-
-
-
Field Detail
-
javaTemplatesTagValues
protected final EugeneJavaTagValues javaTemplatesTagValues
-
beanTagValues
protected final BeanTransformerTagValues beanTagValues
-
coreTagValues
protected final EugeneCoreTagValues coreTagValues
-
helpersNameTranslation
protected com.google.common.collect.ImmutableMap<ObjectModelClass,String> helpersNameTranslation
-
helpers
protected com.google.common.collect.ImmutableSet<ObjectModelClass> helpers
-
context
protected BeanTransformerContext context
-
-
Method Detail
-
skipForInitializer
public static boolean skipForInitializer(ObjectModelPackage aPackage, ObjectModelClass beanClass)
-
transformFromModel
public void transformFromModel(ObjectModel model)
- Overrides:
transformFromModelin classObjectModelTransformer<ObjectModel>
-
generateInitializers
protected void generateInitializers()
-
transformFromClass
public void transformFromClass(ObjectModelClass input)
- Overrides:
transformFromClassin classObjectModelTransformer<ObjectModel>
-
generateClass
protected ObjectModelClass generateClass(ObjectModelClass input, String className, String abstractClassName)
-
generateGeneratedClass
protected ObjectModelClass generateGeneratedClass(ObjectModelPackage aPackage, ObjectModelClass input, String className, String mainClassName)
-
generateHelper
protected void generateHelper(ObjectModelClass aClass, String abstractClassName, String defaultClassName)
-
generateGeneratedHelper
protected void generateGeneratedHelper(ObjectModelPackage aPackage, ObjectModelClass aClass, String typeName, String abstractClassName)
-
generateGeneratedHelperConstructors
protected void generateGeneratedHelperConstructors(ObjectModelClass output, String typeName)
-
generateGeneratedHelperCopyMethods
protected void generateGeneratedHelperCopyMethods(ObjectModelClass output, String typeName)
-
generateGeneratedHelperPredicates
protected void generateGeneratedHelperPredicates(ObjectModelClass input, ObjectModelClass output, String typeName)
-
generateGeneratedHelperFunctions
protected void generateGeneratedHelperFunctions(ObjectModelClass input, ObjectModelClass output, String typeName)
-
getGeneratedHelperSuperClassName
protected String getGeneratedHelperSuperClassName(ObjectModelPackage aPackage, ObjectModelClass aClass)
-
getAttributeType
protected String getAttributeType(ObjectModelAttribute attr)
-
notFoundInClassPath
protected boolean notFoundInClassPath(ObjectModelClass input, String className)
-
createProperty
protected void createProperty(ObjectModelClass output, ObjectModelAttribute attr, boolean usePCS, boolean generateBooleanGetMethods, boolean generateNotEmptyCollections)
-
getProperties
protected List<ObjectModelAttribute> getProperties(ObjectModelClass input)
-
createGetMethod
protected void createGetMethod(ObjectModelClass output, String attrName, String attrType, String methodPrefix, boolean generateLayzCode, String collectionImplementationType)
-
createGetMethod
protected void createGetMethod(ObjectModelClass output, String attrName, String attrType, String methodPrefix)
-
createGetChildMethod
protected void createGetChildMethod(ObjectModelClass output, String attrName, String attrType, String simpleType)
-
createIsEmptyMethod
protected void createIsEmptyMethod(ObjectModelClass output, String attrName)
-
createSizeMethod
protected void createSizeMethod(ObjectModelClass output, String attrName)
-
createAddChildMethod
protected void createAddChildMethod(ObjectModelClass output, String attrName, String attrType, String constantName, boolean usePCS)
-
createAddAllChildrenMethod
protected void createAddAllChildrenMethod(ObjectModelClass output, String attrName, String attrType, String constantName, boolean usePCS)
-
createRemoveChildMethod
protected void createRemoveChildMethod(ObjectModelClass output, String attrName, String attrType, String constantName, boolean usePCS)
-
createRemoveAllChildrenMethod
protected void createRemoveAllChildrenMethod(ObjectModelClass output, String attrName, String attrType, String constantName, boolean usePCS)
-
createContainsChildMethod
protected void createContainsChildMethod(ObjectModelClass output, String attrName, String attrType, String constantName, boolean usePCS)
-
createContainsAllChildrenMethod
protected void createContainsAllChildrenMethod(ObjectModelClass output, String attrName, String attrType, String constantName)
-
createSetMethod
protected void createSetMethod(ObjectModelClass output, String attrName, String attrType, String simpleType, String constantName, boolean usePCS)
-
addSerializable
protected void addSerializable(ObjectModelClass input, ObjectModelClass output, boolean interfaceFound)
-
addInterfaces
protected boolean addInterfaces(ObjectModelClass input, ObjectModelClassifier output, String extraInterfaceName)
Add all interfaces defines in input class and returns ifSerializableinterface was found.- Parameters:
input- the input model class to processoutput- the output generated class- Returns:
trueifSerializablewas found from input,falseotherwise
-
createPropertyChangeSupport
protected void createPropertyChangeSupport(ObjectModelClass output)
-
createGetChildMethod
protected void createGetChildMethod(ObjectModelClass output)
-
generateI18nBlockAndConstants
protected void generateI18nBlockAndConstants(ObjectModelPackage aPackage, ObjectModelClass input, ObjectModelClassifier output)
-
addDefaultMethodForNoneBeanSuperClass
protected void addDefaultMethodForNoneBeanSuperClass(ObjectModelClass output, boolean usePCS, List<ObjectModelAttribute> properties)
-
getGetterName
protected String getGetterName(ObjectModelAttribute attribute, String attrName)
-
canGenerateAbstractClass
protected boolean canGenerateAbstractClass(ObjectModelClass aClass, String abstractClassName)
-
createPropertyConstant
protected void createPropertyConstant(ObjectModelClassifier output, ObjectModelAttribute attr, String prefix, Set<String> constantNames)
-
getAttributeName
protected String getAttributeName(ObjectModelAttribute attr)
-
getAttributeTypeWithGeneric
protected String getAttributeTypeWithGeneric(ObjectModelAttribute attr)
-
containsMultiple
protected boolean containsMultiple(List<ObjectModelAttribute> attributes)
-
-