Author: bleny Date: 2014-04-15 15:20:57 +0200 (Tue, 15 Apr 2014) New Revision: 1328 Url: http://forge.nuiton.org/projects/eugene/repository/revisions/1328 Log: fixes #3147 Review implications of ordering and uniqueness in collections Modified: trunk/eugene-java-templates/src/main/java/org/nuiton/eugene/java/AbstractJavaBeanTransformer.java trunk/eugene-maven-plugin/src/it/generate/generators/src/main/java/org/nuiton/eugene/test/generator/BeanGenerator.java trunk/eugene-maven-plugin/src/it/generate/generators/src/main/java/org/nuiton/eugene/test/generator/BeanTransformer.java trunk/eugene/src/main/java/org/nuiton/eugene/EugeneStereoTypes.java trunk/eugene/src/main/java/org/nuiton/eugene/GeneratorUtil.java trunk/eugene/src/main/java/org/nuiton/eugene/java/JavaGeneratorUtil.java trunk/eugene/src/main/java/org/nuiton/eugene/models/object/xml/ObjectModelAttributeImpl.java trunk/eugene/src/test/java/org/nuiton/eugene/GeneratorUtilTest.java trunk/eugene/src/test/java/org/nuiton/eugene/java/JavaGeneratorUtilTest.java Modified: trunk/eugene/src/main/java/org/nuiton/eugene/EugeneStereoTypes.java =================================================================== --- trunk/eugene/src/main/java/org/nuiton/eugene/EugeneStereoTypes.java 2014-04-15 09:37:25 UTC (rev 1327) +++ trunk/eugene/src/main/java/org/nuiton/eugene/EugeneStereoTypes.java 2014-04-15 13:20:57 UTC (rev 1328) @@ -45,14 +45,20 @@ * Stéréotype pour les attributs à indexer en base. * * @see GeneratorUtil#hasIndexedStereotype(ObjectModelAttribute) + * @deprecated use {@link #STEREOTYPE_ORDERED} instead */ @StereotypeDefinition(target = ObjectModelAttribute.class, documentation = "To specify that a attribute is indexed") + @Deprecated String STEREOTYPE_INDEXED = "indexed"; /** - * Stéréotype pour les attributs à ordonner. + * Stereotype to mark an attribute with multiplicity as ordered. * + * It means that order of insertion is maintained: in Java, it will lead + * to a collection typed with {@link java.util.List} or {@link java.util.LinkedHashSet} + * or {@link java.util.LinkedHashMap}. + * * @see GeneratorUtil#hasOrderedStereotype(ObjectModelAttribute) * @since 2.3 */ @@ -61,6 +67,18 @@ String STEREOTYPE_ORDERED = "ordered"; /** + * Stereotype to mark an attribute with multiplicity as unique. + * + * It means that uniqueness of elements is maintained in the collection: in Java, it + * will lead to a collection typed with {@link java.util.Set}. + * + * @see JavaGeneratorUtil#hasUniqueStereotype(ObjectModelAttribute) + */ + @StereotypeDefinition(target = ObjectModelAttribute.class, + documentation = "To specify that an attribute is unique") + String STEREOTYPE_UNIQUE = "unique"; + + /** * Stereotype to skip generation for some transformer. * * @see JavaGeneratorUtil#hasSkipStereotype(ObjectModelClassifier) Modified: trunk/eugene/src/main/java/org/nuiton/eugene/GeneratorUtil.java =================================================================== --- trunk/eugene/src/main/java/org/nuiton/eugene/GeneratorUtil.java 2014-04-15 09:37:25 UTC (rev 1327) +++ trunk/eugene/src/main/java/org/nuiton/eugene/GeneratorUtil.java 2014-04-15 13:20:57 UTC (rev 1328) @@ -42,7 +42,6 @@ import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; -import java.util.Iterator; import java.util.List; import java.util.Set; @@ -119,42 +118,6 @@ } /** - * @param attribute the attribute to test - * @return the type of the given attribute - * @see #getAttributeType(ObjectModelParameter, boolean) - */ - public static String getAttributeType(ObjectModelParameter attribute) { - return getAttributeType(attribute, false); - } - - /** - * 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 - * - * @param attribute the attribute to test - * @param useGenerics {@code true} if the attribute use a generic type - * @return attribute type - */ - public static String getAttributeType(ObjectModelParameter attribute, - boolean useGenerics) { - String result; - if (attribute instanceof ObjectModelAttribute - && isNMultiplicity((ObjectModelAttribute) attribute)) { - if (attribute.isOrdered()) { - result = List.class.getName(); - } else { - result = Collection.class.getName(); - } - if (useGenerics) { - result += "<" + attribute.getType() + ">"; - } - } else { - result = attribute.getType(); - } - return result; - } - - /** * Indicates if the specified attribute has a primitive type (byte, boolean, ...) * * @param attribute the attribute to test @@ -420,24 +383,6 @@ } /** - * ToString contract for ObjectModelParameter with type and name. This - * contract is used in - * {@link StringUtil#join(Iterable, org.nuiton.util.StringUtil.ToString, String, boolean)} - */ - static final StringUtil.ToString<ObjectModelParameter> - OBJECT_MODEL_PARAMETER_TO_STRING_TYPE = - new StringUtil.ToString<ObjectModelParameter>() { - - @Override - public String toString(ObjectModelParameter param) { - return new StringBuilder(getAttributeType(param)). - append(' '). - append(param.getName()). - toString(); - } - }; - - /** * ToString contract for ObjectModelParameter with name only. This contract * is used in * {@link StringUtil#join(Iterable, org.nuiton.util.StringUtil.ToString, String, boolean)} @@ -452,27 +397,7 @@ } }; - /** - * Used to return the {@code 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. - * - * @param operation to treate - * @return the string corresponding to the list of operation parameters - * for declaration syntax. - */ - public static String getOperationParametersListDeclaration( - ObjectModelOperation operation) { - String result = StringUtil.join( - operation.getParameters(), - OBJECT_MODEL_PARAMETER_TO_STRING_TYPE, - ", ", - false); - return result; - } - - /** * Used to return the {@code operation} parameter names as a string * separated by a comma. Usefull for operation call in templates writing. * @@ -491,25 +416,6 @@ } /** - * @param clazz the class where to look at - * @return sous forme de String la liste des déclarations des attributes d'une classe donnée - */ - public static String getClassAttributesListDeclaration( - ObjectModelClass clazz) { - StringBuilder result = new StringBuilder(); - - Collection<ObjectModelAttribute> params = clazz.getAttributes(); - for (Iterator<ObjectModelAttribute> j = params.iterator(); j.hasNext(); ) { - ObjectModelAttribute attr = j.next(); - result.append(getAttributeType(attr, true)).append(" ").append(attr.getName()); - if (j.hasNext()) { - result.append(", "); - } - } - return result.toString(); - } - - /** * Renvoie si l'attribut passé en paramètre est premier lexicographiquement * par rapport à son attribut inverse (si celui ci existe). * @@ -849,7 +755,9 @@ * @return {@code true} if stereotype was found, {@code false otherwise} * @see EugeneStereoTypes#STEREOTYPE_INDEXED * @since 2.3 + * @deprecated {@link org.nuiton.eugene.EugeneStereoTypes#STEREOTYPE_INDEXED} is deprecated */ + @Deprecated public static boolean hasIndexedStereotype(ObjectModelAttribute attribute) { return attribute.hasStereotype(EugeneStereoTypes.STEREOTYPE_INDEXED); } @@ -868,6 +776,19 @@ } /** + * Check if the given attribute has the + * {@link EugeneStereoTypes#STEREOTYPE_UNIQUE} stereotype. + * + * @param attribute attribute to test + * @return {@code true} if stereotype was found, {@code false otherwise} + * @see EugeneStereoTypes#STEREOTYPE_UNIQUE + * @since 2.8 + */ + public static boolean hasUniqueStereotype(ObjectModelAttribute attribute) { + return attribute.hasStereotype(EugeneStereoTypes.STEREOTYPE_UNIQUE); + } + + /** * Obtain the value of the {@link EugeneTagValues#TAG_DOCUMENTATION} * tag value on the given model. * Modified: trunk/eugene/src/main/java/org/nuiton/eugene/java/JavaGeneratorUtil.java =================================================================== --- trunk/eugene/src/main/java/org/nuiton/eugene/java/JavaGeneratorUtil.java 2014-04-15 09:37:25 UTC (rev 1327) +++ trunk/eugene/src/main/java/org/nuiton/eugene/java/JavaGeneratorUtil.java 2014-04-15 13:20:57 UTC (rev 1328) @@ -29,15 +29,24 @@ import org.nuiton.eugene.EugeneTagValues; import org.nuiton.eugene.GeneratorUtil; import org.nuiton.eugene.models.object.ObjectModel; +import org.nuiton.eugene.models.object.ObjectModelAttribute; +import org.nuiton.eugene.models.object.ObjectModelClass; import org.nuiton.eugene.models.object.ObjectModelClassifier; import org.nuiton.eugene.models.object.ObjectModelElement; import org.nuiton.eugene.models.object.ObjectModelJavaModifier; import org.nuiton.eugene.models.object.ObjectModelModifier; import org.nuiton.eugene.models.object.ObjectModelOperation; import org.nuiton.eugene.models.object.ObjectModelParameter; +import org.nuiton.util.StringUtil; import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedHashSet; +import java.util.LinkedList; import java.util.List; +import java.util.Set; /** * Utility class for pure java templates. @@ -409,4 +418,160 @@ return parts.toArray(new String[parts.size()]); } + + public static boolean isOrdered(ObjectModelAttribute attr) { + return attr.isOrdered() || hasOrderedStereotype(attr); + } + + public static Class<?> getCollectionType(ObjectModelAttribute attr) { + + boolean ordered = isOrdered(attr); + boolean unique = hasUniqueStereotype(attr); + + // Change type for Multiple attribute + Class<?> result; + + if (ordered) { + if (unique) { + result = LinkedHashSet.class; + } else { + result = List.class; + } + } else { + if (unique) { + result = Set.class; + } else { + result = Collection.class; + } + } + return result; + } + + public static Class<?> getCollectionInstanceType(ObjectModelAttribute attr) { + + boolean ordered = isOrdered(attr); + boolean unique = hasUniqueStereotype(attr); + + // Change type for Multiple attribute + Class<?> result; + + if (ordered) { + if (unique) { + result = LinkedHashSet.class; + } else { + result = LinkedList.class; + } + } else { + if (unique) { + result = HashSet.class; + } else { + result = LinkedList.class; + } + } + return result; + } + + /** + * Used to return the {@code 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. + * + * @param operation to treate + * @return the string corresponding to the list of operation parameters + * for declaration syntax. + */ + public static String getOperationParametersListDeclaration( + ObjectModelOperation operation) { + String result = StringUtil.join( + operation.getParameters(), + OBJECT_MODEL_PARAMETER_TO_STRING_TYPE, + ", ", + false); + return result; + } + + /** + * ToString contract for ObjectModelParameter with type and name. This + * contract is used in + * {@link StringUtil#join(Iterable, org.nuiton.util.StringUtil.ToString, String, boolean)} + */ + static final StringUtil.ToString<ObjectModelParameter> + OBJECT_MODEL_PARAMETER_TO_STRING_TYPE = + new StringUtil.ToString<ObjectModelParameter>() { + + @Override + public String toString(ObjectModelParameter param) { + return new StringBuilder(getAttributeType(param)). + append(' '). + append(param.getName()). + toString(); + } + }; + + /** + * @param clazz the class where to look at + * @return sous forme de String la liste des déclarations des attributes d'une classe donnée + */ + public static String getClassAttributesListDeclaration( + ObjectModelClass clazz) { + StringBuilder result = new StringBuilder(); + + Collection<ObjectModelAttribute> params = clazz.getAttributes(); + for (Iterator<ObjectModelAttribute> j = params.iterator(); j.hasNext(); ) { + ObjectModelAttribute attr = j.next(); + result.append(getAttributeType(attr, true)).append(" ").append(attr.getName()); + if (j.hasNext()) { + result.append(", "); + } + } + return result.toString(); + } + + /** + * @param attribute the attribute to test + * @return the type of the given attribute + * @see #getAttributeType(ObjectModelParameter, boolean) + */ + public static String getAttributeType(ObjectModelParameter attribute) { + return getAttributeType(attribute, false); + } + + /** + * 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 + * + * @param attribute the attribute to test + * @param useGenerics {@code true} if the attribute use a generic type + * @return attribute type + */ + public static String getAttributeType(ObjectModelParameter attribute, + boolean useGenerics) { + return getAttributeType(attribute, attribute.getType(), 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 + * + * @param attribute the attribute to test + * @param attributeType the attribute type + * @param useGenerics {@code true} if the attribute use a generic type + * @return attribute type + */ + public static String getAttributeType(ObjectModelParameter attribute, + String attributeType, + boolean useGenerics) { + String result; + if (attribute instanceof ObjectModelAttribute + && isNMultiplicity((ObjectModelAttribute) attribute)) { + + result = getCollectionType((ObjectModelAttribute) attribute).getName(); + if (useGenerics) { + result += "<" + attributeType + ">"; + } + } else { + result = attributeType; + } + return result; + } } Modified: trunk/eugene/src/main/java/org/nuiton/eugene/models/object/xml/ObjectModelAttributeImpl.java =================================================================== --- trunk/eugene/src/main/java/org/nuiton/eugene/models/object/xml/ObjectModelAttributeImpl.java 2014-04-15 09:37:25 UTC (rev 1327) +++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/xml/ObjectModelAttributeImpl.java 2014-04-15 13:20:57 UTC (rev 1328) @@ -31,7 +31,6 @@ import org.apache.commons.lang3.StringUtils; import org.nuiton.eugene.EugeneStereoTypes; import org.nuiton.eugene.GeneratorUtil; -import org.nuiton.eugene.java.JavaGeneratorUtil; import org.nuiton.eugene.models.object.ObjectModelAttribute; import org.nuiton.eugene.models.object.ObjectModelClass; import org.nuiton.eugene.models.object.ObjectModelClassifier; @@ -307,13 +306,4 @@ } return super.addStereotype(stereotype); } - - /** - * FIXME tchemit 2010-11-28 Why the ordered flag may be indexed ? This is two distinct concepts ? - */ - @Override - public boolean isOrdered() { - return JavaGeneratorUtil.hasIndexedStereotype(this) || super.isOrdered(); - } - } Modified: trunk/eugene/src/test/java/org/nuiton/eugene/GeneratorUtilTest.java =================================================================== --- trunk/eugene/src/test/java/org/nuiton/eugene/GeneratorUtilTest.java 2014-04-15 09:37:25 UTC (rev 1327) +++ trunk/eugene/src/test/java/org/nuiton/eugene/GeneratorUtilTest.java 2014-04-15 13:20:57 UTC (rev 1328) @@ -69,38 +69,7 @@ Assert.assertEquals("param1, param2", result); } - @Test - public void testGetOperationParametersListDeclaration() { - if (log.isDebugEnabled()) { - log.debug("getOperationParametersListDeclaration"); - } - ObjectModelOperationImpl op = new ObjectModelOperationImpl(); - - // Without any params - String result = GeneratorUtil.getOperationParametersListDeclaration(op); - Assert.assertEquals("", result); - - // With one param - ObjectModelParameterImpl param1 = new ObjectModelParameterImpl(); - param1.setType("String"); - param1.setName("param1"); - op.addParameter(param1); - - result = GeneratorUtil.getOperationParametersListDeclaration(op); - Assert.assertEquals("String param1", result); - - // With two params - ObjectModelParameterImpl param2 = new ObjectModelParameterImpl(); - param2.setType("Date"); - param2.setName("param2"); - op.addParameter(param2); - - result = GeneratorUtil.getOperationParametersListDeclaration(op); - Assert.assertEquals("String param1, Date param2", result); - } - - /** Test of getSimpleName method, of class GeneratorUtil. */ @Test public void testGetSimpleName() { Modified: trunk/eugene/src/test/java/org/nuiton/eugene/java/JavaGeneratorUtilTest.java =================================================================== --- trunk/eugene/src/test/java/org/nuiton/eugene/java/JavaGeneratorUtilTest.java 2014-04-15 09:37:25 UTC (rev 1327) +++ trunk/eugene/src/test/java/org/nuiton/eugene/java/JavaGeneratorUtilTest.java 2014-04-15 13:20:57 UTC (rev 1328) @@ -24,8 +24,13 @@ */ package org.nuiton.eugene.java; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.junit.Assert; import org.junit.Test; +import org.nuiton.eugene.GeneratorUtil; +import org.nuiton.eugene.models.object.xml.ObjectModelOperationImpl; +import org.nuiton.eugene.models.object.xml.ObjectModelParameterImpl; import org.nuiton.util.StringUtil; import java.beans.Introspector; @@ -38,6 +43,8 @@ */ public class JavaGeneratorUtilTest { + private static final Log log = LogFactory.getLog(JavaGeneratorUtilTest.class); + @Test public void splitGeneric() throws Exception { @@ -168,4 +175,35 @@ Assert.assertEquals(expected, actual); Assert.assertEquals(Introspector.decapitalize(actual), original); } + + @Test + public void testGetOperationParametersListDeclaration() { + if (log.isDebugEnabled()) { + log.debug("getOperationParametersListDeclaration"); + } + + ObjectModelOperationImpl op = new ObjectModelOperationImpl(); + + // Without any params + String result = JavaGeneratorUtil.getOperationParametersListDeclaration(op); + Assert.assertEquals("", result); + + // With one param + ObjectModelParameterImpl param1 = new ObjectModelParameterImpl(); + param1.setType("String"); + param1.setName("param1"); + op.addParameter(param1); + + result = JavaGeneratorUtil.getOperationParametersListDeclaration(op); + Assert.assertEquals("String param1", result); + + // With two params + ObjectModelParameterImpl param2 = new ObjectModelParameterImpl(); + param2.setType("Date"); + param2.setName("param2"); + op.addParameter(param2); + + result = JavaGeneratorUtil.getOperationParametersListDeclaration(op); + Assert.assertEquals("String param1, Date param2", result); + } } Modified: trunk/eugene-java-templates/src/main/java/org/nuiton/eugene/java/AbstractJavaBeanTransformer.java =================================================================== --- trunk/eugene-java-templates/src/main/java/org/nuiton/eugene/java/AbstractJavaBeanTransformer.java 2014-04-15 09:37:25 UTC (rev 1327) +++ trunk/eugene-java-templates/src/main/java/org/nuiton/eugene/java/AbstractJavaBeanTransformer.java 2014-04-15 13:20:57 UTC (rev 1328) @@ -40,7 +40,6 @@ import java.beans.PropertyChangeSupport; import java.io.Serializable; import java.util.ArrayList; -import java.util.Collection; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -182,11 +181,7 @@ ); // Change type for Multiple attribute - if (attr.isOrdered()) { - attrType = List.class.getName() + "<" + attrType + ">"; - } else { - attrType = Collection.class.getName() + "<" + attrType + ">"; - } + attrType = JavaGeneratorUtil.getAttributeType(attr, true); simpleType = JavaGeneratorUtil.getSimpleName(attrType); } Modified: trunk/eugene-maven-plugin/src/it/generate/generators/src/main/java/org/nuiton/eugene/test/generator/BeanGenerator.java =================================================================== --- trunk/eugene-maven-plugin/src/it/generate/generators/src/main/java/org/nuiton/eugene/test/generator/BeanGenerator.java 2014-04-15 09:37:25 UTC (rev 1327) +++ trunk/eugene-maven-plugin/src/it/generate/generators/src/main/java/org/nuiton/eugene/test/generator/BeanGenerator.java 2014-04-15 13:20:57 UTC (rev 1328) @@ -39,34 +39,33 @@ package org.nuiton.eugene.test.generator; import org.apache.commons.lang3.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.eugene.GeneratorUtil; +import org.nuiton.eugene.java.JavaGeneratorUtil; +import org.nuiton.eugene.java.extension.ImportsManager; +import org.nuiton.eugene.models.object.ObjectModelAttribute; +import org.nuiton.eugene.models.object.ObjectModelClass; +import org.nuiton.eugene.models.object.ObjectModelClassifier; +import org.nuiton.eugene.models.object.ObjectModelDependency; +import org.nuiton.eugene.models.object.ObjectModelGenerator; +import org.nuiton.eugene.models.object.ObjectModelInterface; +import org.nuiton.eugene.models.object.ObjectModelOperation; +import org.nuiton.eugene.models.object.ObjectModelParameter; import java.io.File; import java.io.IOException; import java.io.Serializable; import java.io.Writer; +import java.lang.String; import java.util.ArrayList; import java.util.Collection; import java.util.Comparator; +import java.util.HashSet; import java.util.Iterator; - import java.util.List; import java.util.Set; -import java.util.HashSet; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.nuiton.eugene.models.object.ObjectModelGenerator; -import org.nuiton.eugene.GeneratorUtil; -import org.nuiton.eugene.models.object.ObjectModelAttribute; -import org.nuiton.eugene.models.object.ObjectModelClass; -import org.nuiton.eugene.models.object.ObjectModelClassifier; -import org.nuiton.eugene.models.object.ObjectModelDependency; -import org.nuiton.eugene.models.object.ObjectModelInterface; -import org.nuiton.eugene.models.object.ObjectModelOperation; -import org.nuiton.eugene.models.object.ObjectModelParameter; -import org.nuiton.eugene.java.extension.ImportsManagerExtension; -import org.nuiton.eugene.java.extension.ImportsManager; - /** * DTO generator * @plexus.component role="org.nuiton.eugene.Template" role-hint="org.nuiton.eugene.test.generator.BeanGenerator" @@ -156,7 +155,7 @@ } boolean isEntity = (attrEntity != null && attrEntity.hasStereotype(STEREOTYPE_ENTITY)); needGetEntityMethod |= isEntity; - if (attr.isOrdered()) { + if (JavaGeneratorUtil.isOrdered(attr)) { needListInImport = true; } } @@ -359,7 +358,7 @@ attrType = attrType.substring(dot + 1); } if (GeneratorUtil.isNMultiplicity(attr)) { - attrType = getCollection(attr, attrType); + attrType = JavaGeneratorUtil.getAttributeType(attr, attrType, true); } /*{ <%=attrVisibility%> <%=attrType%> <%=attrName%>; @@ -408,7 +407,7 @@ attrType = attrType.substring(dot + 1); } if (GeneratorUtil.isNMultiplicity(attr)) { - attrType = getCollection(attr, attrType); + attrType = JavaGeneratorUtil.getAttributeType(attr, attrType, true); } /*{ public <%=attrType%> get<%=attrNameCapitalized%>() { return <%=attrName%>; @@ -442,7 +441,7 @@ attrType = attrType.substring(dot + 1); } if (GeneratorUtil.isNMultiplicity(attr)) { - attrType = getCollection(attr, attrType); + attrType = JavaGeneratorUtil.getAttributeType(attr, attrType, true); } /*{ public void set<%=attrNameCapitalized%>(<%=attrType%> newValue) { <%=attrType%> oldValue = get<%=attrNameCapitalized%>(); @@ -588,18 +587,6 @@ }*/ } - protected String getCollection(ObjectModelAttribute attr, String attrType) { - String nMultType; - if (attr.isOrdered()) { - nMultType = "List<"; - } else { - nMultType = "Collection<"; - } - nMultType += attrType; - nMultType += ">"; - return nMultType; - } - protected boolean isAbstract(ObjectModelClass clazz) { if (clazz.isAbstract()) { return true; Modified: trunk/eugene-maven-plugin/src/it/generate/generators/src/main/java/org/nuiton/eugene/test/generator/BeanTransformer.java =================================================================== --- trunk/eugene-maven-plugin/src/it/generate/generators/src/main/java/org/nuiton/eugene/test/generator/BeanTransformer.java 2014-04-15 09:37:25 UTC (rev 1327) +++ trunk/eugene-maven-plugin/src/it/generate/generators/src/main/java/org/nuiton/eugene/test/generator/BeanTransformer.java 2014-04-15 13:20:57 UTC (rev 1328) @@ -46,6 +46,7 @@ import org.apache.commons.lang3.StringUtils; import org.nuiton.eugene.GeneratorUtil; +import org.nuiton.eugene.java.JavaGeneratorUtil; import org.nuiton.eugene.java.ObjectModelTransformerToJava; import org.nuiton.eugene.models.object.*; @@ -177,11 +178,7 @@ ); // Change type for Multiple attribute - if (attr.isOrdered()) { - attrType = List.class.getName() + "<" + attrType + ">"; - } else { - attrType = Collection.class.getName() + "<" + attrType + ">"; - } + attrType = JavaGeneratorUtil.getAttributeType(attr, true); simpleType = GeneratorUtil.getSimpleName(attrType); }