Class JavaGeneratorUtil


  • public class JavaGeneratorUtil
    extends GeneratorUtil
    Utility class for pure java templates.
    Since:
    2.0.2
    Author:
    Tony Chemit - chemit@codelutin.com
    • Field Detail

      • 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
    • Constructor Detail

      • JavaGeneratorUtil

        public JavaGeneratorUtil()
    • Method Detail

      • cloneOperations

        public static void cloneOperations​(ObjectModelTransformerToJava transformer,
                                           Iterable<ObjectModelOperation> operations,
                                           ObjectModelClassifier target,
                                           boolean useVisibility,
                                           ObjectModelModifier... extraModifiers)
        Duplicates in the target classifier the given operations using a transformer to modify model.
        Parameters:
        transformer - the transformer to use
        operations - operations to duplicate
        target - where to duplicate operations
        useVisibility - flag to use operation visibilty to compute his modifiers
        extraModifiers - 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:
        true if 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 '&lt;' nor '&gt;' nor ' '.
        Parameters:
        fqns - the fqn list to split
        separator - the fqn separactor char
        Returns:
        the array of all parts of the fqn.
        Since:
        2.3.2
      • getOperationParametersListDeclaration

        public static String getOperationParametersListDeclaration​(ObjectModelOperation operation)
        Used to return the operation parameters 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,
                                                       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 test
        useGenerics - true if 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 test
        attributeType - the attribute type
        useGenerics - true if 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)