Package org.nuiton.eugene.java
Class JavaGeneratorUtil
- java.lang.Object
-
- org.nuiton.eugene.GeneratorUtil
-
- org.nuiton.eugene.java.JavaGeneratorUtil
-
public class JavaGeneratorUtil extends GeneratorUtil
Utility class for pure java templates.- Since:
- 2.0.2
- Author:
- Tony Chemit - dev@tchemit.fr
-
-
Field Summary
Fields Modifier and Type Field Description static StringDEPENDENCIES_CONSTANTSDependency to add constants in interfaces via an enumeration.static StringOPERATION_GETTER_BOOLEAN_PREFIXstatic StringOPERATION_GETTER_DEFAULT_PREFIX-
Fields inherited from class org.nuiton.eugene.GeneratorUtil
SERIAL_VERSION_UID
-
-
Constructor Summary
Constructors Constructor Description JavaGeneratorUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringcapitalizeJavaBeanPropertyName(String propertyName)Convertit une propriété javaBean son suffix utilisé pour écrire les getter/setter correspondant.static voidcloneOperations(ObjectModelTransformerToJava transformer, Iterable<ObjectModelOperation> operations, ObjectModelClassifier target, boolean useVisibility, ObjectModelModifier... extraModifiers)Duplicates in thetargetclassifier the givenoperationsusing atransformerto modify model.static booleancontainsGenerics(String fqn)Tells if the given fqn contains a generic declaration (says contains a<caracter).static StringgenerateName(String prefix, String name, String suffix)static StringgetAttributeImplementationType(ObjectModelParameter attribute, boolean useGenerics)static StringgetAttributeImplementationType(ObjectModelParameter attribute, String attributeType, boolean useGenerics)static StringgetAttributeInterfaceType(ObjectModelParameter attribute)static StringgetAttributeInterfaceType(ObjectModelParameter attribute, boolean useGenerics)Retourne le type de l'attribut, c-a-d une List ou une collection ou le type defini si la cardinalité n'est pas multiplestatic StringgetAttributeInterfaceType(ObjectModelParameter attribute, String attributeType, boolean useGenerics)Retourne le type de l'attribut, c-a-d une List ou une collection ou le type defini si la cardinalité n'est pas multiplestatic StringgetClassAttributesListDeclaration(ObjectModelClass clazz)static Class<?>getCollectionInstanceType(ObjectModelAttribute attr)static Class<?>getCollectionType(ObjectModelAttribute attr)static StringgetOperationParametersListDeclaration(ObjectModelOperation operation)Used to return theoperationparameters for its declaration : type and name of each parameter will be join as a string separated by a comma.static booleanisOrdered(ObjectModelAttribute attr)static StringjoinGeneric(String... genericParts)Join generics parts of a fqn into aparts.static String[]splitFqnList(String fqns, char separator)Split the given fqns gieven the list separator.static String[]splitGeneric(String fqn)Split the given fqn which contains a generic declaration into his parts.-
Methods inherited from class org.nuiton.eugene.GeneratorUtil
changeExtension, changeExtension, computeSerialVersionUID, convertConstantNameToVariableName, convertVariableNameToConstantName, findTagValue, generateSerialVersionUID, getAssocAttrName, getCastValue, getClassifiers, getClassNameFromQualifiedName, getFilenameFromQualifiedName, getFormatingExpression, getHashCodeExpression, getInitValue, getInitValue, getOperationParametersListName, getParentPackageName, getParsingExpression, getPrimitiveWrapType, getRelativeFile, getSimpleName, getSimpleName, getTypesList, hasDocumentation, hasStereotype, isBooleanPrimitive, isBooleanPrimitive, isComposition, isFirstAttribute, isNMultiplicity, isNMultiplicity, isOneMultiplicity, isPrimitiveAttributeType, isPrimitiveType, notEmpty, removeAnyGenericDefinition, removeGenericDefinition, simpleNamesEquals, splitGenericDefinition, toLowerCaseFirstLetter
-
-
-
-
Field Detail
-
OPERATION_GETTER_DEFAULT_PREFIX
public static final String OPERATION_GETTER_DEFAULT_PREFIX
- See Also:
- Constant Field Values
-
OPERATION_GETTER_BOOLEAN_PREFIX
public static final String OPERATION_GETTER_BOOLEAN_PREFIX
- See Also:
- Constant Field Values
-
DEPENDENCIES_CONSTANTS
public static final String DEPENDENCIES_CONSTANTS
Dependency to add constants in interfaces via an enumeration. The literals of enumeration will be the value, and constant names will be generated by transformers.- Since:
- 2.0.2
- See Also:
- Constant Field Values
-
-
Method Detail
-
cloneOperations
public static void cloneOperations(ObjectModelTransformerToJava transformer, Iterable<ObjectModelOperation> operations, ObjectModelClassifier target, boolean useVisibility, ObjectModelModifier... extraModifiers)
Duplicates in thetargetclassifier the givenoperationsusing atransformerto modify model.- Parameters:
transformer- the transformer to useoperations- operations to duplicatetarget- where to duplicate operationsuseVisibility- flag to use operation visibilty to compute his modifiersextraModifiers- scopes to apply to all operations
-
capitalizeJavaBeanPropertyName
public static String capitalizeJavaBeanPropertyName(String propertyName)
Convertit une propriété javaBean son suffix utilisé pour écrire les getter/setter correspondant.- Parameters:
propertyName- le nom de propriété a convertir- Returns:
- le nom capitalizé de la propriété JavaBean
- Since:
- 2.4.2
-
splitGeneric
public static String[] splitGeneric(String fqn)
Split the given fqn which contains a generic declaration into his parts. Example :java.util.List<Integer> : [java.util.List, Integer] java.util.List<java.util.List<Integer>> : [java.util.List, java.util.List<Integer>] java.util.Map<Integer, Integer> : [java.util.Map, Integer, Integer] java.util.Map<Integer, java.util.List<Integer>> : [java.util.Map, Integer, java.util.List<Integer>]
Note: We only deal with one level of generics here in order to be able easly to rebuild after all the fqn with simple names...- Parameters:
fqn- the fqn to split- Returns:
- the array of all parts of the fqn.
- Since:
- 2.3.2
-
joinGeneric
public static String joinGeneric(String... genericParts)
Join generics parts of a fqn into aparts. Example :[java.util.List, Integer] : java.util.List<Integer> [java.util.List, java.util.List<Integer>] : java.util.List<java.util.List<Integer>> [java.util.Map, Integer, Integer] : java.util.Map<Integer, Integer> [java.util.Map, Integer, java.util.List<Integer>] : java.util.Map<Integer, java.util.List<Integer>>
- Parameters:
genericParts- the parts of fqn- Returns:
- the fqn from his parts
- Since:
- 2.3.2
-
containsGenerics
public static boolean containsGenerics(String fqn)
Tells if the given fqn contains a generic declaration (says contains a<caracter).- Parameters:
fqn- the fqn to test- Returns:
trueif given fqn contains a generic declaration- Since:
- 2.3.2
-
splitFqnList
public static String[] splitFqnList(String fqns, char separator)
Split the given fqns gieven the list separator. Example :Boolean, File : [Boolean, File] Boolean , java.util.List<Integer> : [Boolean, java.util.List<Integer>]
Note: You can NOT use as separator'<'nor'>'nor' '.- Parameters:
fqns- the fqn list to splitseparator- the fqn separactor char- Returns:
- the array of all parts of the fqn.
- Since:
- 2.3.2
-
isOrdered
public static boolean isOrdered(ObjectModelAttribute attr)
-
getCollectionType
public static Class<?> getCollectionType(ObjectModelAttribute attr)
-
getCollectionInstanceType
public static Class<?> getCollectionInstanceType(ObjectModelAttribute attr)
-
getOperationParametersListDeclaration
public static String getOperationParametersListDeclaration(ObjectModelOperation operation)
Used to return theoperationparameters for its declaration : type and name of each parameter will be join as a string separated by a comma. Usefull for operation parameters declaration in templates writing.- Parameters:
operation- to treate- Returns:
- the string corresponding to the list of operation parameters for declaration syntax.
-
getClassAttributesListDeclaration
public static String getClassAttributesListDeclaration(ObjectModelClass clazz)
- Parameters:
clazz- the class where to look at- Returns:
- sous forme de String la liste des déclarations des attributes d'une classe donnée
-
getAttributeInterfaceType
public static String getAttributeInterfaceType(ObjectModelParameter attribute)
- Parameters:
attribute- the attribute to test- Returns:
- the type of the given attribute
- See Also:
getAttributeInterfaceType(ObjectModelParameter, boolean)
-
getAttributeInterfaceType
public static String getAttributeInterfaceType(ObjectModelParameter attribute, boolean useGenerics)
Retourne le type de l'attribut, c-a-d une List ou une collection ou le type defini si la cardinalité n'est pas multiple- Parameters:
attribute- the attribute to testuseGenerics-trueif the attribute use a generic type- Returns:
- attribute type
-
getAttributeInterfaceType
public static String getAttributeInterfaceType(ObjectModelParameter attribute, String attributeType, boolean useGenerics)
Retourne le type de l'attribut, c-a-d une List ou une collection ou le type defini si la cardinalité n'est pas multiple- Parameters:
attribute- the attribute to testattributeType- the attribute typeuseGenerics-trueif the attribute use a generic type- Returns:
- attribute type
-
getAttributeImplementationType
public static String getAttributeImplementationType(ObjectModelParameter attribute, String attributeType, boolean useGenerics)
-
getAttributeImplementationType
public static String getAttributeImplementationType(ObjectModelParameter attribute, boolean useGenerics)
-
-