import static org.opendaylight.mdsal.binding.model.ri.BaseYangTypes.UINT64_TYPE
import static org.opendaylight.mdsal.binding.model.ri.BaseYangTypes.UINT8_TYPE
import static org.opendaylight.mdsal.binding.model.ri.BindingTypes.SCALAR_TYPE_OBJECT
-import static org.opendaylight.mdsal.binding.model.ri.Types.BOOLEAN
import static org.opendaylight.mdsal.binding.model.ri.Types.STRING;
import static extension org.apache.commons.text.StringEscapeUtils.escapeJava
import static extension org.opendaylight.mdsal.binding.model.ri.BindingTypes.isBitsType
import java.util.Map
import java.util.Set
import javax.management.ConstructorParameters
-import org.gaul.modernizer_maven_annotations.SuppressModernizer
import org.opendaylight.mdsal.binding.model.api.ConcreteType
import org.opendaylight.mdsal.binding.model.api.Constant
import org.opendaylight.mdsal.binding.model.api.Enumeration
/**
* Template for generating JAVA class.
*/
-@SuppressModernizer
class ClassTemplate extends BaseTemplate {
static val Comparator<GeneratedProperty> PROP_COMPARATOR = Comparator.comparing([prop | prop.name])
static val VALUEOF_TYPES = Set.of(
'''
- def private propertyMethods() {
+ def protected propertyMethods() {
if (properties.empty) {
return ""
}
def private genPatternEnforcer(String ref) '''
«FOR c : consts»
- «IF c.name == TypeConstants.PATTERN_CONSTANT_NAME»
+ «IF TypeConstants.PATTERN_CONSTANT_NAME.equals(c.name)»
«CODEHELPERS.importedName».checkPattern(«ref», «Constants.MEMBER_PATTERN_LIST», «Constants.MEMBER_REGEX_LIST»);
«ENDIF»
«ENDFOR»
int i = 0;
return new «genTO.name»(
«FOR prop : allProperties SEPARATOR ","»
- properties.get(i++).equals(defaultValue) ? «BOOLEAN.importedName».TRUE : null
+ properties.get(i++).equals(defaultValue) ? true : false
«ENDFOR»
);
'''
def protected constantsDeclarations() '''
«IF !consts.empty»
«FOR c : consts»
- «IF c.name == TypeConstants.PATTERN_CONSTANT_NAME»
+ «IF TypeConstants.PATTERN_CONSTANT_NAME.equals(c.name)»
«val cValue = c.value as Map<String, String>»
«val jurPatternRef = JUR_PATTERN.importedName»
public static final «JU_LIST.importedName»<String> «TypeConstants.PATTERN_CONSTANT_NAME» = «ImmutableList.importedName».of(«
def private generateEquals() '''
«IF !genTO.equalsIdentifiers.empty»
@«OVERRIDE.importedName»
- public final boolean equals(java.lang.Object obj) {
- if (this == obj) {
- return true;
- }
- if (!(obj instanceof «type.name»)) {
- return false;
- }
- final «type.name» other = («type.name») obj;
+ public final boolean equals(«OBJECT.importedName» obj) {
+ return this == obj || obj instanceof «type.name» other
«FOR property : genTO.equalsIdentifiers»
«val fieldName = property.fieldName»
- if (!«property.importedUtilClass».equals(«fieldName», other.«fieldName»)) {
- return false;
- }
- «ENDFOR»
- return true;
+ && «property.importedUtilClass».equals(«fieldName», other.«fieldName»)«
+ »«ENDFOR»;
}
«ENDIF»
'''