import static org.opendaylight.mdsal.binding.model.util.Types.BOOLEAN;
import static org.opendaylight.mdsal.binding.model.util.Types.BYTE_ARRAY;
+import static org.opendaylight.mdsal.binding.model.util.Types.STRING;
import static org.opendaylight.mdsal.binding.model.util.Types.getOuterClassName;
import java.util.Arrays
* Template for generating JAVA class.
*/
class UnionTemplate extends ClassTemplate {
-
/**
* Creates instance of this class with concrete <code>genType</code>.
*
«val field = property.fieldName»
if («field» != null) {
«val propRet = property.returnType»
- «IF "java.lang.String".equals(propRet.fullyQualifiedName)»
+ «IF STRING.equals(propRet)»
««« type string
return «field»;
«ELSEIF "org.opendaylight.yangtools.yang.binding.InstanceIdentifier".equals(propRet.fullyQualifiedName)»
««« type instance-identifier
return «field».toString();
- «ELSEIF "byte[]".equals(propRet.name)»
+ «ELSEIF BYTE_ARRAY.equals(propRet)»
««« type binary
return new «String.importedName»(«field»);
«ELSEIF propRet.fullyQualifiedName.startsWith("java.lang") || propRet instanceof Enumeration
«ELSEIF BYTE_ARRAY.equals(propRet.typedefReturnType)»
««« generated byte[] typedef
return «Base64.importedName».getEncoder().encodeToString(«field».getValue());
+ «ELSEIF Constants.EMPTY.equals(propRet) || Constants.EMPTY.equals(propRet.typedefReturnType)»
+ ««« generated empty typedef
+ return "";
«ELSEIF propRet instanceof GeneratedTransferObject // Is it a GeneratedTransferObject
&& (propRet as GeneratedTransferObject).typedef // Is it a typedef
&& (propRet as GeneratedTransferObject).baseType instanceof BitsTypeDefinition»