import java.util.List
import java.util.Map
import java.util.Set
+import org.opendaylight.mdsal.binding.model.api.AnnotationType
import org.opendaylight.mdsal.binding.model.api.GeneratedProperty
import org.opendaylight.mdsal.binding.model.api.GeneratedTransferObject
import org.opendaylight.mdsal.binding.model.api.GeneratedType
+import org.opendaylight.mdsal.binding.model.api.JavaTypeName
import org.opendaylight.mdsal.binding.model.api.Type
import org.opendaylight.mdsal.binding.model.util.Types
import org.opendaylight.mdsal.binding.spec.naming.BindingMapping
abstract class AbstractBuilderTemplate extends BaseTemplate {
static val Comparator<GeneratedProperty> KEY_PROPS_COMPARATOR = [ p1, p2 | return p1.name.compareTo(p2.name) ]
+ protected static val DEPRECATED = JavaTypeName.create(Deprecated);
+
/**
* Generated property is set if among methods is found one with the name GET_AUGMENTATION_METHOD_NAME.
*/
}
'''
+ def protected final CharSequence generateDeprecatedAnnotation(List<AnnotationType> annotations) {
+ var AnnotationType found = annotations.findDeprecatedAnnotation
+ if (found === null) {
+ return ""
+ }
+ return generateDeprecatedAnnotation(found)
+ }
+
def protected abstract CharSequence generateCopyKeys(List<GeneratedProperty> keyProps)
- def protected abstract CharSequence generateCopyAugmentation(Type implType);
+ def protected abstract CharSequence generateCopyAugmentation(Type implType)
+
+ def protected abstract CharSequence generateDeprecatedAnnotation(AnnotationType ann)
private def boolean implementsIfc(GeneratedType type, Type impl) {
for (Type ifc : type.implements) {
props.remove(toRemove);
}
}
+
+ private static def findDeprecatedAnnotation(List<AnnotationType> annotations) {
+ if (annotations !== null) {
+ for (annotation : annotations) {
+ if (DEPRECATED.equals(annotation.identifier)) {
+ return annotation
+ }
+ }
+ }
+ return null
+ }
}
import java.util.StringTokenizer
import java.util.regex.Pattern
import org.gaul.modernizer_maven_annotations.SuppressModernizer
+import org.opendaylight.mdsal.binding.model.api.AnnotationType
import org.opendaylight.mdsal.binding.model.api.ConcreteType
import org.opendaylight.mdsal.binding.model.api.Constant
import org.opendaylight.mdsal.binding.model.api.GeneratedProperty
result = prime * result + «property.importedUtilClass».hashCode(«property.fieldName»);
«ENDFOR»
'''
+
+ def protected final generateAnnotation(AnnotationType annotation) '''
+ @«annotation.importedName»
+ «IF annotation.parameters !== null && !annotation.parameters.empty»
+ (
+ «FOR param : annotation.parameters SEPARATOR ","»
+ «param.name»=«param.value»
+ «ENDFOR»
+ )
+ «ENDIF»
+ '''
}
import java.util.List
import java.util.Map
import java.util.Objects
+import org.opendaylight.mdsal.binding.model.api.AnnotationType
import org.opendaylight.mdsal.binding.model.api.GeneratedProperty
import org.opendaylight.mdsal.binding.model.api.GeneratedType
import org.opendaylight.mdsal.binding.model.api.Type
}
override body() '''
+ «targetType.annotations.generateDeprecatedAnnotation»
private static final class «type.name»
«val impIface = targetType.importedName»
«IF augmentType !== null»
}
'''
+ override generateDeprecatedAnnotation(AnnotationType ann) {
+ return generateAnnotation(ann)
+ }
+
/**
* Template method which generates the method <code>hashCode()</code>.
*
import java.util.Map
import java.util.Set
import java.util.regex.Pattern
+import org.opendaylight.mdsal.binding.model.api.AnnotationType
import org.opendaylight.mdsal.binding.model.api.GeneratedProperty
import org.opendaylight.mdsal.binding.model.api.GeneratedTransferObject
import org.opendaylight.mdsal.binding.model.api.GeneratedType
public static val BUILDER = "Builder";
static val AUGMENTATION_FIELD_UPPER = AUGMENTATION_FIELD.toFirstUpper
+ static val SUPPRESS_WARNINGS = JavaTypeName.create(SuppressWarnings)
/**
* Constructs new instance of this class.
*/
override body() '''
«wrapToDocumentation(formatDataForJavaDoc(targetType))»
+ «targetType.annotations.generateDeprecatedAnnotation»
public class «type.name» implements «Builder.importedName»<«targetType.importedName»> {
«generateFields(false)»
}
'''
+ override generateDeprecatedAnnotation(AnnotationType ann) {
+ val forRemoval = ann.getParameter("forRemoval")
+ if (forRemoval !== null) {
+ return "@" + DEPRECATED.importedName + "(forRemoval = " + forRemoval.value + ")"
+ }
+ return "@" + SUPPRESS_WARNINGS.importedName + "(\"deprecation\")"
+ }
+
/**
* Generate default constructor and constructor for every implemented interface from uses statements.
*/
'''
-
def private generateAnnotations(List<AnnotationType> annotations) '''
«IF annotations !== null && !annotations.empty»
«FOR annotation : annotations»
- @«annotation.importedName»
- «IF annotation.parameters !== null && !annotation.parameters.empty»
- (
- «FOR param : annotation.parameters SEPARATOR ","»
- «param.name»=«param.value»
- «ENDFOR»
- )
- «ENDIF»
+ «annotation.generateAnnotation»
«ENDFOR»
«ENDIF»
'''
container services {
+ status deprecated;
list service {
+ status obsolete;
key "permission";
leaf permission {