We already are generating compatibility setters, this extends this
capability to wrapper classes (i.e. their constructors). As usual
the compatibility code is marked as deprecated for removal.
Also fixes some code formatting issues introduces in previous
patches.
JIRA: MDSAL-330
Change-Id: I0b2db136c27c26de33f8a756292dde4cdf53bebb
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
import com.google.common.base.CharMatcher
import com.google.common.base.MoreObjects
import com.google.common.base.Splitter
import com.google.common.base.CharMatcher
import com.google.common.base.MoreObjects
import com.google.common.base.Splitter
+import com.google.common.collect.ImmutableMap
import com.google.common.collect.Iterables
import com.google.common.collect.Iterables
+import java.math.BigInteger
import java.util.Collection
import java.util.List
import java.util.Locale
import java.util.Collection
import java.util.List
import java.util.Locale
import org.opendaylight.mdsal.binding.spec.naming.BindingMapping
import org.opendaylight.yangtools.yang.binding.CodeHelpers
import org.opendaylight.yangtools.yang.common.QName
import org.opendaylight.mdsal.binding.spec.naming.BindingMapping
import org.opendaylight.yangtools.yang.binding.CodeHelpers
import org.opendaylight.yangtools.yang.common.QName
+import org.opendaylight.yangtools.yang.common.Uint8
+import org.opendaylight.yangtools.yang.common.Uint16
+import org.opendaylight.yangtools.yang.common.Uint32
+import org.opendaylight.yangtools.yang.common.Uint64
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode
import org.opendaylight.yangtools.yang.model.api.ListSchemaNode
import org.opendaylight.yangtools.yang.model.api.NotificationDefinition
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode
import org.opendaylight.yangtools.yang.model.api.ListSchemaNode
import org.opendaylight.yangtools.yang.model.api.NotificationDefinition
.addIgnoredStatement(YangStmtMapping.ORGANIZATION)
.build();
.addIgnoredStatement(YangStmtMapping.ORGANIZATION)
.build();
+ protected static val UINT_TYPES = ImmutableMap.of(
+ Types.typeForClass(Uint8), Types.typeForClass(Short),
+ Types.typeForClass(Uint16), Types.typeForClass(Integer),
+ Types.typeForClass(Uint32), Types.typeForClass(Long),
+ Types.typeForClass(Uint64), Types.typeForClass(BigInteger)
+ );
+
new(GeneratedType type) {
super(type)
}
new(GeneratedType type) {
super(type)
}
import static org.opendaylight.mdsal.binding.spec.naming.BindingMapping.AUGMENTATION_FIELD
import com.google.common.collect.ImmutableList
import static org.opendaylight.mdsal.binding.spec.naming.BindingMapping.AUGMENTATION_FIELD
import com.google.common.collect.ImmutableList
-import com.google.common.collect.ImmutableMap
-import java.math.BigInteger
import java.util.ArrayList
import java.util.Collection
import java.util.HashMap
import java.util.ArrayList
import java.util.Collection
import java.util.HashMap
import org.opendaylight.yangtools.yang.binding.AugmentationHolder
import org.opendaylight.yangtools.yang.binding.CodeHelpers
import org.opendaylight.yangtools.yang.binding.DataObject
import org.opendaylight.yangtools.yang.binding.AugmentationHolder
import org.opendaylight.yangtools.yang.binding.CodeHelpers
import org.opendaylight.yangtools.yang.binding.DataObject
-import org.opendaylight.yangtools.yang.common.Uint8
-import org.opendaylight.yangtools.yang.common.Uint16
-import org.opendaylight.yangtools.yang.common.Uint64
-import org.opendaylight.yangtools.yang.common.Uint32
/**
* Template for generating JAVA builder classes.
/**
* Template for generating JAVA builder classes.
static val AUGMENTATION_FIELD_UPPER = AUGMENTATION_FIELD.toFirstUpper
static val AUGMENTATION_FIELD_UPPER = AUGMENTATION_FIELD.toFirstUpper
- static val UINT_TYPES = ImmutableMap.of(
- Types.typeForClass(Uint8), Types.typeForClass(Short),
- Types.typeForClass(Uint16), Types.typeForClass(Integer),
- Types.typeForClass(Uint32), Types.typeForClass(Long),
- Types.typeForClass(Uint64), Types.typeForClass(BigInteger)
- );
-
/**
* Constructs new instance of this class.
* @throws IllegalArgumentException if <code>genType</code> equals <code>null</code>
/**
* Constructs new instance of this class.
* @throws IllegalArgumentException if <code>genType</code> equals <code>null</code>
def private generateSetter(GeneratedProperty field, Type actualType) '''
«val restrictions = restrictionsForSetter(actualType)»
«IF restrictions !== null»
def private generateSetter(GeneratedProperty field, Type actualType) '''
«val restrictions = restrictionsForSetter(actualType)»
«IF restrictions !== null»
«generateCheckers(field, restrictions, actualType)»
«ENDIF»
«val setterName = "set" + field.getName.toFirstUpper»
public «type.getName» «setterName»(final «field.returnType.importedName» value) {
«generateCheckers(field, restrictions, actualType)»
«ENDIF»
«val setterName = "set" + field.getName.toFirstUpper»
public «type.getName» «setterName»(final «field.returnType.importedName» value) {
- «IF restrictions !== null»
- if (value != null) {
- «checkArgument(field, restrictions, actualType, "value")»
- }
- «ENDIF»
+ «IF restrictions !== null»
+ if (value != null) {
+ «checkArgument(field, restrictions, actualType, "value")»
+ }
+ «ENDIF»
this.«field.fieldName.toString» = value;
return this;
}
«val uintType = UINT_TYPES.get(field.returnType)»
«IF uintType !== null»
this.«field.fieldName.toString» = value;
return this;
}
«val uintType = UINT_TYPES.get(field.returnType)»
«IF uintType !== null»
- /**
- * Utility migration setter.
- *
- * @deprecated Use {#link «setterName»(«field.returnType.importedName»)} instead.
- */
- @Deprecated(forRemoval = true)
- public «type.getName» «setterName»(final «uintType.importedName» value) {
- return «setterName»(«CodeHelpers.importedName».compatUint(value));
- }
+ /**
+ * Utility migration setter.
+ *
+ * @param value field value in legacy type
+ * @deprecated Use {#link «setterName»(«field.returnType.importedName»)} instead.
+ */
+ @Deprecated(forRemoval = true)
+ public «type.getName» «setterName»(final «uintType.importedName» value) {
+ return «setterName»(«CodeHelpers.importedName».compatUint(value));
+ }
+ «val propType = allProperties.get(0).returnType»
+ «val uintType = UINT_TYPES.get(propType)»
+ «IF uintType !== null»
+
+ /**
+ * Utility migration constructor.
+ *
+ * @param value Wrapped value in legacy type
+ * @deprecated Use {#link «type.name»(«propType.importedName»)} instead.
+ */
+ @Deprecated(forRemoval = true)
+ public «type.getName»(final «uintType.importedName» value) {
+ this(«CodeHelpers.importedName».compatUint(value));
+ }
+ «ENDIF»
'''
def protected genUnionConstructor() '''
'''
def protected genUnionConstructor() '''