- Preconditions.checkArgument("char[]".equals(field.returnType.importedName))
-
- '''
- public char[] «field.getterMethodName»() {
- if («field.fieldName» == null) {
- «FOR property : finalProperties.filter([ p | !"value".equals(p.name)]) SEPARATOR " else"»
- if («property.fieldName» != null) {
- «val propRet = property.returnType»
- «IF "java.lang.String".equals(propRet.fullyQualifiedName)»
- ««« type string
- «field.fieldName» = «property.fieldName».toCharArray();
- «ELSEIF "org.opendaylight.yangtools.yang.binding.InstanceIdentifier".equals(propRet.fullyQualifiedName)»
- ««« type instance-identifier
- «field.fieldName» = «property.fieldName».toString().toCharArray();
- «ELSEIF "byte[]".equals(propRet.name)»
- ««« type binary
- «field.fieldName» = new «String.importedName»(«property.fieldName»).toCharArray();
- «ELSEIF propRet.fullyQualifiedName.startsWith("java.lang")
- || propRet instanceof Enumeration
- || propRet.fullyQualifiedName.startsWith("java.math")»
- ««« type int*, uint, decimal64 or enumeration*
- «field.fieldName» = «property.fieldName».toString().toCharArray();
- «ELSEIF propRet instanceof GeneratedTransferObject && (propRet as GeneratedTransferObject).unionType»
- ««« union type
- «field.fieldName» = «property.fieldName».getValue();
- «ELSEIF propRet instanceof GeneratedTransferObject // Is it a GeneratedTransferObject
- && (propRet as GeneratedTransferObject).typedef // Is it a typedef
- && (propRet as GeneratedTransferObject).properties !== null
- && !(propRet as GeneratedTransferObject).properties.empty
- && ((propRet as GeneratedTransferObject).properties.size == 1)
- && (propRet as GeneratedTransferObject).properties.get(0).name.equals("value")
- && BOOLEAN.equals((propRet as GeneratedTransferObject).properties.get(0).returnType)» // And the property value is of type boolean
- ««« generated boolean typedef
- «field.fieldName» = «property.fieldName».isValue().toString().toCharArray();
- «ELSEIF propRet instanceof GeneratedTransferObject // Is it a GeneratedTransferObject
- && (propRet as GeneratedTransferObject).typedef // Is it a typedef
- && (propRet as GeneratedTransferObject).properties !== null
- && !(propRet as GeneratedTransferObject).properties.empty
- && ((propRet as GeneratedTransferObject).properties.size == 1)
- && (propRet as GeneratedTransferObject).properties.get(0).name.equals("value")
- && "byte[]".equals((propRet as GeneratedTransferObject).properties.get(0).returnType.name)»
- ««« generated byte[] typedef
- «field.fieldName» = BaseEncoding.base64().encode(«property.fieldName».getValue()).toCharArray();
- «ELSEIF propRet instanceof GeneratedTransferObject // Is it a GeneratedTransferObject
- && (propRet as GeneratedTransferObject).typedef // Is it a typedef
- && (propRet as GeneratedTransferObject).baseType instanceof BitsTypeDefinition»
- ««« generated bits typedef
- «field.fieldName» = java.util.Arrays.toString(«property.fieldName».getValue()).toCharArray();
- «ELSE»
- ««« generated type
- «field.fieldName» = «property.fieldName».getValue().toString().toCharArray();
- «ENDIF»
- }
- «ENDFOR»
- }
- return «field.fieldName» == null ? null : «field.fieldName».clone();
- }
- '''