import org.opendaylight.yangtools.sal.binding.model.api.GeneratedProperty\r
import org.opendaylight.yangtools.sal.binding.model.api.GeneratedTransferObject\r
import org.opendaylight.yangtools.sal.binding.model.api.GeneratedType\r
-\r
+import java.util.ArrayList\r
+import java.util.Collections\r
\r
/**\r
* Template for generating JAVA class. \r
\r
\r
protected val GeneratedTransferObject genTO;\r
- \r
+\r
/**\r
* Creates instance of this class with concrete <code>genType</code>.\r
* \r
this.properties = genType.properties\r
this.finalProperties = GeneratorUtil.resolveReadOnlyPropertiesFromTO(genTO.properties)\r
this.parentProperties = GeneratorUtil.getPropertiesOfAllParents(genTO)\r
- this.allProperties = properties + parentProperties\r
+\r
+ var List<GeneratedProperty> sorted = new ArrayList<GeneratedProperty>();\r
+ sorted.addAll(properties);\r
+ sorted.addAll(parentProperties);\r
+ Collections.sort(sorted, new PropertyComparator());\r
+ \r
+ this.allProperties = sorted\r
this.enums = genType.enumerations\r
this.consts = genType.constantDefinitions\r
this.enclosedGeneratedTypes = genType.enclosedTypes\r
* \r
* @return string with JAVA class body source code\r
*/\r
- def generateAsInnerClass() {\r
+ def CharSequence generateAsInnerClass() {\r
return generateBody(true)\r
}\r
\r
«IF cValue instanceof List<?>»\r
«val cValues = cValue as List<?>»\r
private static final List<Pattern> «Constants.MEMBER_PATTERN_LIST» = new ArrayList<Pattern>();\r
- public static final List<String> «TypeConstants.PATTERN_CONSTANT_NAME» = Arrays.asList(«\r
+ public static final List<String> «TypeConstants.PATTERN_CONSTANT_NAME» = java.util.Arrays.asList(«\r
FOR v : cValues SEPARATOR ", "»«\r
IF v instanceof String»"«\r
v as String»"«\r
ENDIF»«\r
ENDFOR»);\r
- \r
+\r
«generateStaticInicializationBlock»\r
«ENDIF»\r
«ELSE»\r
«ENDFOR»\r
«ENDIF»\r
'''\r
- \r
+\r
/**\r
* Template method which generates JAVA static initialization block.\r
- * \r
+ *\r
* @return string with static initialization block in JAVA format\r
*/\r
def protected generateStaticInicializationBlock() '''\r
}\r
}\r
'''\r
- \r
+\r
/**\r
* Template method which generates JAVA class attributes.\r
- * \r
+ *\r
* @return string with the class attributes in JAVA format\r
*/\r
def protected generateFields() '''\r
«ENDFOR»\r
«ENDIF»\r
'''\r
- \r
+\r
\r
/**\r
* Template method which generates the method <code>hashCode()</code>.\r
- * \r
+ *\r
* @return string with the <code>hashCode()</code> method definition in JAVA format\r
*/\r
def protected generateHashCode() '''\r
final int prime = 31;\r
int result = 1;\r
«FOR property : genTO.hashCodeIdentifiers»\r
+ «IF property.returnType.name.contains("[")»\r
+ result = prime * result + ((«property.fieldName» == null) ? 0 : java.util.Arrays.hashCode(«property.fieldName»));\r
+ «ELSE»\r
result = prime * result + ((«property.fieldName» == null) ? 0 : «property.fieldName».hashCode());\r
+ «ENDIF»\r
«ENDFOR»\r
return result;\r
}\r
«ENDIF»\r
'''\r
- \r
+\r
/**\r
* Template method which generates the method <code>equals()</code>.\r
- * \r
- * @return string with the <code>equals()</code> method definition in JAVA format \r
+ *\r
+ * @return string with the <code>equals()</code> method definition in JAVA format\r
*/\r
def protected generateEquals() '''\r
«IF !genTO.equalsIdentifiers.empty»\r
if (other.«fieldName» != null) {\r
return false;\r
}\r
+ «IF property.returnType.name.contains("[")»\r
+ } else if(!java.util.Arrays.equals(«fieldName», other.«fieldName»)) {\r
+ «ELSE»\r
} else if(!«fieldName».equals(other.«fieldName»)) {\r
+ «ENDIF»\r
return false;\r
}\r
«ENDFOR»\r
}\r
«ENDIF»\r
'''\r
- \r
+\r
/**\r
* Template method which generates the method <code>toString()</code>.\r
- * \r
- * @return string with the <code>toString()</code> method definition in JAVA format \r
+ *\r
+ * @return string with the <code>toString()</code> method definition in JAVA format\r
*/\r
def protected generateToString() '''\r
«IF !genTO.toStringIdentifiers.empty»\r
«ELSE»\r
builder.append(«properties.get(0).fieldName»);\r
«ENDIF»\r
- builder.append(«properties.get(0).fieldName»);\r
«FOR i : 1..<genTO.toStringIdentifiers.size»\r
builder.append(", «properties.get(i).fieldName»=");\r
«IF properties.get(i).returnType.name.contains("[")»\r