import java.util.Arrays
import java.util.Collections
import java.util.List
+import java.util.Objects
import java.util.regex.Pattern
import org.opendaylight.yangtools.binding.generator.util.TypeConstants
import org.opendaylight.yangtools.sal.binding.model.api.ConcreteType
*/
def protected generateBody(boolean isInnerClass) '''
«wrapToDocumentation(formatDataForJavaDoc(type))»
+ «annotationDeclaration»
«generateClassDeclaration(isInnerClass)» {
«suidDeclaration»
«innerClassesDeclarations»
«ENDIF»
'''
+ def protected annotationDeclaration() '''
+ «IF genTO.getAnnotations != null»
+ «FOR e : genTO.getAnnotations»
+ @«e.getName»
+ «ENDFOR»
+ «ENDIF»
+ '''
+
/**
* Template method which generates JAVA constants.
*
ENDIF»«
ENDFOR»);
- «generateStaticInicializationBlock»
+ «generateStaticInitializationBlock»
«ENDIF»
«ELSE»
«emitConstant(c)»
*
* @return string with static initialization block in JAVA format
*/
- def protected generateStaticInicializationBlock() '''
+ def protected generateStaticInitializationBlock() '''
static {
final «Pattern.importedName» a[] = new «Pattern.importedName»[«TypeConstants.PATTERN_CONSTANT_NAME».size()];
int i = 0;
def protected generateFields() '''
«IF !properties.empty»
«FOR f : properties»
- private«IF f.readOnly» final«ENDIF» «f.returnType.importedName» «f.fieldName»;
+ private«IF isReadOnly(f)» final«ENDIF» «f.returnType.importedName» «f.fieldName»;
«ENDFOR»
«ENDIF»
'''
+ protected def isReadOnly(GeneratedProperty field) {
+ return field.readOnly
+ }
+
/**
* Template method which generates the method <code>hashCode()</code>.
*
int result = 1;
«FOR property : genTO.hashCodeIdentifiers»
«IF property.returnType.name.contains("[")»
- result = prime * result + ((«property.fieldName» == null) ? 0 : «Arrays.importedName».hashCode(«property.fieldName»));
+ result = prime * result + «Arrays.importedName».hashCode(«property.fieldName»);
«ELSE»
- result = prime * result + ((«property.fieldName» == null) ? 0 : «property.fieldName».hashCode());
+ result = prime * result + «Objects.importedName».hashCode(«property.fieldName»);
«ENDIF»
«ENDFOR»
return result;
«type.name» other = («type.name») obj;
«FOR property : genTO.equalsIdentifiers»
«val fieldName = property.fieldName»
- if («fieldName» == null) {
- if (other.«fieldName» != null) {
- return false;
- }
«IF property.returnType.name.contains("[")»
- } else if(!«Arrays.importedName».equals(«fieldName», other.«fieldName»)) {
+ if (!«Arrays.importedName».equals(«fieldName», other.«fieldName»)) {
«ELSE»
- } else if(!«fieldName».equals(other.«fieldName»)) {
+ if (!«Objects.importedName».equals(«fieldName», other.«fieldName»)) {
«ENDIF»
return false;
}