1 package org.opendaylight.yangtools.sal.java.api.generator
\r
3 import org.opendaylight.yangtools.sal.binding.model.api.GeneratedTransferObject
\r
7 * Template for generating JAVA class.
\r
9 class UnionTemplate extends ClassTemplate {
\r
14 * Creates instance of this class with concrete <code>genType</code>.
\r
16 * @param genType generated transfer object which will be transformed to JAVA class source code
\r
18 new(GeneratedTransferObject genType) {
\r
25 override constructors() '''
\r
27 «IF !allProperties.empty»
\r
30 «IF properties.empty && !parentProperties.empty »
\r
36 def unionConstructors() '''
\r
37 «FOR property : finalProperties SEPARATOR "\n"»
\r
38 «val propertyAndTopParentProperties = parentProperties + #[property]»
\r
39 public «type.name»(«propertyAndTopParentProperties.asArgumentsDeclaration») {
\r
40 super(«parentProperties.asArguments»);
\r
41 this.«property.fieldName» = «property.fieldName»;
\r
42 «FOR other : finalProperties»
\r
43 «IF property != other»this.«other.fieldName» = null;«ENDIF»
\r