Merge "Extended binding-model-api to support of Enclosed Generated Types and TOs."
authorAlessandro Boch <aboch@cisco.com>
Thu, 20 Jun 2013 23:50:01 +0000 (23:50 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Thu, 20 Jun 2013 23:50:01 +0000 (23:50 +0000)
48 files changed:
opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/main/java/org/opendaylight/controller/sal/binding/generator/impl/BindingGeneratorImpl.java
opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/main/java/org/opendaylight/controller/sal/binding/yang/types/TypeProviderImpl.java
opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/java/org/opendaylight/controller/sal/binding/generator/impl/GenEnumResolvingTest.java
opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/java/org/opendaylight/controller/sal/binding/generator/impl/GeneratedTypesTest.java
opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/java/org/opendaylight/controller/sal/binding/generator/impl/GeneretedTypesBitsTest.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/resources/simple-bits-demo.yang [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/binding-generator-util/src/main/java/org/opendaylight/controller/binding/generator/util/AbstractBaseType.java
opendaylight/sal/yang-prototype/code-generator/binding-generator-util/src/main/java/org/opendaylight/controller/binding/generator/util/ReferencedTypeImpl.java
opendaylight/sal/yang-prototype/code-generator/binding-generator-util/src/main/java/org/opendaylight/controller/binding/generator/util/generated/type/builder/AbstractGeneratedType.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/binding-generator-util/src/main/java/org/opendaylight/controller/binding/generator/util/generated/type/builder/AbstractGeneratedTypeBuilder.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/binding-generator-util/src/main/java/org/opendaylight/controller/binding/generator/util/generated/type/builder/AbstractTypeMember.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/binding-generator-util/src/main/java/org/opendaylight/controller/binding/generator/util/generated/type/builder/AbstractTypeMemberBuilder.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/binding-generator-util/src/main/java/org/opendaylight/controller/binding/generator/util/generated/type/builder/AnnotationTypeBuilderImpl.java
opendaylight/sal/yang-prototype/code-generator/binding-generator-util/src/main/java/org/opendaylight/controller/binding/generator/util/generated/type/builder/ConstantBuilderImpl.java [deleted file]
opendaylight/sal/yang-prototype/code-generator/binding-generator-util/src/main/java/org/opendaylight/controller/binding/generator/util/generated/type/builder/ConstantImpl.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/binding-generator-util/src/main/java/org/opendaylight/controller/binding/generator/util/generated/type/builder/EnumerationBuilderImpl.java
opendaylight/sal/yang-prototype/code-generator/binding-generator-util/src/main/java/org/opendaylight/controller/binding/generator/util/generated/type/builder/GeneratedPropertyBuilderImpl.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/binding-generator-util/src/main/java/org/opendaylight/controller/binding/generator/util/generated/type/builder/GeneratedPropertyImpl.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/binding-generator-util/src/main/java/org/opendaylight/controller/binding/generator/util/generated/type/builder/GeneratedTOBuilderImpl.java
opendaylight/sal/yang-prototype/code-generator/binding-generator-util/src/main/java/org/opendaylight/controller/binding/generator/util/generated/type/builder/GeneratedTypeBuilderImpl.java
opendaylight/sal/yang-prototype/code-generator/binding-generator-util/src/main/java/org/opendaylight/controller/binding/generator/util/generated/type/builder/MethodSignatureBuilderImpl.java
opendaylight/sal/yang-prototype/code-generator/binding-generator-util/src/main/java/org/opendaylight/controller/binding/generator/util/generated/type/builder/MethodSignatureImpl.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/binding-generator-util/src/test/java/org/opendaylight/controller/binding/generator/util/generated/type/builder/AnnotationBuilderTest.java
opendaylight/sal/yang-prototype/code-generator/binding-java-api-generator/src/main/java/org/opendaylight/controller/sal/java/api/generator/ClassCodeGenerator.java
opendaylight/sal/yang-prototype/code-generator/binding-java-api-generator/src/main/java/org/opendaylight/controller/sal/java/api/generator/GeneratorUtil.java
opendaylight/sal/yang-prototype/code-generator/binding-java-api-generator/src/main/java/org/opendaylight/controller/sal/java/api/generator/InterfaceGenerator.java
opendaylight/sal/yang-prototype/code-generator/binding-java-api-generator/src/test/java/org/opendaylight/controller/sal/java/api/generator/test/ClassCodeGeneratorTest.java
opendaylight/sal/yang-prototype/code-generator/binding-model-api/src/main/java/org/opendaylight/controller/sal/binding/model/api/AccessModifier.java
opendaylight/sal/yang-prototype/code-generator/binding-model-api/src/main/java/org/opendaylight/controller/sal/binding/model/api/AnnotationType.java
opendaylight/sal/yang-prototype/code-generator/binding-model-api/src/main/java/org/opendaylight/controller/sal/binding/model/api/CodeGenerator.java
opendaylight/sal/yang-prototype/code-generator/binding-model-api/src/main/java/org/opendaylight/controller/sal/binding/model/api/ConcreteType.java
opendaylight/sal/yang-prototype/code-generator/binding-model-api/src/main/java/org/opendaylight/controller/sal/binding/model/api/Constant.java
opendaylight/sal/yang-prototype/code-generator/binding-model-api/src/main/java/org/opendaylight/controller/sal/binding/model/api/Enumeration.java
opendaylight/sal/yang-prototype/code-generator/binding-model-api/src/main/java/org/opendaylight/controller/sal/binding/model/api/GeneratedProperty.java
opendaylight/sal/yang-prototype/code-generator/binding-model-api/src/main/java/org/opendaylight/controller/sal/binding/model/api/GeneratedTransferObject.java
opendaylight/sal/yang-prototype/code-generator/binding-model-api/src/main/java/org/opendaylight/controller/sal/binding/model/api/GeneratedType.java
opendaylight/sal/yang-prototype/code-generator/binding-model-api/src/main/java/org/opendaylight/controller/sal/binding/model/api/MethodSignature.java
opendaylight/sal/yang-prototype/code-generator/binding-model-api/src/main/java/org/opendaylight/controller/sal/binding/model/api/ParameterizedType.java
opendaylight/sal/yang-prototype/code-generator/binding-model-api/src/main/java/org/opendaylight/controller/sal/binding/model/api/Type.java
opendaylight/sal/yang-prototype/code-generator/binding-model-api/src/main/java/org/opendaylight/controller/sal/binding/model/api/TypeMember.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/binding-model-api/src/main/java/org/opendaylight/controller/sal/binding/model/api/type/builder/AnnotationTypeBuilder.java
opendaylight/sal/yang-prototype/code-generator/binding-model-api/src/main/java/org/opendaylight/controller/sal/binding/model/api/type/builder/ConstantBuilder.java
opendaylight/sal/yang-prototype/code-generator/binding-model-api/src/main/java/org/opendaylight/controller/sal/binding/model/api/type/builder/EnumBuilder.java
opendaylight/sal/yang-prototype/code-generator/binding-model-api/src/main/java/org/opendaylight/controller/sal/binding/model/api/type/builder/GeneratedPropertyBuilder.java
opendaylight/sal/yang-prototype/code-generator/binding-model-api/src/main/java/org/opendaylight/controller/sal/binding/model/api/type/builder/GeneratedTOBuilder.java
opendaylight/sal/yang-prototype/code-generator/binding-model-api/src/main/java/org/opendaylight/controller/sal/binding/model/api/type/builder/GeneratedTypeBuilder.java
opendaylight/sal/yang-prototype/code-generator/binding-model-api/src/main/java/org/opendaylight/controller/sal/binding/model/api/type/builder/MethodSignatureBuilder.java
opendaylight/sal/yang-prototype/code-generator/binding-model-api/src/main/java/org/opendaylight/controller/sal/binding/model/api/type/builder/TypeMemberBuilder.java [new file with mode: 0644]

index b89dbb44ac786756b60d866c02459097bbe615b4..2235bfb2a32c7dd3fa75b887939af0e428b99827 100644 (file)
@@ -334,7 +334,7 @@ public final class BindingGeneratorImpl implements BindingGenerator {
 
                 final Type rpcRes = Types.parameterizedTypeFor(
                         Types.typeForClass(RpcResult.class), outTypeInstance);
-                method.addReturnType(Types.parameterizedTypeFor(future, rpcRes));
+                method.setReturnType(Types.parameterizedTypeFor(future, rpcRes));
                 for (DataNodeIterator it : rpcInOut) {
                     List<ContainerSchemaNode> nContainers = it.allContainers();
                     if ((nContainers != null) && !nContainers.isEmpty()) {
@@ -446,16 +446,16 @@ public final class BindingGeneratorImpl implements BindingGenerator {
 
             GeneratedTransferObject gto = new GeneratedTOBuilderImpl(
                     returnTypePkgName, returnTypeName).toInstance();
-            newType.addExtendsType(gto);
+            newType.setExtendsType(gto);
         } else {
-            newType.addExtendsType(Types.getBaseIdentityTO());
+            newType.setExtendsType(Types.getBaseIdentityTO());
         }
-
-        return newType.toIdentityInstance();
+        newType.setAbstract(true);
+        return newType.toInstance();
     }
 
     private List<Type> allGroupingsToGenTypes(Module module) {
-        final List<Type> genTypes = new ArrayList<Type>();
+        final List<Type> genTypes = new ArrayList<>();
         final String basePackageName = moduleNamespaceToPackageName(module);
         Set<GroupingDefinition> groupings = module.getGroupings();
         if (groupings != null && !groupings.isEmpty()) {
@@ -804,8 +804,8 @@ public final class BindingGeneratorImpl implements BindingGenerator {
                             .addProperty(parseToClassName(leafName));
 
                     propBuilder.setReadOnly(isReadOnly);
-                    propBuilder.addReturnType(returnType);
-                    propBuilder.addComment(leafDesc);
+                    propBuilder.setReturnType(returnType);
+                    propBuilder.setComment(leafDesc);
 
                     toBuilder.addEqualsIdentity(propBuilder);
                     toBuilder.addHashIdentity(propBuilder);
@@ -946,8 +946,8 @@ public final class BindingGeneratorImpl implements BindingGenerator {
         final MethodSignatureBuilder getMethod = interfaceBuilder
                 .addMethod(getterMethodName(schemaNodeName));
 
-        getMethod.addComment(comment);
-        getMethod.addReturnType(returnType);
+        getMethod.setComment(comment);
+        getMethod.setReturnType(returnType);
 
         return getMethod;
     }
@@ -959,10 +959,10 @@ public final class BindingGeneratorImpl implements BindingGenerator {
         final MethodSignatureBuilder setMethod = interfaceBuilder
                 .addMethod(setterMethodName(schemaNodeName));
 
-        setMethod.addComment(comment);
+        setMethod.setComment(comment);
         setMethod.addParameter(parameterType,
                 parseToValidParamName(schemaNodeName));
-        setMethod.addReturnType(Types.voidType());
+        setMethod.setReturnType(Types.voidType());
 
         return setMethod;
     }
index 96069c273c071b96d3594b484055f0c32913a6f1..9410ffe1de5dc9825325bfc97b076aa32f079a94 100644 (file)
@@ -21,11 +21,9 @@ import org.opendaylight.controller.sal.binding.model.api.type.builder.GeneratedT
 import org.opendaylight.controller.sal.binding.model.api.type.builder.GeneratedTypeBuilder;
 import org.opendaylight.controller.yang.common.QName;
 import org.opendaylight.controller.yang.model.api.*;
-import org.opendaylight.controller.yang.model.api.type.EnumTypeDefinition;
+import org.opendaylight.controller.yang.model.api.type.*;
+import org.opendaylight.controller.yang.model.api.type.BitsTypeDefinition.Bit;
 import org.opendaylight.controller.yang.model.api.type.EnumTypeDefinition.EnumPair;
-import org.opendaylight.controller.yang.model.api.type.IdentityrefTypeDefinition;
-import org.opendaylight.controller.yang.model.api.type.LeafrefTypeDefinition;
-import org.opendaylight.controller.yang.model.api.type.UnionTypeDefinition;
 import org.opendaylight.controller.yang.model.util.ExtendedType;
 
 import java.util.HashMap;
@@ -56,13 +54,13 @@ public final class TypeProviderImpl implements TypeProvider {
     public void putReferencedType(final SchemaPath refTypePath,
                                   final Type refType) {
         if (refTypePath == null) {
-            throw new IllegalArgumentException("Path reference of " +
-                    "Enumeration Type Definition cannot be NULL!");
+            throw new IllegalArgumentException("Path reference of "
+                    "Enumeration Type Definition cannot be NULL!");
         }
 
         if (refType == null) {
-            throw new IllegalArgumentException("Reference to Enumeration " +
-                    "Type cannot be NULL!");
+            throw new IllegalArgumentException("Reference to Enumeration "
+                    "Type cannot be NULL!");
         }
         referencedTypes.put(refTypePath, refType);
     }
@@ -85,16 +83,13 @@ public final class TypeProviderImpl implements TypeProvider {
             final TypeDefinition<?> typeDefinition) {
         Type returnType = null;
         if (typeDefinition == null) {
-            throw new IllegalArgumentException("Type Definition cannot be " +
-                    "NULL!");
+            throw new IllegalArgumentException("Type Definition cannot be NULL!");
         }
         if (typeDefinition.getQName() == null) {
-            throw new IllegalArgumentException("Type Definition cannot have " +
-                    "non specified QName (QName cannot be NULL!)");
+            throw new IllegalArgumentException("Type Definition cannot have non specified QName (QName cannot be NULL!)");
         }
         if (typeDefinition.getQName().getLocalName() == null) {
-            throw new IllegalArgumentException("Type Definitions Local Name " +
-                    "cannot be NULL!");
+            throw new IllegalArgumentException("Type Definitions Local Name cannot be NULL!");
         }
         final String typedefName = typeDefinition.getQName().getLocalName();
         if (typeDefinition instanceof ExtendedType) {
@@ -104,15 +99,15 @@ public final class TypeProviderImpl implements TypeProvider {
                 final LeafrefTypeDefinition leafref = (LeafrefTypeDefinition) baseTypeDef;
                 returnType = provideTypeForLeafref(leafref);
             } else if (baseTypeDef instanceof IdentityrefTypeDefinition) {
-                final IdentityrefTypeDefinition idref = (IdentityrefTypeDefinition)typeDefinition;
+                final IdentityrefTypeDefinition idref = (IdentityrefTypeDefinition) baseTypeDef;
                 returnType = returnTypeForIdentityref(idref);
             } else if (baseTypeDef instanceof EnumTypeDefinition) {
                 final EnumTypeDefinition enumTypeDef = (EnumTypeDefinition) baseTypeDef;
                 returnType = resolveEnumFromTypeDefinition(enumTypeDef,
                         typedefName);
             } else {
-                final Module module = findParentModuleForTypeDefinition(schemaContext,
-                        typeDefinition);
+                final Module module = findParentModuleForTypeDefinition(
+                        schemaContext, typeDefinition);
                 if (module != null) {
                     final Map<String, Type> genTOs = genTypeDefsContextMap
                             .get(module.getName());
@@ -130,32 +125,32 @@ public final class TypeProviderImpl implements TypeProvider {
                 final LeafrefTypeDefinition leafref = (LeafrefTypeDefinition) typeDefinition;
                 returnType = provideTypeForLeafref(leafref);
             } else if (typeDefinition instanceof IdentityrefTypeDefinition) {
-                final IdentityrefTypeDefinition idref = (IdentityrefTypeDefinition)typeDefinition;
+                final IdentityrefTypeDefinition idref = (IdentityrefTypeDefinition) typeDefinition;
                 returnType = returnTypeForIdentityref(idref);
             } else {
                 returnType = BaseYangTypes.BASE_YANG_TYPES_PROVIDER
                         .javaTypeForSchemaDefinitionType(typeDefinition);
             }
         }
-        //TODO: add throw exception when we will be able to resolve ALL yang
+        // TODO: add throw exception when we will be able to resolve ALL yang
         // types!
-//        if (returnType == null) {
-//            throw new IllegalArgumentException("Type Provider can't resolve " +
-//                    "type for specified Type Definition " + typedefName);
-//        }
+        // if (returnType == null) {
+        // throw new IllegalArgumentException("Type Provider can't resolve " +
+        // "type for specified Type Definition " + typedefName);
+        // }
         return returnType;
     }
-    
+
     private Type returnTypeForIdentityref(IdentityrefTypeDefinition idref) {
         QName baseIdQName = idref.getIdentity();
         Module module = schemaContext.findModuleByNamespace(baseIdQName.getNamespace());
         IdentitySchemaNode identity = null;
-        for(IdentitySchemaNode id : module.getIdentities()) {
-            if(id.getQName().equals(baseIdQName)) {
+        for (IdentitySchemaNode id : module.getIdentities()) {
+            if (id.getQName().equals(baseIdQName)) {
                 identity = id;
             }
         }
-        if(identity == null) {
+        if (identity == null) {
             throw new IllegalArgumentException("Target identity '" + baseIdQName + "' do not exists");
         }
 
@@ -173,16 +168,13 @@ public final class TypeProviderImpl implements TypeProvider {
             final TypeDefinition<?> typeDefinition) {
         Type returnType = null;
         if (typeDefinition == null) {
-            throw new IllegalArgumentException("Type Definition cannot be " +
-                    "NULL!");
+            throw new IllegalArgumentException("Type Definition cannot be NULL!");
         }
         if (typeDefinition.getQName() == null) {
-            throw new IllegalArgumentException("Type Definition cannot have " +
-                    "non specified QName (QName cannot be NULL!)");
+            throw new IllegalArgumentException("Type Definition cannot have non specified QName (QName cannot be NULL!)");
         }
         if (typeDefinition.getQName() == null) {
-            throw new IllegalArgumentException("Type Definitions Local Name " +
-                    "cannot be NULL!");
+            throw new IllegalArgumentException("Type Definitions Local Name cannot be NULL!");
         }
 
         final String typedefName = typeDefinition.getQName().getLocalName();
@@ -191,8 +183,8 @@ public final class TypeProviderImpl implements TypeProvider {
 
             if (!(baseTypeDef instanceof LeafrefTypeDefinition)
                     && !(baseTypeDef instanceof IdentityrefTypeDefinition)) {
-                final Module module = findParentModuleForTypeDefinition(schemaContext,
-                        typeDefinition);
+                final Module module = findParentModuleForTypeDefinition(
+                        schemaContext, typeDefinition);
 
                 if (module != null) {
                     final Map<String, Type> genTOs = genTypeDefsContextMap
@@ -209,8 +201,7 @@ public final class TypeProviderImpl implements TypeProvider {
     private TypeDefinition<?> baseTypeDefForExtendedType(
             final TypeDefinition<?> extendTypeDef) {
         if (extendTypeDef == null) {
-            throw new IllegalArgumentException("Type Definiition reference " +
-                    "cannot be NULL!");
+            throw new IllegalArgumentException("Type Definiition reference cannot be NULL!");
         }
         final TypeDefinition<?> baseTypeDef = extendTypeDef.getBaseType();
         if (baseTypeDef instanceof ExtendedType) {
@@ -224,13 +215,11 @@ public final class TypeProviderImpl implements TypeProvider {
     public Type provideTypeForLeafref(final LeafrefTypeDefinition leafrefType) {
         Type returnType = null;
         if (leafrefType == null) {
-            throw new IllegalArgumentException("Leafref Type Definition " +
-                    "reference cannot be NULL!");
+            throw new IllegalArgumentException("Leafref Type Definition reference cannot be NULL!");
         }
 
         if (leafrefType.getPathStatement() == null) {
-            throw new IllegalArgumentException("The Path Statement for " +
-                    "Leafref Type Definition cannot be NULL!");
+            throw new IllegalArgumentException("The Path Statement for Leafref Type Definition cannot be NULL!");
         }
 
         final RevisionAwareXPath xpath = leafrefType.getPathStatement();
@@ -240,22 +229,23 @@ public final class TypeProviderImpl implements TypeProvider {
             if (strXPath.matches(".*//[.* | .*//].*")) {
                 returnType = Types.typeForClass(Object.class);
             } else {
-                final Module module = findParentModuleForTypeDefinition(schemaContext, leafrefType);
+                final Module module = findParentModuleForTypeDefinition(
+                        schemaContext, leafrefType);
                 if (module != null) {
                     final DataSchemaNode dataNode;
                     if (xpath.isAbsolute()) {
                         dataNode = findDataSchemaNode(schemaContext, module,
                                 xpath);
                     } else {
-                        dataNode = findDataSchemaNodeForRelativeXPath(schemaContext,
-                                module, leafrefType, xpath);
+                        dataNode = findDataSchemaNodeForRelativeXPath(
+                                schemaContext, module, leafrefType, xpath);
                     }
 
                     if (leafContainsEnumDefinition(dataNode)) {
                         returnType = referencedTypes.get(dataNode.getPath());
                     } else if (leafListContainsEnumDefinition(dataNode)) {
-                        returnType = Types.listTypeFor(referencedTypes.get(
-                                dataNode.getPath()));
+                        returnType = Types.listTypeFor(referencedTypes
+                                .get(dataNode.getPath()));
                     } else {
                         returnType = resolveTypeFromDataSchemaNode(dataNode);
                     }
@@ -275,8 +265,7 @@ public final class TypeProviderImpl implements TypeProvider {
         return false;
     }
 
-    private boolean leafListContainsEnumDefinition(
-            final DataSchemaNode dataNode) {
+    private boolean leafListContainsEnumDefinition(final DataSchemaNode dataNode) {
         if (dataNode instanceof LeafListSchemaNode) {
             final LeafListSchemaNode leafList = (LeafListSchemaNode) dataNode;
             if (leafList.getType() instanceof EnumTypeDefinition) {
@@ -289,25 +278,22 @@ public final class TypeProviderImpl implements TypeProvider {
     private Enumeration resolveEnumFromTypeDefinition(
             final EnumTypeDefinition enumTypeDef, final String enumName) {
         if (enumTypeDef == null) {
-            throw new IllegalArgumentException("EnumTypeDefinition reference " +
-                    "cannot be NULL!");
+            throw new IllegalArgumentException("EnumTypeDefinition reference cannot be NULL!");
         }
         if (enumTypeDef.getValues() == null) {
-            throw new IllegalArgumentException("EnumTypeDefinition MUST " +
-                    "contain at least ONE value definition!");
+            throw new IllegalArgumentException("EnumTypeDefinition MUST contain at least ONE value definition!");
         }
         if (enumTypeDef.getQName() == null) {
-            throw new IllegalArgumentException("EnumTypeDefinition MUST " +
-                    "contain NON-NULL QName!");
+            throw new IllegalArgumentException("EnumTypeDefinition MUST contain NON-NULL QName!");
         }
         if (enumTypeDef.getQName().getLocalName() == null) {
-            throw new IllegalArgumentException("Local Name in " +
-                    "EnumTypeDefinition QName cannot be NULL!");
+            throw new IllegalArgumentException("Local Name in EnumTypeDefinition QName cannot be NULL!");
         }
 
         final String enumerationName = parseToClassName(enumName);
 
-        Module module = findParentModuleForTypeDefinition(schemaContext, enumTypeDef);
+        Module module = findParentModuleForTypeDefinition(schemaContext,
+                enumTypeDef);
         final String basePackageName = moduleNamespaceToPackageName(module);
 
         final EnumBuilder enumBuilder = new EnumerationBuilderImpl(
@@ -320,24 +306,19 @@ public final class TypeProviderImpl implements TypeProvider {
             final EnumTypeDefinition enumTypeDef, final String enumName,
             final GeneratedTypeBuilder typeBuilder) {
         if (enumTypeDef == null) {
-            throw new IllegalArgumentException("EnumTypeDefinition reference " +
-                    "cannot be NULL!");
+            throw new IllegalArgumentException("EnumTypeDefinition reference cannot be NULL!");
         }
         if (enumTypeDef.getValues() == null) {
-            throw new IllegalArgumentException("EnumTypeDefinition MUST " +
-                    "contain at least ONE value definition!");
+            throw new IllegalArgumentException("EnumTypeDefinition MUST contain at least ONE value definition!");
         }
         if (enumTypeDef.getQName() == null) {
-            throw new IllegalArgumentException("EnumTypeDefinition MUST " +
-                    "contain NON-NULL QName!");
+            throw new IllegalArgumentException("EnumTypeDefinition MUST contain NON-NULL QName!");
         }
         if (enumTypeDef.getQName().getLocalName() == null) {
-            throw new IllegalArgumentException("Local Name in " +
-                    "EnumTypeDefinition QName cannot be NULL!");
+            throw new IllegalArgumentException("Local Name in EnumTypeDefinition QName cannot be NULL!");
         }
         if (typeBuilder == null) {
-            throw new IllegalArgumentException("Generated Type Builder " +
-                    "reference cannot be NULL!");
+            throw new IllegalArgumentException("Generated Type Builder reference cannot be NULL!");
         }
 
         final String enumerationName = parseToClassName(enumName);
@@ -350,8 +331,7 @@ public final class TypeProviderImpl implements TypeProvider {
     }
 
     private void updateEnumPairsFromEnumTypeDef(
-            final EnumTypeDefinition enumTypeDef,
-            final EnumBuilder enumBuilder) {
+            final EnumTypeDefinition enumTypeDef, final EnumBuilder enumBuilder) {
         if (enumBuilder != null) {
             final List<EnumPair> enums = enumTypeDef.getValues();
             if (enums != null) {
@@ -390,8 +370,7 @@ public final class TypeProviderImpl implements TypeProvider {
     private void resolveTypeDefsFromContext() {
         final Set<Module> modules = schemaContext.getModules();
         if (modules == null) {
-            throw new IllegalArgumentException("Sef of Modules cannot be " +
-                    "NULL!");
+            throw new IllegalArgumentException("Sef of Modules cannot be NULL!");
         }
         for (final Module module : modules) {
             if (module == null) {
@@ -413,7 +392,8 @@ public final class TypeProviderImpl implements TypeProvider {
                 final List<ExtendedType> extUnions = UnionDependencySort
                         .sort(typeDefinitions);
                 for (final ExtendedType extUnionType : extUnions) {
-                    addUnionGeneratedTypeDefinition(basePackageName, extUnionType);
+                    addUnionGeneratedTypeDefinition(basePackageName,
+                            extUnionType);
                 }
             }
         }
@@ -424,7 +404,6 @@ public final class TypeProviderImpl implements TypeProvider {
         if ((basePackageName != null) && (moduleName != null)
                 && (typedef != null) && (typedef.getQName() != null)) {
 
-
             final String typedefName = typedef.getQName().getLocalName();
             final TypeDefinition<?> baseTypeDefinition = baseTypeDefForExtendedType(typedef);
             if (!(baseTypeDefinition instanceof LeafrefTypeDefinition)
@@ -435,6 +414,11 @@ public final class TypeProviderImpl implements TypeProvider {
                     returnType = resolveEnumFromTypeDefinition(enumTypeDef,
                             typedefName);
 
+                } else if (baseTypeDefinition instanceof BitsTypeDefinition) {
+                    final BitsTypeDefinition bitsTypeDefinition = (BitsTypeDefinition) baseTypeDefinition;
+                    returnType = bitsTypedefToTransferObject(bitsTypeDefinition,
+                            basePackageName, typedefName);
+
                 } else {
                     final Type javaType = BaseYangTypes.BASE_YANG_TYPES_PROVIDER
                             .javaTypeForSchemaDefinitionType(baseTypeDefinition);
@@ -443,8 +427,8 @@ public final class TypeProviderImpl implements TypeProvider {
                             javaType);
                 }
                 if (returnType != null) {
-                    final Map<String, Type> typeMap = genTypeDefsContextMap.get
-                            (moduleName);
+                    final Map<String, Type> typeMap = genTypeDefsContextMap
+                            .get(moduleName);
                     if (typeMap != null) {
                         typeMap.put(typedefName, returnType);
                     }
@@ -468,7 +452,7 @@ public final class TypeProviderImpl implements TypeProvider {
             final GeneratedPropertyBuilder genPropBuilder = genTOBuilder
                     .addProperty(propertyName);
 
-            genPropBuilder.addReturnType(javaType);
+            genPropBuilder.setReturnType(javaType);
             genTOBuilder.addEqualsIdentity(genPropBuilder);
             genTOBuilder.addHashIdentity(genPropBuilder);
             genTOBuilder.addToStringProperty(genPropBuilder);
@@ -480,26 +464,22 @@ public final class TypeProviderImpl implements TypeProvider {
     private void addUnionGeneratedTypeDefinition(final String basePackageName,
                                                  final TypeDefinition<?> typedef) {
         if (basePackageName == null) {
-            throw new IllegalArgumentException("Base Package Name cannot be " +
-                    "NULL!");
+            throw new IllegalArgumentException("Base Package Name cannot be NULL!");
         }
         if (typedef == null) {
-            throw new IllegalArgumentException("Type Definition cannot be " +
-                    "NULL!");
+            throw new IllegalArgumentException("Type Definition cannot be NULL!");
         }
         if (typedef.getQName() == null) {
-            throw new IllegalArgumentException("Type Definition cannot have " +
-                    "non specified QName (QName cannot be NULL!)");
+            throw new IllegalArgumentException("Type Definition cannot have non specified QName (QName cannot be NULL!)");
         }
 
         final TypeDefinition<?> baseTypeDefinition = typedef.getBaseType();
         if ((baseTypeDefinition != null)
                 && (baseTypeDefinition instanceof UnionTypeDefinition)) {
             final UnionTypeDefinition unionTypeDef = (UnionTypeDefinition) baseTypeDefinition;
-            final List<TypeDefinition<?>> unionTypes = unionTypeDef
-                    .getTypes();
-            final Module parentModule = findParentModuleForTypeDefinition(schemaContext,
-                    typedef);
+            final List<TypeDefinition<?>> unionTypes = unionTypeDef.getTypes();
+            final Module parentModule = findParentModuleForTypeDefinition(
+                    schemaContext, typedef);
 
             Map<String, Type> genTOsMap = null;
             if (parentModule != null && parentModule.getName() != null) {
@@ -510,17 +490,17 @@ public final class TypeProviderImpl implements TypeProvider {
                     basePackageName, typedef);
             if ((unionTypes != null) && (unionGenTransObject != null)) {
                 for (final TypeDefinition<?> unionType : unionTypes) {
-                    final String typeName = unionType.getQName()
-                            .getLocalName();
+                    final String typeName = unionType.getQName().getLocalName();
                     if (unionType instanceof ExtendedType) {
-                        final Module unionTypeModule = findParentModuleForTypeDefinition(schemaContext,
-                                unionType);
-                        if (unionTypeModule != null && unionTypeModule.getName() != null) {
+                        final Module unionTypeModule = findParentModuleForTypeDefinition(
+                                schemaContext, unionType);
+                        if (unionTypeModule != null
+                                && unionTypeModule.getName() != null) {
                             final Map<String, Type> innerGenTOs = genTypeDefsContextMap
                                     .get(unionTypeModule.getName());
 
-                            final GeneratedTransferObject genTransferObject =
-                                    (GeneratedTransferObject) innerGenTOs.get(typeName);
+                            final GeneratedTransferObject genTransferObject = (GeneratedTransferObject) innerGenTOs
+                                    .get(typeName);
                             if (genTransferObject != null) {
                                 updateUnionTypeAsProperty(unionGenTransObject,
                                         genTransferObject,
@@ -528,8 +508,7 @@ public final class TypeProviderImpl implements TypeProvider {
                             }
                         }
                     } else if (unionType instanceof EnumTypeDefinition) {
-                        final EnumBuilder
-                                enumBuilder = resolveInnerEnumFromTypeDefinition(
+                        final EnumBuilder enumBuilder = resolveInnerEnumFromTypeDefinition(
                                 (EnumTypeDefinition) unionType, typeName,
                                 unionGenTransObject);
                         final Type enumRefType = new ReferencedTypeImpl(
@@ -556,10 +535,9 @@ public final class TypeProviderImpl implements TypeProvider {
             final GeneratedTOBuilder unionGenTransObject, final Type type,
             final String propertyName) {
         if (unionGenTransObject != null && type != null) {
-            final GeneratedPropertyBuilder propBuilder =
-                    unionGenTransObject.addProperty(parseToValidParamName(
-                            propertyName));
-            propBuilder.addReturnType(type);
+            final GeneratedPropertyBuilder propBuilder = unionGenTransObject
+                    .addProperty(parseToValidParamName(propertyName));
+            propBuilder.setReturnType(type);
             propBuilder.setReadOnly(false);
 
             if (!(type instanceof Enumeration)) {
@@ -587,4 +565,35 @@ public final class TypeProviderImpl implements TypeProvider {
         }
         return null;
     }
+
+    private GeneratedTransferObject bitsTypedefToTransferObject(
+            final BitsTypeDefinition bitsTypeDefinition, final String basePackageName, final String typedefName) {
+
+        if (bitsTypeDefinition == null) {
+            throw new IllegalArgumentException("Bits TypeDefinition cannot be NULL!");
+        }
+        if (basePackageName == null) {
+            throw new IllegalArgumentException("Base Package Name cannot be NULL!");
+        }
+        if (typedefName == null) {
+            throw new IllegalArgumentException("Type Definition Local Name cannot be NULL!");
+        }
+
+        final String typeDefName = parseToClassName(typedefName);
+        final GeneratedTOBuilder genTOBuilder = new GeneratedTOBuilderImpl(basePackageName, typeDefName);
+
+        final List<Bit> bitList = bitsTypeDefinition.getBits();
+        GeneratedPropertyBuilder genPropertyBuilder;
+        for (final Bit bit : bitList) {
+            String name = bit.getName();
+            genPropertyBuilder = genTOBuilder.addProperty(parseToValidParamName(name));
+            genPropertyBuilder.setReadOnly(false);
+            genPropertyBuilder.setReturnType(BaseYangTypes.BOOLEAN_TYPE);
+
+            genTOBuilder.addEqualsIdentity(genPropertyBuilder);
+            genTOBuilder.addHashIdentity(genPropertyBuilder);
+            genTOBuilder.addToStringProperty(genPropertyBuilder);
+        }
+        return genTOBuilder.toInstance();
+    }
 }
index a95eb072ba4f2bc35329fe5dd121727ccb3f7bcc..10ea9fae1f7ebb7a62ce9e8b1e13b4f54159ed22 100644 (file)
@@ -76,7 +76,7 @@ public class GenEnumResolvingTest {
 
         Enumeration linkUpDownTrapEnable = null;
         Enumeration operStatus = null;
-        final List<Enumeration> enums = genInterface.getEnumDefintions();
+        final List<Enumeration> enums = genInterface.getEnumerations();
         assertNotNull("Generated Type Interface cannot contain NULL reference" +
                 " to Enumeration types!", enums);
         assertEquals("Generated Type Interface MUST contain 2 Enumeration " +
index b226252eaea7a635cace166cb3721f307725058a..cfa74a005f31f12ca157fb0b736f9a0983ca8001 100644 (file)
@@ -16,7 +16,6 @@ import java.util.Set;
 
 import org.junit.Test;
 import org.opendaylight.controller.sal.binding.generator.api.BindingGenerator;
-import org.opendaylight.controller.sal.binding.model.api.Enumeration;
 import org.opendaylight.controller.sal.binding.model.api.GeneratedProperty;
 import org.opendaylight.controller.sal.binding.model.api.GeneratedTransferObject;
 import org.opendaylight.controller.sal.binding.model.api.GeneratedType;
diff --git a/opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/java/org/opendaylight/controller/sal/binding/generator/impl/GeneretedTypesBitsTest.java b/opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/java/org/opendaylight/controller/sal/binding/generator/impl/GeneretedTypesBitsTest.java
new file mode 100644 (file)
index 0000000..646efd1
--- /dev/null
@@ -0,0 +1,159 @@
+package org.opendaylight.controller.sal.binding.generator.impl;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import org.junit.Test;
+import org.opendaylight.controller.sal.binding.generator.api.BindingGenerator;
+import org.opendaylight.controller.sal.binding.model.api.GeneratedProperty;
+import org.opendaylight.controller.sal.binding.model.api.GeneratedTransferObject;
+import org.opendaylight.controller.sal.binding.model.api.GeneratedType;
+import org.opendaylight.controller.sal.binding.model.api.MethodSignature;
+import org.opendaylight.controller.sal.binding.model.api.MethodSignature.Parameter;
+import org.opendaylight.controller.sal.binding.model.api.Type;
+import org.opendaylight.controller.yang.model.api.Module;
+import org.opendaylight.controller.yang.model.api.SchemaContext;
+import org.opendaylight.controller.yang.model.parser.api.YangModelParser;
+import org.opendaylight.controller.yang.parser.impl.YangParserImpl;
+
+public class GeneretedTypesBitsTest {
+
+    private SchemaContext resolveSchemaContextFromFiles(
+            final String... yangFiles) {
+        final YangModelParser parser = new YangParserImpl();
+
+        final List<File> inputFiles = new ArrayList<File>();
+        for (int i = 0; i < yangFiles.length; ++i) {
+            inputFiles.add(new File(yangFiles[i]));
+        }
+
+        final Set<Module> modules = parser.parseYangModels(inputFiles);
+        return parser.resolveSchemaContext(modules);
+    }
+
+    @Test
+    public void testGeneretedTypesBitsTest() {
+        final String yangTypesPath = getClass().getResource(
+                "/simple-bits-demo.yang").getPath();
+
+        final SchemaContext context = resolveSchemaContextFromFiles(yangTypesPath);
+        assertTrue(context != null);
+
+        final BindingGenerator bindingGen = new BindingGeneratorImpl();
+        final List<Type> genTypes = bindingGen.generateTypes(context);
+        assertTrue(genTypes != null);
+
+        List<MethodSignature> methodSignaturesList = null;
+
+        boolean leafParentFound = false;
+
+        boolean byteTypeFound = false;
+        int classPropertiesNumb = 0;
+        int toStringPropertiesNum = 0;
+        int equalPropertiesNum = 0;
+        int hashPropertiesNum = 0;
+
+        String nameReturnParamType = "";
+        String nameMethodeParamType = "";
+        boolean getByteLeafMethodFound = false;
+        boolean setByteLeafMethodFound = false;
+        int setByteLeafMethodParamNum = 0;
+
+        for (final Type type : genTypes) {
+            if (type instanceof GeneratedTransferObject) { // searching for
+                                                            // ByteType
+                final GeneratedTransferObject genTO = (GeneratedTransferObject) type;
+                if (genTO.getName().equals("ByteType")) {
+                    byteTypeFound = true;
+                    List<GeneratedProperty> genProperties = genTO
+                            .getProperties();
+                    classPropertiesNumb = genProperties.size();
+
+                    genProperties = null;
+                    genProperties = genTO.getToStringIdentifiers();
+                    toStringPropertiesNum = genProperties.size();
+
+                    genProperties = null;
+                    genProperties = genTO.getEqualsIdentifiers();
+                    equalPropertiesNum = genProperties.size();
+
+                    genProperties = null;
+                    genProperties = genTO.getHashCodeIdentifiers();
+                    hashPropertiesNum = genProperties.size();
+
+                }
+            } else if (type instanceof GeneratedType) { // searching for
+                                                        // interface
+                                                        // LeafParameterContainer
+                final GeneratedType genType = (GeneratedType) type;
+                if (genType.getName().compareTo("LeafParentContainer") == 0) {
+                    leafParentFound = true;
+                    // check of methods
+                    methodSignaturesList = genType.getMethodDefinitions();
+                    if (methodSignaturesList != null) {
+                        for (MethodSignature methodSignature : methodSignaturesList) { // loop
+                                                                                        // through
+                                                                                        // all
+                                                                                        // methods
+                            if (methodSignature.getName().compareTo(
+                                    "getByteLeaf") == 0) {
+                                getByteLeafMethodFound = true;
+
+                                nameReturnParamType = methodSignature
+                                        .getReturnType().getName();
+                            } else if (methodSignature.getName().compareTo(
+                                    "setByteLeaf") == 0) {
+                                setByteLeafMethodFound = true;
+
+                                List<Parameter> parameters = methodSignature
+                                        .getParameters();
+                                setByteLeafMethodParamNum = parameters.size();
+                                for (Parameter parameter : parameters) {
+                                    nameMethodeParamType = parameter.getType()
+                                            .getName();
+                                }
+
+                            }
+
+                        }
+                    }
+                }
+            }
+
+        }
+
+        assertTrue("type >ByteType< wasn't in YANG file", byteTypeFound == true);
+
+        assertTrue("Incorrect number of bit properties in class",
+                classPropertiesNumb == 8);
+
+        assertTrue("Incorrect number of properties in toString method",
+                toStringPropertiesNum == 8);
+        assertTrue("Incorrect number of properties in equals method",
+                equalPropertiesNum == 8);
+        assertTrue("Incorrect number of properties in hash method",
+                hashPropertiesNum == 8);
+        assertTrue("LeafParameterContainer container wasn't found",
+                leafParentFound == true);
+
+        assertTrue("No methods were generated", methodSignaturesList != null);
+
+        assertTrue("Method getByteLeaf wasn't generated.",
+                getByteLeafMethodFound == true);
+        assertTrue("Wrong returning parameter type of method getByteLeaf",
+                nameReturnParamType.compareTo("ByteType") == 0);
+
+        assertTrue("Method setByteLeaf wasn't generated.",
+                setByteLeafMethodFound == true);
+        assertTrue("Incorrect number of input parameters for setByteLeaf",
+                setByteLeafMethodParamNum == 1);
+        assertTrue("Wrong input parameter type",
+                nameMethodeParamType.compareTo("ByteType") == 0);
+
+    }
+
+}
\ No newline at end of file
diff --git a/opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/resources/simple-bits-demo.yang b/opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/resources/simple-bits-demo.yang
new file mode 100644 (file)
index 0000000..d7e69d1
--- /dev/null
@@ -0,0 +1,54 @@
+module simple-bits-demo {
+    
+    namespace "urn:simple:bits:demo";
+    prefix "sbd";
+
+    organization "OPEN DAYLIGHT";
+    contact "http://www.opendaylight.org/";    
+
+    revision 2013-06-11 {
+        
+    }
+
+    typedef byte-type {
+        type bits {
+            bit first-bit {
+                position 10;
+            }
+            bit second-bit {
+                position 20;
+            }
+            bit third-bit {
+                position 30;
+            }
+            bit forth-bit {
+                position 40;
+            }       
+            bit fifth-bit {
+                position 50;
+            }       
+            bit sixth-bit {
+                position 60;
+            }       
+            bit seventh-bit {
+                position 70;
+            }       
+            bit eight-bit {
+                position 80;
+            }       
+            
+    }
+
+    typedef jo {
+        type uint32;
+    }
+
+    
+    container leaf-parent-container {
+        leaf byte-leaf {
+            type byte-type;
+        }
+        
+    }
+
+}
\ No newline at end of file
index a9d1cf5227c4efb575debadfb52eb288f64032b7..a67e4163e9a15694c70584ba6aafd0ba4b319fb2 100644 (file)
@@ -24,6 +24,15 @@ public class AbstractBaseType implements Type {
         return name;\r
     }\r
 \r
+    @Override\r
+    public String getFullyQualifiedName() {\r
+        if (packageName.isEmpty()) {\r
+            return name;\r
+        } else {\r
+            return packageName + "." + name;\r
+        }\r
+    }\r
+\r
     protected AbstractBaseType(String pkName, String name) {\r
         this.packageName = pkName;\r
         this.name = name;\r
@@ -68,5 +77,4 @@ public class AbstractBaseType implements Type {
         }\r
         return "Type (" + packageName + "." + name + ")";\r
     }\r
-\r
 }\r
index 8f265c4ec39a2e7404a957da9e444e4d4dfd5ef5..bffa013f8402038d0ecc67e355b35b862205fc28 100644 (file)
@@ -7,82 +7,19 @@
  */
 package org.opendaylight.controller.binding.generator.util;
 
-import org.opendaylight.controller.sal.binding.model.api.Type;
+public final class ReferencedTypeImpl extends AbstractBaseType {
 
-
-public final class ReferencedTypeImpl implements Type {
-    
-    private final String packageName;
-    private final String name;
-    
     public ReferencedTypeImpl(String packageName, String name) {
-        super();
-        this.packageName = packageName;
-        this.name = name;
-    }
-
-    /* (non-Javadoc)
-     * @see org.opendaylight.controller.sal.binding.model.api.Type#getPackageName()
-     */
-    @Override
-    public String getPackageName() {
-        return packageName;
-    }
-
-    /* (non-Javadoc)
-     * @see org.opendaylight.controller.sal.binding.model.api.Type#getName()
-     */
-    @Override
-    public String getName() {
-        return name;
-    }
-
-    @Override
-    public int hashCode() {
-        final int prime = 31;
-        int result = 1;
-        result = prime * result + ((name == null) ? 0 : name.hashCode());
-        result = prime * result
-                + ((packageName == null) ? 0 : packageName.hashCode());
-        return result;
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        if (this == obj) {
-            return true;
-        }
-        if (obj == null) {
-            return false;
-        }
-        if (getClass() != obj.getClass()) {
-            return false;
-        }
-        ReferencedTypeImpl other = (ReferencedTypeImpl) obj;
-        if (name == null) {
-            if (other.name != null) {
-                return false;
-            }
-        } else if (!name.equals(other.name)) {
-            return false;
-        }
-        if (packageName == null) {
-            if (other.packageName != null) {
-                return false;
-            }
-        } else if (!packageName.equals(other.packageName)) {
-            return false;
-        }
-        return true;
+        super(packageName, name);
     }
 
     @Override
     public String toString() {
         StringBuilder builder = new StringBuilder();
         builder.append("ReferencedTypeImpl [packageName=");
-        builder.append(packageName);
+        builder.append(getPackageName());
         builder.append(", name=");
-        builder.append(name);
+        builder.append(getName());
         builder.append("]");
         return builder.toString();
     }
diff --git a/opendaylight/sal/yang-prototype/code-generator/binding-generator-util/src/main/java/org/opendaylight/controller/binding/generator/util/generated/type/builder/AbstractGeneratedType.java b/opendaylight/sal/yang-prototype/code-generator/binding-generator-util/src/main/java/org/opendaylight/controller/binding/generator/util/generated/type/builder/AbstractGeneratedType.java
new file mode 100644 (file)
index 0000000..5609f73
--- /dev/null
@@ -0,0 +1,179 @@
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.binding.generator.util.generated.type.builder;
+
+
+import org.opendaylight.controller.binding.generator.util.AbstractBaseType;
+import org.opendaylight.controller.sal.binding.model.api.*;
+import org.opendaylight.controller.sal.binding.model.api.type.builder.*;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+abstract class AbstractGeneratedType extends AbstractBaseType implements GeneratedType {
+
+    private final Type parent;
+    private final String comment;
+    private final List<AnnotationType> annotations;
+    private final List<Type> implementsTypes;
+    private final List<Enumeration> enumerations;
+    private final List<Constant> constants;
+    private final List<MethodSignature> methodSignatures;
+    private final List<GeneratedType> enclosedTypes;
+    private final boolean isAbstract;
+
+    public AbstractGeneratedType(final Type parent, final String packageName,
+                             final String name, final String comment,
+                             final List<AnnotationTypeBuilder> annotationBuilders,
+                             final boolean isAbstract,
+                             final List<Type> implementsTypes,
+                             final List<GeneratedTypeBuilder> enclosedGenTypeBuilders,
+                             final List<GeneratedTOBuilder> enclosedGenTOBuilders,
+                             final List<EnumBuilder> enumBuilders,
+                             final List<Constant> constants,
+                             final List<MethodSignatureBuilder> methodBuilders) {
+        super(packageName, name);
+        this.parent = parent;
+        this.comment = comment;
+        this.annotations = toUnmodifiableAnnotations(annotationBuilders);
+        this.implementsTypes = Collections.unmodifiableList(implementsTypes);
+        this.constants = toUnmodifiableConstants(constants);
+        this.enumerations = toUnmodifiableEnumerations(enumBuilders);
+        this.methodSignatures = toUnmodifiableMethods(methodBuilders);
+        this.enclosedTypes = toUnmodifiableEnclosedTypes(enclosedGenTypeBuilders, enclosedGenTOBuilders);
+        this.isAbstract = isAbstract;
+    }
+
+    private List<GeneratedType> toUnmodifiableEnclosedTypes(final List<GeneratedTypeBuilder> enclosedGenTypeBuilders,
+                                                            final List<GeneratedTOBuilder> enclosedGenTOBuilders) {
+        final List<GeneratedType> enclosedTypes = new ArrayList<>();
+        for (final GeneratedTypeBuilder builder : enclosedGenTypeBuilders) {
+            if (builder != null) {
+                enclosedTypes.add(builder.toInstance());
+            }
+        }
+
+        for (final GeneratedTOBuilder builder : enclosedGenTOBuilders) {
+            if (builder != null) {
+                enclosedTypes.add(builder.toInstance());
+            }
+        }
+        return enclosedTypes;
+    }
+
+    protected List<AnnotationType> toUnmodifiableAnnotations(
+            final List<AnnotationTypeBuilder> annotationBuilders) {
+        final List<AnnotationType> annotations = new ArrayList<>();
+        for (final AnnotationTypeBuilder builder : annotationBuilders) {
+            annotations.add(builder.toInstance());
+        }
+        return Collections.unmodifiableList(annotations);
+    }
+
+    protected List<MethodSignature> toUnmodifiableMethods(
+            List<MethodSignatureBuilder> methodBuilders) {
+        final List<MethodSignature> methods = new ArrayList<>();
+        for (final MethodSignatureBuilder methodBuilder : methodBuilders) {
+            methods.add(methodBuilder.toInstance(this));
+        }
+        return Collections.unmodifiableList(methods);
+    }
+
+    protected List<Enumeration> toUnmodifiableEnumerations(
+            List<EnumBuilder> enumBuilders) {
+        final List<Enumeration> enums = new ArrayList<>();
+        for (final EnumBuilder enumBuilder : enumBuilders) {
+            enums.add(enumBuilder.toInstance(this));
+        }
+        return Collections.unmodifiableList(enums);
+    }
+
+    protected List<Constant> toUnmodifiableConstants(
+            List<Constant> constants) {
+        for (final Constant constant : constants) {
+            constants.add(new ConstantImpl(this, constant.getType(),
+                    constant.getName(), constant.getValue()));
+        }
+        return Collections.unmodifiableList(constants);
+    }
+
+    @Override
+    public Type getParentType() {
+        return parent;
+    }
+
+    @Override
+    public String getComment() {
+        return comment;
+    }
+
+    @Override
+    public List<AnnotationType> getAnnotations() {
+        return annotations;
+    }
+
+    @Override
+    public boolean isAbstract() {
+       return isAbstract;
+    }
+
+     @Override
+    public List<Type> getImplements() {
+        return implementsTypes;
+    }
+
+    @Override
+    public List<GeneratedType> getEnclosedTypes() {
+        return enclosedTypes;
+    }
+
+    @Override
+    public List<Enumeration> getEnumerations() {
+        return enumerations;
+    }
+
+    @Override
+    public List<Constant> getConstantDefinitions() {
+        return constants;
+    }
+
+    @Override
+    public List<MethodSignature> getMethodDefinitions() {
+        return methodSignatures;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder builder = new StringBuilder();
+        builder.append("GeneratedType [packageName=");
+        builder.append(getPackageName());
+        builder.append(", name=");
+        builder.append(getName());
+        if (parent != null) {
+            builder.append(", parent=");
+            builder.append(parent.getFullyQualifiedName());
+        } else {
+            builder.append(", parent=null");
+        }
+        builder.append(", comment=");
+        builder.append(comment);
+        builder.append(", annotations=");
+        builder.append(annotations);
+        builder.append(", enclosedTypes=");
+        builder.append(enclosedTypes);
+        builder.append(", enumerations=");
+        builder.append(enumerations);
+        builder.append(", constants=");
+        builder.append(constants);
+        builder.append(", methodSignatures=");
+        builder.append(methodSignatures);
+        builder.append("]");
+        return builder.toString();
+    }
+}
diff --git a/opendaylight/sal/yang-prototype/code-generator/binding-generator-util/src/main/java/org/opendaylight/controller/binding/generator/util/generated/type/builder/AbstractGeneratedTypeBuilder.java b/opendaylight/sal/yang-prototype/code-generator/binding-generator-util/src/main/java/org/opendaylight/controller/binding/generator/util/generated/type/builder/AbstractGeneratedTypeBuilder.java
new file mode 100644 (file)
index 0000000..02c0060
--- /dev/null
@@ -0,0 +1,223 @@
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.binding.generator.util.generated.type.builder;
+
+import org.opendaylight.controller.sal.binding.model.api.AccessModifier;
+import org.opendaylight.controller.sal.binding.model.api.Constant;
+import org.opendaylight.controller.sal.binding.model.api.Type;
+import org.opendaylight.controller.sal.binding.model.api.type.builder.*;
+
+import java.util.ArrayList;
+import java.util.List;
+
+abstract class AbstractGeneratedTypeBuilder implements GeneratedTypeBuilder {
+
+    private final String packageName;
+    private String comment = "";
+    private final String name;
+
+    private final List<AnnotationTypeBuilder> annotationBuilders = new ArrayList<>();
+    private final List<Type> implementsTypes = new ArrayList<>();
+    private final List<EnumBuilder> enumDefinitions = new ArrayList<>();
+    private final List<Constant> constants = new ArrayList<>();
+    private final List<MethodSignatureBuilder> methodDefinitions = new ArrayList<>();
+    private final List<GeneratedTypeBuilder> enclosedTypes = new ArrayList<>();
+    private final List<GeneratedTOBuilder> enclosingTransferObjects = new ArrayList<>();
+    private boolean isAbstract;
+
+    public AbstractGeneratedTypeBuilder(final String packageName, final String name) {
+        if (packageName == null) {
+            throw new IllegalArgumentException("Package Name for Generated Type cannot be null!");
+        }
+        if (name == null) {
+            throw new IllegalArgumentException("Name of Generated Type cannot be null!");
+        }
+        this.packageName = packageName;
+        this.name = name;
+    }
+
+    @Override
+    public String getPackageName() {
+        return packageName;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public String getFullyQualifiedName() {
+        return packageName + "." + name;
+    }
+
+
+    protected String getComment() {
+        return comment;
+    }
+
+    protected List<AnnotationTypeBuilder> getAnnotations() {
+        return annotationBuilders;
+    }
+
+    protected boolean isAbstract() {
+        return isAbstract;
+    }
+
+    protected List<Type> getImplementsTypes() {
+        return implementsTypes;
+    }
+
+    protected List<EnumBuilder> getEnumerations() {
+        return enumDefinitions;
+    }
+
+    protected List<Constant> getConstants() {
+        return constants;
+    }
+
+    protected List<MethodSignatureBuilder> getMethodDefinitions() {
+        return methodDefinitions;
+    }
+
+    protected List<GeneratedTypeBuilder> getEnclosedTypes() {
+        return enclosedTypes;
+    }
+
+    protected List<GeneratedTOBuilder> getEnclosedTransferObjects() {
+        return enclosingTransferObjects;
+    }
+
+    @Override
+    public GeneratedTypeBuilder addEnclosingType(String name) {
+        if (name == null) {
+            throw new IllegalArgumentException("Name for Enclosing Generated Type cannot be null!");
+        }
+        GeneratedTypeBuilder builder = new GeneratedTOBuilderImpl(getFullyQualifiedName(), name);
+        enclosedTypes.add(builder);
+        return builder;
+    }
+
+    @Override
+    public GeneratedTOBuilder addEnclosingTransferObject(String name) {
+        if (name == null) {
+            throw new IllegalArgumentException("Name for Enclosing Generated Transfer Object cannot be null!");
+        }
+        GeneratedTOBuilder builder = new GeneratedTOBuilderImpl(getFullyQualifiedName(), name);
+        enclosingTransferObjects.add(builder);
+        return builder;
+    }
+
+    @Override
+    public void addComment(String comment) {
+        this.comment = comment;
+    }
+
+    @Override
+    public AnnotationTypeBuilder addAnnotation(final String packageName, final String name) {
+        if (packageName == null) {
+            throw new IllegalArgumentException("Package Name for Annotation Type cannot be null!");
+        }
+        if (name == null) {
+            throw new IllegalArgumentException("Name of Annotation Type cannot be null!");
+        }
+
+        final AnnotationTypeBuilder builder = new AnnotationTypeBuilderImpl(packageName, name);
+        annotationBuilders.add(builder);
+        return builder;
+    }
+
+     @Override
+     public void setAbstract(boolean isAbstract) {
+         this.isAbstract = isAbstract;
+     }
+
+     @Override
+    public boolean addImplementsType(Type genType) {
+        if (genType == null) {
+            throw new IllegalArgumentException("Type cannot be null");
+        }
+        return implementsTypes.add(genType);
+    }
+
+    @Override
+    public Constant addConstant(Type type, String name, Object value) {
+        if (type == null) {
+            throw new IllegalArgumentException("Returning Type for Constant cannot be null!");
+        }
+        if (name == null) {
+            throw new IllegalArgumentException("Name of constant cannot be null!");
+        }
+
+        final Constant constant = new ConstantImpl(this, type, name, value);
+        constants.add(constant);
+        return constant;
+    }
+
+    @Override
+    public EnumBuilder addEnumeration(String name) {
+        if (name == null) {
+            throw new IllegalArgumentException("Name of enumeration cannot be null!");
+        }
+        final EnumBuilder builder = new EnumerationBuilderImpl(
+                getFullyQualifiedName(), name);
+        enumDefinitions.add(builder);
+        return builder;
+    }
+
+    @Override
+    public MethodSignatureBuilder addMethod(String name) {
+        if (name == null) {
+            throw new IllegalArgumentException("Name of method cannot be null!");
+        }
+        final MethodSignatureBuilder builder = new MethodSignatureBuilderImpl(name);
+        builder.setAccessModifier(AccessModifier.PUBLIC);
+        builder.setAbstract(true);
+        methodDefinitions.add(builder);
+        return builder;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
+        result = prime * result
+                + ((getPackageName() == null) ? 0 : getPackageName().hashCode());
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null) {
+            return false;
+        }
+        if (getClass() != obj.getClass()) {
+            return false;
+        }
+        AbstractGeneratedTypeBuilder other = (AbstractGeneratedTypeBuilder) obj;
+        if (getName() == null) {
+            if (other.getName() != null) {
+                return false;
+            }
+        } else if (!getName().equals(other.getName())) {
+            return false;
+        }
+        if (getPackageName() == null) {
+            if (other.getPackageName() != null) {
+                return false;
+            }
+        } else if (!getPackageName().equals(other.getPackageName())) {
+            return false;
+        }
+        return true;
+    }
+}
diff --git a/opendaylight/sal/yang-prototype/code-generator/binding-generator-util/src/main/java/org/opendaylight/controller/binding/generator/util/generated/type/builder/AbstractTypeMember.java b/opendaylight/sal/yang-prototype/code-generator/binding-generator-util/src/main/java/org/opendaylight/controller/binding/generator/util/generated/type/builder/AbstractTypeMember.java
new file mode 100644 (file)
index 0000000..5719d35
--- /dev/null
@@ -0,0 +1,138 @@
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.binding.generator.util.generated.type.builder;
+
+
+import org.opendaylight.controller.sal.binding.model.api.AccessModifier;
+import org.opendaylight.controller.sal.binding.model.api.AnnotationType;
+import org.opendaylight.controller.sal.binding.model.api.Type;
+import org.opendaylight.controller.sal.binding.model.api.TypeMember;
+
+import java.util.Collections;
+import java.util.List;
+
+abstract class AbstractTypeMember implements TypeMember {
+
+    private final String name;
+    private final String comment;
+    private final Type definingType;
+    private final Type returnType;
+    private final List<AnnotationType> annotations;
+    private final boolean isFinal;
+    private final AccessModifier accessModifier;
+
+    public AbstractTypeMember(final Type definingType, final String name,  final List<AnnotationType> annotations,
+                              final String comment, final AccessModifier accessModifier, final Type returnType,
+                              boolean isFinal) {
+        super();
+        this.definingType = definingType;
+        this.name = name;
+        this.annotations = Collections.unmodifiableList(annotations);
+        this.comment = comment;
+        this.accessModifier = accessModifier;
+        this.returnType = returnType;
+        this.isFinal = isFinal;
+    }
+
+    @Override
+    public List<AnnotationType> getAnnotations() {
+        return annotations;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public String getComment() {
+        return comment;
+    }
+
+    @Override
+    public Type getDefiningType() {
+        return definingType;
+    }
+
+    @Override
+    public AccessModifier getAccessModifier() {
+        return accessModifier;
+    }
+
+    @Override
+    public Type getReturnType() {
+        return returnType;
+    }
+
+    @Override
+    public boolean isFinal() {
+        return isFinal;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
+        result = prime * result
+                + ((getReturnType() == null) ? 0 : getReturnType().hashCode());
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null) {
+            return false;
+        }
+        if (getClass() != obj.getClass()) {
+            return false;
+        }
+        MethodSignatureImpl other = (MethodSignatureImpl) obj;
+        if (getName() == null) {
+            if (other.getName() != null) {
+                return false;
+            }
+        } else if (!getName().equals(other.getName())) {
+            return false;
+        }
+        if (getReturnType() == null) {
+            if (other.getReturnType() != null) {
+                return false;
+            }
+        } else if (!getReturnType().equals(other.getReturnType())) {
+            return false;
+        }
+        return true;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder builder = new StringBuilder();
+        builder.append("MethodSignatureImpl [name=");
+        builder.append(getName());
+        builder.append(", comment=");
+        builder.append(getComment());
+        if (getDefiningType() != null) {
+            builder.append(", definingType=");
+            builder.append(getDefiningType().getPackageName());
+            builder.append(".");
+            builder.append(getDefiningType().getName());
+        } else {
+            builder.append(", definingType= null");
+        }
+        builder.append(", returnType=");
+        builder.append(getReturnType());
+        builder.append(", annotations=");
+        builder.append(getAnnotations());
+        builder.append("]");
+        return builder.toString();
+    }
+}
diff --git a/opendaylight/sal/yang-prototype/code-generator/binding-generator-util/src/main/java/org/opendaylight/controller/binding/generator/util/generated/type/builder/AbstractTypeMemberBuilder.java b/opendaylight/sal/yang-prototype/code-generator/binding-generator-util/src/main/java/org/opendaylight/controller/binding/generator/util/generated/type/builder/AbstractTypeMemberBuilder.java
new file mode 100644 (file)
index 0000000..391c3af
--- /dev/null
@@ -0,0 +1,167 @@
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.binding.generator.util.generated.type.builder;
+
+import org.opendaylight.controller.sal.binding.model.api.AccessModifier;
+import org.opendaylight.controller.sal.binding.model.api.AnnotationType;
+import org.opendaylight.controller.sal.binding.model.api.Type;
+import org.opendaylight.controller.sal.binding.model.api.type.builder.AnnotationTypeBuilder;
+import org.opendaylight.controller.sal.binding.model.api.type.builder.TypeMemberBuilder;
+
+import java.util.ArrayList;
+import java.util.List;
+
+abstract class AbstractTypeMemberBuilder implements TypeMemberBuilder {
+    private final String name;
+    private Type returnType;
+    private final List<AnnotationTypeBuilder> annotationBuilders;
+    private String comment = "";
+    private boolean isFinal;
+    private AccessModifier accessModifier;
+
+    public AbstractTypeMemberBuilder(final String name) {
+        this.name = name;
+        this.annotationBuilders = new ArrayList<>();
+    }
+
+    @Override
+    public AnnotationTypeBuilder addAnnotation(String packageName, String name) {
+        if (packageName == null) {
+            throw new IllegalArgumentException("Annotation Type cannot have package name null!");
+        }
+        if (name == null) {
+            throw new IllegalArgumentException("Annotation Type cannot have name as null!");
+        }
+        final AnnotationTypeBuilder builder = new AnnotationTypeBuilderImpl(
+                    packageName, name);
+        annotationBuilders.add(builder);
+        return builder;
+    }
+
+    protected Type getReturnType() {
+        return returnType;
+    }
+
+    protected List<AnnotationTypeBuilder> getAnnotationBuilders() {
+        return annotationBuilders;
+    }
+
+    protected String getComment() {
+        return comment;
+    }
+
+    protected boolean isFinal() {
+        return isFinal;
+    }
+
+    protected AccessModifier getAccessModifier() {
+        return accessModifier;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public void setReturnType(Type returnType) {
+        if (returnType == null) {
+            throw new IllegalArgumentException("Return Type of member cannot be null!");
+        }
+        this.returnType = returnType;
+    }
+
+    @Override
+    public void setAccessModifier(AccessModifier modifier) {
+        if (modifier == null) {
+            throw new IllegalArgumentException("Access Modifier for member type cannot be null!");
+        }
+        this.accessModifier = modifier;
+    }
+
+    @Override
+    public void setComment(String comment) {
+        if (comment == null) {
+            throw new IllegalArgumentException("Comment string cannot be null!");
+        }
+        this.comment = comment;
+    }
+
+    @Override
+    public void setFinal(boolean isFinal) {
+        this.isFinal = isFinal;
+    }
+
+    protected List<AnnotationType> toAnnotationTypes() {
+        final List<AnnotationType> annotations = new ArrayList<>();
+        for (final AnnotationTypeBuilder annotBuilder : getAnnotationBuilders()) {
+            if (annotBuilder != null) {
+                annotations.add(annotBuilder.toInstance());
+            }
+        }
+        return annotations;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
+        result = prime * result
+                + ((getReturnType() == null) ? 0 : getReturnType().hashCode());
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null) {
+            return false;
+        }
+        if (getClass() != obj.getClass()) {
+            return false;
+        }
+        MethodSignatureBuilderImpl other = (MethodSignatureBuilderImpl) obj;
+        if (getName() == null) {
+            if (other.getName() != null) {
+                return false;
+            }
+        } else if (!getName().equals(other.getName())) {
+            return false;
+        }
+        if (getReturnType() == null) {
+            if (other.getReturnType() != null) {
+                return false;
+            }
+        } else if (!getReturnType().equals(other.getReturnType())) {
+            return false;
+        }
+        return true;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder builder = new StringBuilder();
+        builder.append("GeneratedPropertyImpl [name=");
+        builder.append(getName());
+        builder.append(", annotations=");
+        builder.append(getAnnotationBuilders());
+        builder.append(", comment=");
+        builder.append(getComment());
+        builder.append(", returnType=");
+        builder.append(getReturnType());
+        builder.append(", isFinal=");
+        builder.append(isFinal());
+        builder.append(", modifier=");
+        builder.append(getAccessModifier());
+        builder.append("]");
+        return builder.toString();
+    }
+}
index 6eaa7695638a9b7d0d76fe1fed89cd997082cdd5..c125af556a14551eb9af51c3faa70b87460f55e5 100644 (file)
@@ -1,3 +1,10 @@
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
 package org.opendaylight.controller.binding.generator.util.generated.type.builder;
 
 import java.util.ArrayList;
@@ -18,9 +25,8 @@ final class AnnotationTypeBuilderImpl implements AnnotationTypeBuilder {
         super();
         this.packageName = packageName;
         this.name = name;
-        
-        annotationBuilders = new ArrayList<AnnotationTypeBuilder>();
-        parameters = new ArrayList<AnnotationType.Parameter>();
+        annotationBuilders = new ArrayList<>();
+        parameters = new ArrayList<>();
     }
 
     @Override
@@ -33,6 +39,11 @@ final class AnnotationTypeBuilderImpl implements AnnotationTypeBuilder {
         return name;
     }
 
+    @Override
+    public String getFullyQualifiedName() {
+        return packageName + "." + name;
+    }
+
     @Override
     public AnnotationTypeBuilder addAnnotation(final String packageName, final String name) {
         if (packageName != null && name != null) {
@@ -134,7 +145,7 @@ final class AnnotationTypeBuilderImpl implements AnnotationTypeBuilder {
             this.packageName = packageName;
             this.name = name;
             
-            this.annotations = new ArrayList<AnnotationType>();
+            this.annotations = new ArrayList<>();
             for (final AnnotationTypeBuilder builder : annotationBuilders) {
                 annotations.add(builder.toInstance());
             }
@@ -142,7 +153,7 @@ final class AnnotationTypeBuilderImpl implements AnnotationTypeBuilder {
             this.annotations = Collections.unmodifiableList(annotations); 
             this.parameters = Collections.unmodifiableList(parameters);
             
-            paramNames = new ArrayList<String>();
+            paramNames = new ArrayList<>();
             for (final AnnotationType.Parameter parameter : parameters) {
                 paramNames.add(parameter.getName());
             }
@@ -159,6 +170,11 @@ final class AnnotationTypeBuilderImpl implements AnnotationTypeBuilder {
             return name;
         }
 
+        @Override
+        public String getFullyQualifiedName() {
+            return packageName + "." + name;
+        }
+
         @Override
         public List<AnnotationType> getAnnotations() {
             return annotations;
diff --git a/opendaylight/sal/yang-prototype/code-generator/binding-generator-util/src/main/java/org/opendaylight/controller/binding/generator/util/generated/type/builder/ConstantBuilderImpl.java b/opendaylight/sal/yang-prototype/code-generator/binding-generator-util/src/main/java/org/opendaylight/controller/binding/generator/util/generated/type/builder/ConstantBuilderImpl.java
deleted file mode 100644 (file)
index 16e89e0..0000000
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.binding.generator.util.generated.type.builder;
-
-import org.opendaylight.controller.sal.binding.model.api.Constant;
-import org.opendaylight.controller.sal.binding.model.api.Type;
-import org.opendaylight.controller.sal.binding.model.api.type.builder.ConstantBuilder;
-
-final class ConstantBuilderImpl implements ConstantBuilder {
-
-    private final Type type;
-    private final String name;
-    private Object value;
-
-    public ConstantBuilderImpl(Type type, String name, Object value) {
-        super();
-        this.type = type;
-        this.name = name;
-        this.value = value;
-    }
-
-    public ConstantBuilderImpl(Type type, String name) {
-        super();
-        this.type = type;
-        this.name = name;
-    }
-
-    @Override
-    public void assignValue(Object value) {
-        this.value = value;
-    }
-
-    @Override
-    public Constant toInstance(final Type definingType) {
-        return new ConstantImpl(definingType, type, name, value);
-    }
-
-    private static final class ConstantImpl implements Constant {
-
-        final Type definingType;
-        private final Type type;
-        private final String name;
-        private final Object value;
-
-        public ConstantImpl(final Type definingType, final Type type,
-                final String name, final Object value) {
-            super();
-            this.definingType = definingType;
-            this.type = type;
-            this.name = name;
-            this.value = value;
-        }
-
-        @Override
-        public Type getDefiningType() {
-            return definingType;
-        }
-
-        @Override
-        public Type getType() {
-            return type;
-        }
-
-        @Override
-        public String getName() {
-            return name;
-        }
-
-        @Override
-        public Object getValue() {
-            return value;
-        }
-        
-        @Override
-        public String toFormattedString() {
-            StringBuilder builder = new StringBuilder();
-            builder.append(type);
-            builder.append(" ");
-            builder.append(name);
-            builder.append(" ");
-            builder.append(value);
-            return builder.toString();
-        }
-
-        /*
-         * (non-Javadoc)
-         * 
-         * @see java.lang.Object#hashCode()
-         */
-        @Override
-        public int hashCode() {
-            final int prime = 31;
-            int result = 1;
-            result = prime * result + ((name == null) ? 0 : name.hashCode());
-            result = prime * result + ((type == null) ? 0 : type.hashCode());
-            return result;
-        }
-
-        /*
-         * (non-Javadoc)
-         * 
-         * @see java.lang.Object#equals(java.lang.Object)
-         */
-        @Override
-        public boolean equals(Object obj) {
-            if (this == obj) {
-                return true;
-            }
-            if (obj == null) {
-                return false;
-            }
-            if (getClass() != obj.getClass()) {
-                return false;
-            }
-            ConstantImpl other = (ConstantImpl) obj;
-            if (name == null) {
-                if (other.name != null) {
-                    return false;
-                }
-            } else if (!name.equals(other.name)) {
-                return false;
-            }
-            if (type == null) {
-                if (other.type != null) {
-                    return false;
-                }
-            } else if (!type.equals(other.type)) {
-                return false;
-            }
-            if (value == null) {
-                if (other.value != null) {
-                    return false;
-                }
-            } else if (!value.equals(other.value)) {
-                return false;
-            }
-            return true;
-        }
-
-        @Override
-        public String toString() {
-            StringBuilder builder = new StringBuilder();
-            builder.append("Constant [type=");
-            builder.append(type);
-            builder.append(", name=");
-            builder.append(name);
-            builder.append(", value=");
-            builder.append(value);
-            if (definingType != null) {
-                builder.append(", definingType=");
-                builder.append(definingType.getPackageName());
-                builder.append(".");
-                builder.append(definingType.getName());
-            } else {
-                builder.append(", definingType= null");
-            }
-            builder.append("]");
-            return builder.toString();
-        }
-    }
-}
diff --git a/opendaylight/sal/yang-prototype/code-generator/binding-generator-util/src/main/java/org/opendaylight/controller/binding/generator/util/generated/type/builder/ConstantImpl.java b/opendaylight/sal/yang-prototype/code-generator/binding-generator-util/src/main/java/org/opendaylight/controller/binding/generator/util/generated/type/builder/ConstantImpl.java
new file mode 100644 (file)
index 0000000..5d7ba4e
--- /dev/null
@@ -0,0 +1,135 @@
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.binding.generator.util.generated.type.builder;
+
+import org.opendaylight.controller.sal.binding.model.api.Constant;
+import org.opendaylight.controller.sal.binding.model.api.Type;
+
+final class ConstantImpl implements Constant {
+
+    final Type definingType;
+    private final Type type;
+    private final String name;
+    private final Object value;
+
+    public ConstantImpl(final Type definingType, final Type type,
+                        final String name, final Object value) {
+        super();
+        this.definingType = definingType;
+        this.type = type;
+        this.name = name;
+        this.value = value;
+    }
+
+    @Override
+    public Type getDefiningType() {
+        return definingType;
+    }
+
+    @Override
+    public Type getType() {
+        return type;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public Object getValue() {
+        return value;
+    }
+
+    @Override
+    public String toFormattedString() {
+        StringBuilder builder = new StringBuilder();
+        builder.append(type);
+        builder.append(" ");
+        builder.append(name);
+        builder.append(" ");
+        builder.append(value);
+        return builder.toString();
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see java.lang.Object#hashCode()
+     */
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((name == null) ? 0 : name.hashCode());
+        result = prime * result + ((type == null) ? 0 : type.hashCode());
+        return result;
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see java.lang.Object#equals(java.lang.Object)
+     */
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null) {
+            return false;
+        }
+        if (getClass() != obj.getClass()) {
+            return false;
+        }
+        ConstantImpl other = (ConstantImpl) obj;
+        if (name == null) {
+            if (other.name != null) {
+                return false;
+            }
+        } else if (!name.equals(other.name)) {
+            return false;
+        }
+        if (type == null) {
+            if (other.type != null) {
+                return false;
+            }
+        } else if (!type.equals(other.type)) {
+            return false;
+        }
+        if (value == null) {
+            if (other.value != null) {
+                return false;
+            }
+        } else if (!value.equals(other.value)) {
+            return false;
+        }
+        return true;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder builder = new StringBuilder();
+        builder.append("Constant [type=");
+        builder.append(type);
+        builder.append(", name=");
+        builder.append(name);
+        builder.append(", value=");
+        builder.append(value);
+        if (definingType != null) {
+            builder.append(", definingType=");
+            builder.append(definingType.getPackageName());
+            builder.append(".");
+            builder.append(definingType.getName());
+        } else {
+            builder.append(", definingType= null");
+        }
+        builder.append("]");
+        return builder.toString();
+    }
+}
index 62945ea4517253c6d5643cfd9e759887c493ed5c..8bf5b5d4cb587d13270773a4104e5a82965edca9 100644 (file)
@@ -27,7 +27,7 @@ public final class EnumerationBuilderImpl implements EnumBuilder {
         super();
         this.packageName = packageName;
         this.name = name;
-        values = new ArrayList<Enumeration.Pair>();
+        values = new ArrayList<>();
     }
     
     @Override
@@ -39,7 +39,12 @@ public final class EnumerationBuilderImpl implements EnumBuilder {
     public String getName() {
         return name;
     }
-    
+
+    @Override
+    public String getFullyQualifiedName() {
+        return packageName + "." + name;
+    }
+
     @Override
     public AnnotationTypeBuilder addAnnotation(final String packageName, final String name) {
         if (packageName != null && name != null) {
@@ -220,7 +225,7 @@ public final class EnumerationBuilderImpl implements EnumBuilder {
         private final String packageName;
         private final String name;
         private final List<Pair> values;
-        private List<AnnotationType> annotations = new ArrayList<AnnotationType>();
+        private List<AnnotationType> annotations = new ArrayList<>();
         
         public EnumerationImpl(final Type definingType,
                 final List<AnnotationTypeBuilder> annotationBuilders,
@@ -252,6 +257,11 @@ public final class EnumerationBuilderImpl implements EnumBuilder {
             return name;
         }
 
+        @Override
+        public String getFullyQualifiedName() {
+            return packageName + "." + name;
+        }
+
         @Override
         public List<Pair> getValues() {
             return values;
diff --git a/opendaylight/sal/yang-prototype/code-generator/binding-generator-util/src/main/java/org/opendaylight/controller/binding/generator/util/generated/type/builder/GeneratedPropertyBuilderImpl.java b/opendaylight/sal/yang-prototype/code-generator/binding-generator-util/src/main/java/org/opendaylight/controller/binding/generator/util/generated/type/builder/GeneratedPropertyBuilderImpl.java
new file mode 100644 (file)
index 0000000..9b61163
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.binding.generator.util.generated.type.builder;
+
+import org.opendaylight.controller.sal.binding.model.api.AnnotationType;
+import org.opendaylight.controller.sal.binding.model.api.GeneratedProperty;
+import org.opendaylight.controller.sal.binding.model.api.Type;
+import org.opendaylight.controller.sal.binding.model.api.type.builder.GeneratedPropertyBuilder;
+
+import java.util.List;
+
+final class GeneratedPropertyBuilderImpl extends AbstractTypeMemberBuilder implements GeneratedPropertyBuilder {
+
+    private boolean isReadOnly;
+
+    public GeneratedPropertyBuilderImpl(String name) {
+        super(name);
+    }
+
+    @Override
+    public void setReadOnly(boolean isReadOnly) {
+        this.isReadOnly = isReadOnly;
+    }
+
+    @Override
+    public GeneratedProperty toInstance(Type definingType) {
+        final List<AnnotationType> annotations = toAnnotationTypes();
+        return new GeneratedPropertyImpl(definingType, getName(), annotations, getComment(), getAccessModifier(),
+                getReturnType(), isFinal(), isReadOnly);
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder builder = new StringBuilder();
+        builder.append("GeneratedPropertyImpl [name=");
+        builder.append(getName());
+        builder.append(", annotations=");
+        builder.append(getAnnotationBuilders());
+        builder.append(", comment=");
+        builder.append(getComment());
+        builder.append(", returnType=");
+        builder.append(getReturnType());
+        builder.append(", isFinal=");
+        builder.append(isFinal());
+        builder.append(", isReadOnly=");
+        builder.append(isReadOnly);
+        builder.append(", modifier=");
+        builder.append(getAccessModifier());
+        builder.append("]");
+        return builder.toString();
+    }
+}
\ No newline at end of file
diff --git a/opendaylight/sal/yang-prototype/code-generator/binding-generator-util/src/main/java/org/opendaylight/controller/binding/generator/util/generated/type/builder/GeneratedPropertyImpl.java b/opendaylight/sal/yang-prototype/code-generator/binding-generator-util/src/main/java/org/opendaylight/controller/binding/generator/util/generated/type/builder/GeneratedPropertyImpl.java
new file mode 100644 (file)
index 0000000..6d11bfd
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.binding.generator.util.generated.type.builder;
+
+import org.opendaylight.controller.sal.binding.model.api.AccessModifier;
+import org.opendaylight.controller.sal.binding.model.api.AnnotationType;
+import org.opendaylight.controller.sal.binding.model.api.GeneratedProperty;
+import org.opendaylight.controller.sal.binding.model.api.Type;
+
+import java.util.List;
+
+final class GeneratedPropertyImpl extends AbstractTypeMember implements GeneratedProperty {
+
+    private boolean isReadOnly;
+
+    public GeneratedPropertyImpl(Type definingType, String name, List<AnnotationType> annotations, String comment,
+                                 AccessModifier accessModifier, Type returnType, boolean isFinal, boolean isReadOnly) {
+        super(definingType, name, annotations, comment, accessModifier, returnType, isFinal);
+        this.isReadOnly = isReadOnly;
+    }
+
+    @Override
+    public boolean isReadOnly() {
+        return isReadOnly;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder builder = new StringBuilder();
+        builder.append("GeneratedPropertyImpl [name=");
+        builder.append(getName());
+        builder.append(", annotations=");
+        builder.append(getAnnotations());
+        builder.append(", comment=");
+        builder.append(getComment());
+        if (getDefiningType() != null) {
+            builder.append(", parent=");
+            builder.append(getDefiningType().getPackageName());
+            builder.append(".");
+            builder.append(getDefiningType().getName());
+        } else {
+            builder.append(", parent=null");
+        }
+        builder.append(", returnType=");
+        builder.append(getReturnType());
+        builder.append(", isFinal=");
+        builder.append(isFinal());
+        builder.append(", isReadOnly=");
+        builder.append(isReadOnly);
+        builder.append(", modifier=");
+        builder.append(getAccessModifier());
+        builder.append("]");
+        return builder.toString();
+    }
+}
index f1683fdc6435e86ccb98ea36389c1a24053b9d13..de3e19223f5fca053240f27ab1d0ca3031d63be0 100644 (file)
  */
 package org.opendaylight.controller.binding.generator.util.generated.type.builder;
 
+import org.opendaylight.controller.sal.binding.model.api.*;
+import org.opendaylight.controller.sal.binding.model.api.type.builder.*;
+
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
-import org.opendaylight.controller.sal.binding.model.api.AccessModifier;
-import org.opendaylight.controller.sal.binding.model.api.AnnotationType;
-import org.opendaylight.controller.sal.binding.model.api.Constant;
-import org.opendaylight.controller.sal.binding.model.api.Enumeration;
-import org.opendaylight.controller.sal.binding.model.api.GeneratedProperty;
-import org.opendaylight.controller.sal.binding.model.api.GeneratedTransferIdentityObject;
-import org.opendaylight.controller.sal.binding.model.api.GeneratedTransferObject;
-import org.opendaylight.controller.sal.binding.model.api.MethodSignature;
-import org.opendaylight.controller.sal.binding.model.api.Type;
-import org.opendaylight.controller.sal.binding.model.api.type.builder.AnnotationTypeBuilder;
-import org.opendaylight.controller.sal.binding.model.api.type.builder.ConstantBuilder;
-import org.opendaylight.controller.sal.binding.model.api.type.builder.EnumBuilder;
-import org.opendaylight.controller.sal.binding.model.api.type.builder.GeneratedPropertyBuilder;
-import org.opendaylight.controller.sal.binding.model.api.type.builder.GeneratedTOBuilder;
-import org.opendaylight.controller.sal.binding.model.api.type.builder.MethodSignatureBuilder;
-
-public class GeneratedTOBuilderImpl implements GeneratedTOBuilder {
-    private String packageName;
-    private final String name;
-    private String comment = "";
+public final class GeneratedTOBuilderImpl extends AbstractGeneratedTypeBuilder implements GeneratedTOBuilder {
 
     private GeneratedTransferObject extendsType;
-    private final List<Type> implementsTypes = new ArrayList<Type>();
-    private final List<EnumBuilder> enumerations = new ArrayList<EnumBuilder>();
-    private final List<GeneratedPropertyBuilder> properties = new ArrayList<GeneratedPropertyBuilder>();
-    private final List<GeneratedPropertyBuilder> equalsProperties = new ArrayList<GeneratedPropertyBuilder>();
-    private final List<GeneratedPropertyBuilder> hashProperties = new ArrayList<GeneratedPropertyBuilder>();
-    private final List<GeneratedPropertyBuilder> toStringProperties = new ArrayList<GeneratedPropertyBuilder>();
-
-    private final List<ConstantBuilder> constantDefintions = new ArrayList<ConstantBuilder>();
-    private final List<MethodSignatureBuilder> methodDefinitions = new ArrayList<MethodSignatureBuilder>();
-    private final List<AnnotationTypeBuilder> annotationBuilders = new ArrayList<AnnotationTypeBuilder>();
+    private final List<GeneratedPropertyBuilder> properties = new ArrayList<>();
+    private final List<GeneratedPropertyBuilder> equalsProperties = new ArrayList<>();
+    private final List<GeneratedPropertyBuilder> hashProperties = new ArrayList<>();
+    private final List<GeneratedPropertyBuilder> toStringProperties = new ArrayList<>();
 
     public GeneratedTOBuilderImpl(String packageName, String name) {
-        super();
-        this.packageName = packageName;
-        this.name = name;
-    }
-
-    @Override
-    public String getPackageName() {
-        return packageName;
-    }
-
-    @Override
-    public String getName() {
-        return name;
-    }
-
-    @Override
-    public Type getParentType() {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    @Override
-    public void addComment(final String comment) {
-        this.comment = comment;
-    }
-
-    @Override
-    public AnnotationTypeBuilder addAnnotation(String packageName, String name) {
-        if (packageName != null && name != null) {
-            final AnnotationTypeBuilder builder = new AnnotationTypeBuilderImpl(
-                    packageName, name);
-            if (annotationBuilders.add(builder)) {
-                return builder;
-            }
-        }
-        return null;
-    }
-
-    @Override
-    public boolean addImplementsType(final Type genType) {
-        if (genType != null) {
-            return implementsTypes.add(genType);
-        }
-        return false;
+        super(packageName, name);
+        setAbstract(false);
     }
 
     @Override
-    public boolean addExtendsType(final GeneratedTransferObject genTransObj) {
-        if (genTransObj != null) {
-            extendsType = genTransObj;
-            return true;
+    public void setExtendsType(final GeneratedTransferObject genTransObj) {
+        if (genTransObj == null) {
+            throw new IllegalArgumentException("Generated Transfer Object cannot be null!");
         }
-        return false;
-    }
-
-    @Override
-    public EnumBuilder addEnumeration(String name) {
-        final String innerPackageName = packageName + "." + this.name;
-        final EnumBuilder builder = new EnumerationBuilderImpl(innerPackageName,
-                name);
-        enumerations.add(builder);
-        return builder;
+        extendsType = genTransObj;
     }
 
     @Override
-    public ConstantBuilder addConstant(Type type, String name, Object value) {
-        final ConstantBuilder builder = new ConstantBuilderImpl(type, name,
-                value);
-        constantDefintions.add(builder);
+    public GeneratedPropertyBuilder addProperty(String name) {
+        final GeneratedPropertyBuilder builder = new GeneratedPropertyBuilderImpl(name);
+        builder.setAccessModifier(AccessModifier.PUBLIC);
+        properties.add(builder);
         return builder;
     }
 
+    /**
+     * Add new Method Signature definition for Generated Type Builder and
+     * returns Method Signature Builder for specifying all Method parameters.
+     * <br>
+     * Name of Method cannot be <code>null</code>,
+     * if it is <code>null</code> the method SHOULD throw {@link IllegalArgumentException}
+     * <br>
+     * By <i>Default</i> the MethodSignatureBuilder SHOULD be pre-set as
+     * {@link MethodSignatureBuilder#setAbstract(false)}, {@link MethodSignatureBuilder#setFinal(false)} and
+     * {@link MethodSignatureBuilder#setAccessModifier(PUBLIC)}
+     *
+     * @param name Name of Method
+     * @return <code>new</code> instance of Method Signature Builder.
+     */
     @Override
     public MethodSignatureBuilder addMethod(String name) {
-        final MethodSignatureBuilder builder = new MethodSignatureBuilderImpl(
-                this, name);
-        methodDefinitions.add(builder);
-        return builder;
-    }
-
-    @Override
-    public GeneratedPropertyBuilder addProperty(String name) {
-        final GeneratedPropertyBuilder builder = new GeneratedPropertyBuilderImpl(
-                name);
-        properties.add(builder);
+        final MethodSignatureBuilder builder = super.addMethod(name);
+        builder.setAbstract(false);
         return builder;
     }
 
@@ -150,381 +81,83 @@ public class GeneratedTOBuilderImpl implements GeneratedTOBuilder {
 
     @Override
     public GeneratedTransferObject toInstance() {
-        return new GeneratedTransferObjectImpl(packageName, name, comment,
-                annotationBuilders, extendsType, implementsTypes,
-                constantDefintions, enumerations, methodDefinitions,
-                properties, equalsProperties, hashProperties,
-                toStringProperties);
-    }
-
-    @Override
-    public GeneratedTransferObject toIdentityInstance() {
-        return new GeneratedTransferIdentityObjectImpl(packageName, name, comment,
-                annotationBuilders, extendsType, implementsTypes,
-                constantDefintions, enumerations, methodDefinitions,
-                properties, equalsProperties, hashProperties,
-                toStringProperties);
-    }
-
-    private static final class GeneratedPropertyBuilderImpl implements
-            GeneratedPropertyBuilder {
-
-        private final String name;
-        private final List<AnnotationTypeBuilder> annotationBuilders = new ArrayList<AnnotationTypeBuilder>();
-        private Type returnType;
-        private final List<MethodSignature.Parameter> parameters;
-        private String comment = "";
-        private AccessModifier accessModifier;
-        private boolean isFinal;
-        private boolean isReadOnly;
-
-        public GeneratedPropertyBuilderImpl(final String name) {
-            super();
-            this.name = name;
-            parameters = new ArrayList<MethodSignature.Parameter>();
-            isFinal = true;
-            this.isReadOnly = true;
-            accessModifier = AccessModifier.PUBLIC;
-        }
-
-        public String getName() {
-            return name;
-        }
-
-        @Override
-        public AnnotationTypeBuilder addAnnotation(String packageName,
-                String name) {
-            if (packageName != null && name != null) {
-                final AnnotationTypeBuilder builder = new AnnotationTypeBuilderImpl(
-                        packageName, name);
-                if (annotationBuilders.add(builder)) {
-                    return builder;
-                }
-            }
-            return null;
-        }
-
-        @Override
-        public boolean addReturnType(Type returnType) {
-            if (returnType != null) {
-                this.returnType = returnType;
-                this.parameters.add(new MethodParameterImpl(name, returnType));
-                return true;
-            }
-            return false;
-        }
-
-        @Override
-        public void accessorModifier(final AccessModifier modifier) {
-            accessModifier = modifier;
-        }
-
-        @Override
-        public void addComment(String comment) {
-            if (comment != null) {
-                this.comment = comment;
-            }
-        }
-
-        @Override
-        public void setFinal(boolean isFinal) {
-            this.isFinal = isFinal;
-        }
-
-        @Override
-        public void setReadOnly(boolean isReadOnly) {
-            this.isReadOnly = isReadOnly;
-        }
-
-        @Override
-        public GeneratedProperty toInstance(final Type definingType) {
-            return new GeneratedPropertyImpl(name, comment, annotationBuilders,
-                    definingType, returnType, isFinal, isReadOnly, parameters,
-                    accessModifier);
-        }
-    }
-
-    private static final class GeneratedPropertyImpl implements
-            GeneratedProperty {
-
-        private final String name;
-        private List<AnnotationType> annotations;
-        private final String comment;
-        private final Type parent;
-        private final Type returnType;
-        private final boolean isFinal;
-        private final boolean isReadOnly;
-        private final List<MethodSignature.Parameter> parameters;
-        private final AccessModifier modifier;
-
-        public GeneratedPropertyImpl(final String name, final String comment,
-                final List<AnnotationTypeBuilder> annotationBuilders,
-                final Type parent, final Type returnType,
-                final boolean isFinal, final boolean isReadOnly,
-                final List<Parameter> parameters, final AccessModifier modifier) {
-            super();
-            this.name = name;
-            this.annotations = new ArrayList<AnnotationType>();
-            for (final AnnotationTypeBuilder builder : annotationBuilders) {
-                this.annotations.add(builder.toInstance());
-            }
-            this.annotations = Collections.unmodifiableList(this.annotations);
-            this.comment = comment;
-            this.parent = parent;
-            this.returnType = returnType;
-            this.isFinal = isFinal;
-            this.isReadOnly = isReadOnly;
-            this.parameters = Collections.unmodifiableList(parameters);
-            this.modifier = modifier;
-        }
-
-        @Override
-        public String getName() {
-            return name;
-        }
-
-        @Override
-        public String getComment() {
-            return comment;
-        }
-
-        @Override
-        public Type getDefiningType() {
-            return parent;
-        }
-
-        @Override
-        public List<AnnotationType> getAnnotations() {
-            return annotations;
-        }
-
-        @Override
-        public Type getReturnType() {
-            return returnType;
-        }
-
-        @Override
-        public List<Parameter> getParameters() {
-            return parameters;
-        }
-
-        @Override
-        public AccessModifier getAccessModifier() {
-            return modifier;
-        }
-
-        @Override
-        public boolean isReadOnly() {
-            return isReadOnly;
-        }
-
-        @Override
-        public boolean isFinal() {
-            return isFinal;
-        }
-
-        @Override
-        public int hashCode() {
-            final int prime = 31;
-            int result = 1;
-            result = prime * result + ((name == null) ? 0 : name.hashCode());
-            result = prime * result
-                    + ((parameters == null) ? 0 : parameters.hashCode());
-            result = prime * result
-                    + ((returnType == null) ? 0 : returnType.hashCode());
-            return result;
-        }
-
-        @Override
-        public boolean equals(Object obj) {
-            if (this == obj) {
-                return true;
-            }
-            if (obj == null) {
-                return false;
-            }
-            if (getClass() != obj.getClass()) {
-                return false;
-            }
-            GeneratedPropertyImpl other = (GeneratedPropertyImpl) obj;
-            if (name == null) {
-                if (other.name != null) {
-                    return false;
-                }
-            } else if (!name.equals(other.name)) {
-                return false;
-            }
-            if (parameters == null) {
-                if (other.parameters != null) {
-                    return false;
-                }
-            } else if (!parameters.equals(other.parameters)) {
-                return false;
-            }
-            if (returnType == null) {
-                if (other.returnType != null) {
-                    return false;
-                }
-            } else if (!returnType.getPackageName().equals(
-                    other.returnType.getPackageName())) {
-                return false;
-            } else if (!returnType.getName().equals(other.returnType.getName())) {
-                return false;
-            }
-            return true;
-        }
-
-        @Override
-        public String toString() {
-            StringBuilder builder = new StringBuilder();
-            builder.append("GeneratedPropertyImpl [name=");
-            builder.append(name);
-            builder.append(", annotations=");
-            builder.append(annotations);
-            builder.append(", comment=");
-            builder.append(comment);
-            if (parent != null) {
-                builder.append(", parent=");
-                builder.append(parent.getPackageName());
-                builder.append(".");
-                builder.append(parent.getName());
-            } else {
-                builder.append(", parent=null");
-            }
-            builder.append(", returnType=");
-            builder.append(returnType);
-            builder.append(", isFinal=");
-            builder.append(isFinal);
-            builder.append(", isReadOnly=");
-            builder.append(isReadOnly);
-            builder.append(", parameters=");
-            builder.append(parameters);
-            builder.append(", modifier=");
-            builder.append(modifier);
-            builder.append("]");
-            return builder.toString();
-        }
-    }
-
-    private static class GeneratedTransferObjectImpl implements
+        return new GeneratedTransferObjectImpl(null, getPackageName(), getName(), getComment(),
+                getAnnotations(), isAbstract(), extendsType, getImplementsTypes(), getEnclosedTypes(),
+                getEnclosedTransferObjects(), getConstants(), getEnumerations(), getMethodDefinitions(), properties,
+                equalsProperties, hashProperties, toStringProperties);
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder builder = new StringBuilder();
+        builder.append("GeneratedTransferObject [packageName=");
+        builder.append(getPackageName());
+        builder.append(", name=");
+        builder.append(getName());
+        builder.append(", comment=");
+        builder.append(getComment());
+        builder.append(", constants=");
+        builder.append(getConstants());
+        builder.append(", enumerations=");
+        builder.append(getEnumerations());
+        builder.append(", properties=");
+        builder.append(properties);
+        builder.append(", equalsProperties=");
+        builder.append(equalsProperties);
+        builder.append(", hashCodeProperties=");
+        builder.append(hashProperties);
+        builder.append(", stringProperties=");
+        builder.append(toStringProperties);
+        builder.append(", annotations=");
+        builder.append(getAnnotations());
+        builder.append(", methods=");
+        builder.append(getMethodDefinitions());
+        builder.append("]");
+        return builder.toString();
+    }
+
+    private static final class GeneratedTransferObjectImpl extends AbstractGeneratedType implements
             GeneratedTransferObject {
 
-        private final String packageName;
-        private final String name;
-        private final String comment;
-        private final List<Constant> constants;
-        private final List<Enumeration> enumerations;
         private final List<GeneratedProperty> properties;
         private final List<GeneratedProperty> equalsProperties;
         private final List<GeneratedProperty> hashCodeProperties;
         private final List<GeneratedProperty> stringProperties;
-        private final List<AnnotationType> annotations;
-        private final List<MethodSignature> methods;
         private final GeneratedTransferObject extendsType;
-        private final List<Type> implementsTypes;
 
-        public GeneratedTransferObjectImpl(final String packageName,
-                final String name, final String comment,
-                final List<AnnotationTypeBuilder> annotationBuilders,
-                final GeneratedTransferObject extendsType,
-                final List<Type> implementsTypes,
-                final List<ConstantBuilder> constantBuilders,
-                final List<EnumBuilder> enumBuilders,
-                final List<MethodSignatureBuilder> methodBuilders,
-                final List<GeneratedPropertyBuilder> propBuilers,
-                final List<GeneratedPropertyBuilder> equalsBuilers,
-                final List<GeneratedPropertyBuilder> hashCodeBuilers,
-                final List<GeneratedPropertyBuilder> stringBuilers) {
-            super();
-            this.packageName = packageName;
-            this.name = name;
-            this.comment = comment;
-            this.annotations = toUnmodifiableAnnotations(annotationBuilders);
+        GeneratedTransferObjectImpl(final Type parent,
+                    final String packageName,
+                                           final String name, final String comment,
+                                           final List<AnnotationTypeBuilder> annotationBuilders,
+                                           final boolean isAbstract,
+                                           final GeneratedTransferObject extendsType,
+                                           final List<Type> implementsTypes,
+                                           final List<GeneratedTypeBuilder> enclosedGenTypeBuilders,
+                                           final List<GeneratedTOBuilder> enclosedGenTOBuilders,
+                                           final List<Constant> constants,
+                                           final List<EnumBuilder> enumBuilders,
+                                           final List<MethodSignatureBuilder> methodBuilders,
+                                           final List<GeneratedPropertyBuilder> propBuilders,
+                                           final List<GeneratedPropertyBuilder> equalsBuilders,
+                                           final List<GeneratedPropertyBuilder> hashCodeBuilders,
+                                           final List<GeneratedPropertyBuilder> stringBuilders) {
+            super(parent, packageName, name, comment, annotationBuilders, isAbstract, implementsTypes,
+                    enclosedGenTypeBuilders,
+                    enclosedGenTOBuilders, enumBuilders, constants, methodBuilders);
             this.extendsType = extendsType;
-            this.implementsTypes = Collections
-                    .unmodifiableList(implementsTypes);
-            this.constants = toUnmodifiableConstant(constantBuilders);
-            this.enumerations = toUnmodifiableEnumerations(enumBuilders);
-            this.properties = toUnmodifiableProperties(propBuilers);
-            this.methods = toUnmodifiableMethods(methodBuilders);
-            this.equalsProperties = toUnmodifiableProperties(equalsBuilers);
-            this.hashCodeProperties = toUnmodifiableProperties(hashCodeBuilers);
-            this.stringProperties = toUnmodifiableProperties(stringBuilers);
-        }
-
-        private List<AnnotationType> toUnmodifiableAnnotations(
-                final List<AnnotationTypeBuilder> annotationBuilders) {
-            final List<AnnotationType> annotations = new ArrayList<AnnotationType>();
-            for (final AnnotationTypeBuilder builder : annotationBuilders) {
-                annotations.add(builder.toInstance());
-            }
-            return Collections.unmodifiableList(annotations);
-        }
-
-        private List<Enumeration> toUnmodifiableEnumerations(
-                final List<EnumBuilder> enumBuilders) {
-            final List<Enumeration> enumerations = new ArrayList<Enumeration>();
-            for (final EnumBuilder builder : enumBuilders) {
-                enumerations.add(builder.toInstance(this));
-            }
-            return Collections.unmodifiableList(enumerations);
-        }
-
-        private List<Constant> toUnmodifiableConstant(
-                final List<ConstantBuilder> constBuilders) {
-            final List<Constant> constants = new ArrayList<Constant>();
-            for (final ConstantBuilder builder : constBuilders) {
-                constants.add(builder.toInstance(this));
-            }
-            return Collections.unmodifiableList(constants);
-        }
-
-        private List<MethodSignature> toUnmodifiableMethods(
-                final List<MethodSignatureBuilder> methodBuilders) {
-            final List<MethodSignature> methods = new ArrayList<MethodSignature>();
-            for (final MethodSignatureBuilder builder : methodBuilders) {
-                methods.add(builder.toInstance(this));
-            }
-            return Collections.unmodifiableList(methods);
+            this.properties = toUnmodifiableProperties(propBuilders);
+            this.equalsProperties = toUnmodifiableProperties(equalsBuilders);
+            this.hashCodeProperties = toUnmodifiableProperties(hashCodeBuilders);
+            this.stringProperties = toUnmodifiableProperties(stringBuilders);
         }
 
         private List<GeneratedProperty> toUnmodifiableProperties(
                 final List<GeneratedPropertyBuilder> propBuilders) {
-            final List<GeneratedProperty> constants = new ArrayList<GeneratedProperty>();
+            final List<GeneratedProperty> properties = new ArrayList<>();
             for (final GeneratedPropertyBuilder builder : propBuilders) {
-                constants.add(builder.toInstance(this));
+                properties.add(builder.toInstance(this));
             }
-            return Collections.unmodifiableList(constants);
-        }
-
-        @Override
-        public String getPackageName() {
-            return packageName;
-        }
-
-        @Override
-        public String getName() {
-            return name;
-        }
-
-        @Override
-        public Type getParentType() {
-            return null;
-        }
-
-        @Override
-        public String getComment() {
-            return comment;
-        }
-
-        @Override
-        public List<AnnotationType> getAnnotations() {
-            return annotations;
-        }
-
-        @Override
-        public List<Type> getImplements() {
-            return implementsTypes;
+            return Collections.unmodifiableList(properties);
         }
 
         @Override
@@ -532,21 +165,6 @@ public class GeneratedTOBuilderImpl implements GeneratedTOBuilder {
             return extendsType;
         }
 
-        @Override
-        public List<Enumeration> getEnumDefintions() {
-            return enumerations;
-        }
-
-        @Override
-        public List<Constant> getConstantDefinitions() {
-            return constants;
-        }
-
-        @Override
-        public List<MethodSignature> getMethodDefinitions() {
-            return methods;
-        }
-
         @Override
         public List<GeneratedProperty> getProperties() {
             return properties;
@@ -567,58 +185,27 @@ public class GeneratedTOBuilderImpl implements GeneratedTOBuilder {
             return stringProperties;
         }
 
-        @Override
-        public int hashCode() {
-            final int prime = 31;
-            int result = 1;
-            result = prime * result + ((name == null) ? 0 : name.hashCode());
-            result = prime * result
-                    + ((packageName == null) ? 0 : packageName.hashCode());
-            return result;
-        }
-
-        @Override
-        public boolean equals(Object obj) {
-            if (this == obj) {
-                return true;
-            }
-            if (obj == null) {
-                return false;
-            }
-            if (getClass() != obj.getClass()) {
-                return false;
-            }
-            GeneratedTransferObjectImpl other = (GeneratedTransferObjectImpl) obj;
-            if (name == null) {
-                if (other.name != null) {
-                    return false;
-                }
-            } else if (!name.equals(other.name)) {
-                return false;
-            }
-            if (packageName == null) {
-                if (other.packageName != null) {
-                    return false;
-                }
-            } else if (!packageName.equals(other.packageName)) {
-                return false;
-            }
-            return true;
-        }
-
         @Override
         public String toString() {
             StringBuilder builder = new StringBuilder();
             builder.append("GeneratedTransferObject [packageName=");
-            builder.append(packageName);
+            builder.append(getPackageName());
             builder.append(", name=");
-            builder.append(name);
+            builder.append(getName());
             builder.append(", comment=");
-            builder.append(comment);
+            builder.append(", annotations=");
+            builder.append(getAnnotations());
+            builder.append(getComment());
+            builder.append(", extends=");
+            builder.append(getExtends());
+            builder.append(", implements=");
+            builder.append(getImplements());
+            builder.append(", enclosedTypes=");
+            builder.append(getEnclosedTypes());
             builder.append(", constants=");
-            builder.append(constants);
+            builder.append(getConstantDefinitions());
             builder.append(", enumerations=");
-            builder.append(enumerations);
+            builder.append(getEnumerations());
             builder.append(", properties=");
             builder.append(properties);
             builder.append(", equalsProperties=");
@@ -627,34 +214,10 @@ public class GeneratedTOBuilderImpl implements GeneratedTOBuilder {
             builder.append(hashCodeProperties);
             builder.append(", stringProperties=");
             builder.append(stringProperties);
-            builder.append(", annotations=");
-            builder.append(annotations);
             builder.append(", methods=");
-            builder.append(methods);
+            builder.append(getMethodDefinitions());
             builder.append("]");
             return builder.toString();
         }
     }
-
-    private static final class GeneratedTransferIdentityObjectImpl extends
-            GeneratedTransferObjectImpl implements
-            GeneratedTransferIdentityObject {
-        public GeneratedTransferIdentityObjectImpl(final String packageName,
-                final String name, final String comment,
-                final List<AnnotationTypeBuilder> annotationBuilders,
-                final GeneratedTransferObject extendsType,
-                final List<Type> implementsTypes,
-                final List<ConstantBuilder> constantBuilders,
-                final List<EnumBuilder> enumBuilders,
-                final List<MethodSignatureBuilder> methodBuilders,
-                final List<GeneratedPropertyBuilder> propBuilers,
-                final List<GeneratedPropertyBuilder> equalsBuilers,
-                final List<GeneratedPropertyBuilder> hashCodeBuilers,
-                final List<GeneratedPropertyBuilder> stringBuilers) {
-            super(packageName, name, comment, annotationBuilders, extendsType,
-                    implementsTypes, constantBuilders, enumBuilders,
-                    methodBuilders, propBuilers, equalsBuilers,
-                    hashCodeBuilers, stringBuilers);
-        }
-    }
 }
index 3a3ded39babc818b3abdf57008307399e3ac4780..a3ffbda4f55adc64d93dc505e6ed462b2cc253c1 100644 (file)
  */
 package org.opendaylight.controller.binding.generator.util.generated.type.builder;
 
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.opendaylight.controller.sal.binding.model.api.AnnotationType;
 import org.opendaylight.controller.sal.binding.model.api.Constant;
-import org.opendaylight.controller.sal.binding.model.api.Enumeration;
 import org.opendaylight.controller.sal.binding.model.api.GeneratedType;
-import org.opendaylight.controller.sal.binding.model.api.MethodSignature;
 import org.opendaylight.controller.sal.binding.model.api.Type;
-import org.opendaylight.controller.sal.binding.model.api.type.builder.AnnotationTypeBuilder;
-import org.opendaylight.controller.sal.binding.model.api.type.builder.ConstantBuilder;
-import org.opendaylight.controller.sal.binding.model.api.type.builder.EnumBuilder;
-import org.opendaylight.controller.sal.binding.model.api.type.builder.GeneratedTypeBuilder;
-import org.opendaylight.controller.sal.binding.model.api.type.builder.MethodSignatureBuilder;
-
-public final class GeneratedTypeBuilderImpl implements GeneratedTypeBuilder {
-
-    private final String packageName;
-    private String comment = "";
-    private final String name;
-    private final List<AnnotationTypeBuilder> annotationBuilders = new ArrayList<AnnotationTypeBuilder>();
-    private final List<Type> implementsTypes = new ArrayList<Type>();
-    private final List<EnumBuilder> enumDefinitions = new ArrayList<EnumBuilder>();
-    private final List<ConstantBuilder> constantDefintions = new ArrayList<ConstantBuilder>();
-    private final List<MethodSignatureBuilder> methodDefinitions = new ArrayList<MethodSignatureBuilder>();
-    
-    public GeneratedTypeBuilderImpl(final String packageName, final String name) {
-        this.packageName = packageName;
-        this.name = name;
-    }
-
-    @Override
-    public Type getParentType() {
-        return this;
-    }
-
-    @Override
-    public String getPackageName() {
-        return packageName;
-    }
-
-    @Override
-    public String getName() {
-        return name;
-    }
-
-    @Override
-    public void addComment(String comment) {
-        this.comment = comment;
-    }
+import org.opendaylight.controller.sal.binding.model.api.type.builder.*;
 
-    @Override
-    public AnnotationTypeBuilder addAnnotation(String packageName, String name) {
-        if (packageName != null && name != null) {
-            final AnnotationTypeBuilder builder = new AnnotationTypeBuilderImpl(
-                    packageName, name);
-            if (annotationBuilders.add(builder)) {
-                return builder;
-            }
-        }
-        return null;
-    }
+import java.util.List;
 
-    @Override
-    public ConstantBuilder addConstant(Type type, String name, Object value) {
-        final ConstantBuilder builder = new ConstantBuilderImpl(type, name,
-                value);
-        constantDefintions.add(builder);
-        return builder;
-    }
+public final class GeneratedTypeBuilderImpl extends AbstractGeneratedTypeBuilder {
 
-    @Override
-    public EnumBuilder addEnumeration(final String name) {
-        final String innerPackageName = packageName + "." + this.name;
-        final EnumBuilder builder = new EnumerationBuilderImpl(
-                innerPackageName, name);
-        enumDefinitions.add(builder);
-        return builder;
+    public GeneratedTypeBuilderImpl(String packageName, String name) {
+        super(packageName, name);
+        setAbstract(true);
     }
 
     @Override
-    public MethodSignatureBuilder addMethod(final String name) {
-        final MethodSignatureBuilder builder = new MethodSignatureBuilderImpl(
-                this, name);
-        methodDefinitions.add(builder);
-        return builder;
+    public GeneratedType toInstance() {
+        return new GeneratedTypeImpl(null, getPackageName(), getName(), getComment(), getAnnotations(), isAbstract(),
+                getImplementsTypes(), getEnclosedTypes(), getEnclosedTransferObjects(), getEnumerations(),
+                getConstants(), getMethodDefinitions());
     }
 
     @Override
-    public boolean addImplementsType(final Type genType) {
-        if (genType != null) {
-            return implementsTypes.add(genType);
-        }
-        return false;
+    public String toString() {
+        StringBuilder builder = new StringBuilder();
+        builder.append("GeneratedTransferObject [packageName=");
+        builder.append(getPackageName());
+        builder.append(", name=");
+        builder.append(getName());
+        builder.append(", comment=");
+        builder.append(", annotations=");
+        builder.append(getAnnotations());
+        builder.append(getComment());
+        builder.append(", implements=");
+        builder.append(getImplementsTypes());
+        builder.append(", enclosedTypes=");
+        builder.append(getEnclosedTypes());
+        builder.append(", constants=");
+        builder.append(getConstants());
+        builder.append(", enumerations=");
+        builder.append(getEnumerations());
+        builder.append(", properties=");
+        builder.append(", methods=");
+        builder.append(getMethodDefinitions());
+        builder.append("]");
+        return builder.toString();
     }
-    
-    @Override
-    public GeneratedType toInstance() {
-        return new GeneratedTypeImpl(this, packageName, name, comment,
-                annotationBuilders, implementsTypes, enumDefinitions, constantDefintions,
-                methodDefinitions);
-    }
-    
-    private static final class GeneratedTypeImpl implements GeneratedType {
-
-        private final Type parent;
-        private final String packageName;
-        private final String name;
-        private final String comment;
-        private final List<AnnotationType> annotations;
-        private final List<Type> implementsTypes;
-        private final List<Enumeration> enumDefinitions;
-        private final List<Constant> constantDefintions;
-        private final List<MethodSignature> methodDefinitions;
-
-        public GeneratedTypeImpl(final Type parent, final String packageName,
-                final String name, final String comment,
-                final List<AnnotationTypeBuilder> annotationBuilders,
-                final List<Type> implementsTypes,
-                final List<EnumBuilder> enumBuilders,
-                final List<ConstantBuilder> constantBuilders,
-                final List<MethodSignatureBuilder> methodBuilders) {
-            super();
-            this.parent = parent;
-            this.packageName = packageName;
-            this.name = name;
-            this.comment = comment;
-            this.annotations = toUnmodifiableAnnotations(annotationBuilders);
-            this.implementsTypes = Collections.unmodifiableList(implementsTypes); 
-            this.constantDefintions = toUnmodifiableConstants(constantBuilders);
-            this.enumDefinitions = toUnmodifiableEnums(enumBuilders);
-            this.methodDefinitions = toUnmodifiableMethods(methodBuilders);
-        }
-
-        private List<AnnotationType> toUnmodifiableAnnotations(
-                final List<AnnotationTypeBuilder> annotationBuilders) {
-            final List<AnnotationType> annotations = new ArrayList<AnnotationType>();
-            for (final AnnotationTypeBuilder builder : annotationBuilders) {
-                annotations.add(builder.toInstance());
-            }
-            return Collections.unmodifiableList(annotations);
-        }
-
-        private List<MethodSignature> toUnmodifiableMethods(
-                List<MethodSignatureBuilder> methodBuilders) {
-            final List<MethodSignature> methods = new ArrayList<MethodSignature>();
-            for (final MethodSignatureBuilder methodBuilder : methodBuilders) {
-                methods.add(methodBuilder.toInstance(this));
-            }
-            return Collections.unmodifiableList(methods);
-        }
-
-        private List<Enumeration> toUnmodifiableEnums(
-                List<EnumBuilder> enumBuilders) {
-            final List<Enumeration> enums = new ArrayList<Enumeration>();
-            for (final EnumBuilder enumBuilder : enumBuilders) {
-                enums.add(enumBuilder.toInstance(this));
-            }
-            return Collections.unmodifiableList(enums);
-        }
-
-        private List<Constant> toUnmodifiableConstants(
-                List<ConstantBuilder> constantBuilders) {
-            final List<Constant> constants = new ArrayList<Constant>();
-            for (final ConstantBuilder enumBuilder : constantBuilders) {
-                constants.add(enumBuilder.toInstance(this));
-            }
-            return Collections.unmodifiableList(constants);
-        }
-
-        @Override
-        public String getPackageName() {
-            return packageName;
-        }
-
-        @Override
-        public String getName() {
-            return name;
-        }
-
-        @Override
-        public Type getParentType() {
-            return parent;
-        }
-
-        @Override
-        public String getComment() {
-            return comment;
-        }
-
-        @Override
-        public List<AnnotationType> getAnnotations() {
-            return annotations;
-        }
-        
-        @Override
-        public List<Type> getImplements() {
-            return implementsTypes;
-        }
-        
-        @Override
-        public List<Enumeration> getEnumDefintions() {
-            return enumDefinitions;
-        }
-
-        @Override
-        public List<Constant> getConstantDefinitions() {
-            return constantDefintions;
-        }
-
-        @Override
-        public List<MethodSignature> getMethodDefinitions() {
-            return methodDefinitions;
-        }
-
-        @Override
-        public int hashCode() {
-            final int prime = 31;
-            int result = 1;
-            result = prime
-                    * result
-                    + ((constantDefintions == null) ? 0 : constantDefintions
-                            .hashCode());
-            result = prime
-                    * result
-                    + ((enumDefinitions == null) ? 0 : enumDefinitions
-                            .hashCode());
-            result = prime
-                    * result
-                    + ((methodDefinitions == null) ? 0 : methodDefinitions
-                            .hashCode());
-            result = prime * result + ((name == null) ? 0 : name.hashCode());
-            result = prime * result
-                    + ((packageName == null) ? 0 : packageName.hashCode());
-            return result;
-        }
-
-        @Override
-        public boolean equals(Object obj) {
-            if (this == obj) {
-                return true;
-            }
-            if (obj == null) {
-                return false;
-            }
-            if (getClass() != obj.getClass()) {
-                return false;
-            }
-            GeneratedTypeImpl other = (GeneratedTypeImpl) obj;
-            if (constantDefintions == null) {
-                if (other.constantDefintions != null) {
-                    return false;
-                }
-            } else if (!constantDefintions.equals(other.constantDefintions)) {
-                return false;
-            }
-            if (enumDefinitions == null) {
-                if (other.enumDefinitions != null) {
-                    return false;
-                }
-            } else if (!enumDefinitions.equals(other.enumDefinitions)) {
-                return false;
-            }
-            if (methodDefinitions == null) {
-                if (other.methodDefinitions != null) {
-                    return false;
-                }
-            } else if (!methodDefinitions.equals(other.methodDefinitions)) {
-                return false;
-            }
-            if (name == null) {
-                if (other.name != null) {
-                    return false;
-                }
-            } else if (!name.equals(other.name)) {
-                return false;
-            }
-            if (packageName == null) {
-                if (other.packageName != null) {
-                    return false;
-                }
-            } else if (!packageName.equals(other.packageName)) {
-                return false;
-            }
-            return true;
-        }
 
-        @Override
-        public String toString() {
-            StringBuilder builder = new StringBuilder();
-            builder.append("GeneratedType [packageName=");
-            builder.append(packageName);
-            builder.append(", name=");
-            builder.append(name);
-            if (parent != null) {
-                builder.append(", parent=");
-                builder.append(parent.getPackageName());
-                builder.append(".");
-                builder.append(parent.getName());
-            } else {
-                builder.append(", parent=null");
-            }
-            builder.append(", comment=");
-            builder.append(comment);
-            builder.append(", annotations=");
-            builder.append(annotations);
-            builder.append(", enumDefinitions=");
-            builder.append(enumDefinitions);
-            builder.append(", constantDefintions=");
-            builder.append(constantDefintions);
-            builder.append(", methodDefinitions=");
-            builder.append(methodDefinitions);
-            builder.append("]");
-            return builder.toString();
+    private static final class GeneratedTypeImpl extends AbstractGeneratedType {
+
+        public GeneratedTypeImpl(final Type parent, final String packageName, final String name, final String comment,
+                                 final List<AnnotationTypeBuilder> annotationBuilders, final boolean isAbstract,
+                                 final List<Type> implementsTypes,
+                                 final List<GeneratedTypeBuilder> enclosedGenTypeBuilders,
+                                 final List<GeneratedTOBuilder> enclosedGenTOBuilders,
+                                 final List<EnumBuilder> enumBuilders, final List<Constant> constants,
+                                 final List<MethodSignatureBuilder> methodBuilders) {
+            super(parent, packageName, name, comment, annotationBuilders, isAbstract, implementsTypes,
+                    enclosedGenTypeBuilders, enclosedGenTOBuilders, enumBuilders, constants, methodBuilders);
         }
     }
 }
index a2ce27c72a54e746094aac07059dac79eab1a6af..ebb68647bfe8d9206e27500494f08e95e26fec06 100644 (file)
@@ -1,49 +1,34 @@
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
 package org.opendaylight.controller.binding.generator.util.generated.type.builder;
 
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.List;
 
-import org.opendaylight.controller.sal.binding.model.api.AccessModifier;
 import org.opendaylight.controller.sal.binding.model.api.AnnotationType;
 import org.opendaylight.controller.sal.binding.model.api.MethodSignature;
 import org.opendaylight.controller.sal.binding.model.api.Type;
 import org.opendaylight.controller.sal.binding.model.api.type.builder.AnnotationTypeBuilder;
 import org.opendaylight.controller.sal.binding.model.api.type.builder.MethodSignatureBuilder;
 
-final class MethodSignatureBuilderImpl implements MethodSignatureBuilder {
-    private final String name;
-    private Type returnType;
+final class MethodSignatureBuilderImpl extends AbstractTypeMemberBuilder implements MethodSignatureBuilder {
+
     private final List<MethodSignature.Parameter> parameters;
-    private final List<AnnotationTypeBuilder> annotationBuilders;
-    private String comment = "";
-    private final Type parent;
+    private boolean isAbstract;
 
-    public MethodSignatureBuilderImpl(final Type parent, final String name) {
-        super();
-        this.name = name;
-        this.parent = parent;
-        this.parameters = new ArrayList<MethodSignature.Parameter>();
-        this.annotationBuilders = new ArrayList<AnnotationTypeBuilder>();
+    public MethodSignatureBuilderImpl(final String name) {
+        super(name);
+        this.parameters = new ArrayList<>();
     }
 
     @Override
-    public AnnotationTypeBuilder addAnnotation(String packageName, String name) {
-        if (packageName != null && name != null) {
-            final AnnotationTypeBuilder builder = new AnnotationTypeBuilderImpl(
-                    packageName, name);
-            if (annotationBuilders.add(builder)) {
-                return builder;
-            }
-        }
-        return null;
-    }
-
-    @Override
-    public void addReturnType(Type returnType) {
-        if (returnType != null) {
-            this.returnType = returnType;
-        }
+    public void setAbstract(boolean isAbstract) {
+        this.isAbstract = isAbstract;
     }
 
     @Override
@@ -51,26 +36,22 @@ final class MethodSignatureBuilderImpl implements MethodSignatureBuilder {
         parameters.add(new MethodParameterImpl(name, type));
     }
 
-    @Override
-    public void addComment(String comment) {
-        this.comment = comment;
-    }
-
     @Override
     public MethodSignature toInstance(Type definingType) {
-        return new MethodSignatureImpl(definingType, name, annotationBuilders,
-                comment, returnType, parameters);
+        final List<AnnotationType> annotations = toAnnotationTypes();
+        return new MethodSignatureImpl(definingType, getName(), annotations,
+                getComment(), getAccessModifier(), getReturnType(), parameters, isFinal(), isAbstract);
     }
     
     @Override
     public int hashCode() {
         final int prime = 31;
         int result = 1;
-        result = prime * result + ((name == null) ? 0 : name.hashCode());
+        result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
         result = prime * result
                 + ((parameters == null) ? 0 : parameters.hashCode());
         result = prime * result
-                + ((returnType == null) ? 0 : returnType.hashCode());
+                + ((getReturnType() == null) ? 0 : getReturnType().hashCode());
         return result;
     }
 
@@ -86,11 +67,11 @@ final class MethodSignatureBuilderImpl implements MethodSignatureBuilder {
             return false;
         }
         MethodSignatureBuilderImpl other = (MethodSignatureBuilderImpl) obj;
-        if (name == null) {
-            if (other.name != null) {
+        if (getName() == null) {
+            if (other.getName() != null) {
                 return false;
             }
-        } else if (!name.equals(other.name)) {
+        } else if (!getName().equals(other.getName())) {
             return false;
         }
         if (parameters == null) {
@@ -100,11 +81,11 @@ final class MethodSignatureBuilderImpl implements MethodSignatureBuilder {
         } else if (!parameters.equals(other.parameters)) {
             return false;
         }
-        if (returnType == null) {
-            if (other.returnType != null) {
+        if (getReturnType() == null) {
+            if (other.getReturnType() != null) {
                 return false;
             }
-        } else if (!returnType.equals(other.returnType)) {
+        } else if (!getReturnType().equals(other.getReturnType())) {
             return false;
         }
         return true;
@@ -114,160 +95,16 @@ final class MethodSignatureBuilderImpl implements MethodSignatureBuilder {
     public String toString() {
         StringBuilder builder = new StringBuilder();
         builder.append("MethodSignatureBuilderImpl [name=");
-        builder.append(name);
+        builder.append(getName());
         builder.append(", returnType=");
-        builder.append(returnType);
+        builder.append(getReturnType());
         builder.append(", parameters=");
         builder.append(parameters);
         builder.append(", annotationBuilders=");
-        builder.append(annotationBuilders);
+        builder.append(getAnnotationBuilders());
         builder.append(", comment=");
-        builder.append(comment);
-        if (parent != null) {
-            builder.append(", parent=");
-            builder.append(parent.getPackageName());
-            builder.append(".");
-            builder.append(parent.getName());
-        } else {
-            builder.append(", parent=null");
-        }
+        builder.append(getComment());
         builder.append("]");
         return builder.toString();
     }
-
-    private static final class MethodSignatureImpl implements MethodSignature {
-
-        private final String name;
-        private final String comment;
-        private final Type definingType;
-        private final Type returnType;
-        private final List<Parameter> params;
-        private List<AnnotationType> annotations;
-
-        public MethodSignatureImpl(final Type definingType, final String name,
-                final List<AnnotationTypeBuilder> annotationBuilders,
-                final String comment, final Type returnType,
-                final List<Parameter> params) {
-            super();
-            this.name = name;
-            this.comment = comment;
-            this.definingType = definingType;
-            this.returnType = returnType;
-            this.params = Collections.unmodifiableList(params);
-            
-            this.annotations = new ArrayList<AnnotationType>();
-            for (final AnnotationTypeBuilder builder : annotationBuilders) {
-                this.annotations.add(builder.toInstance());
-            }
-            this.annotations = Collections.unmodifiableList(this.annotations);
-        }
-
-        @Override
-        public List<AnnotationType> getAnnotations() {
-            return annotations;
-        }
-
-        @Override
-        public String getName() {
-            return name;
-        }
-
-        @Override
-        public String getComment() {
-            return comment;
-        }
-
-        @Override
-        public Type getDefiningType() {
-            return definingType;
-        }
-
-        @Override
-        public Type getReturnType() {
-            return returnType;
-        }
-
-        @Override
-        public List<Parameter> getParameters() {
-            return params;
-        }
-
-        @Override
-        public AccessModifier getAccessModifier() {
-            return AccessModifier.PUBLIC;
-        }
-
-        @Override
-        public int hashCode() {
-            final int prime = 31;
-            int result = 1;
-            result = prime * result + ((name == null) ? 0 : name.hashCode());
-            result = prime * result
-                    + ((params == null) ? 0 : params.hashCode());
-            result = prime * result
-                    + ((returnType == null) ? 0 : returnType.hashCode());
-            return result;
-        }
-
-        @Override
-        public boolean equals(Object obj) {
-            if (this == obj) {
-                return true;
-            }
-            if (obj == null) {
-                return false;
-            }
-            if (getClass() != obj.getClass()) {
-                return false;
-            }
-            MethodSignatureImpl other = (MethodSignatureImpl) obj;
-            if (name == null) {
-                if (other.name != null) {
-                    return false;
-                }
-            } else if (!name.equals(other.name)) {
-                return false;
-            }
-            if (params == null) {
-                if (other.params != null) {
-                    return false;
-                }
-            } else if (!params.equals(other.params)) {
-                return false;
-            }
-            if (returnType == null) {
-                if (other.returnType != null) {
-                    return false;
-                }
-            } else if (!returnType.equals(other.returnType)) {
-                return false;
-            }
-            return true;
-        }
-
-        @Override
-        public String toString() {
-            StringBuilder builder = new StringBuilder();
-            builder.append("MethodSignatureImpl [name=");
-            builder.append(name);
-            builder.append(", comment=");
-            builder.append(comment);
-            if (definingType != null) {
-                builder.append(", definingType=");
-                builder.append(definingType.getPackageName());
-                builder.append(".");
-                builder.append(definingType.getName());
-            } else {
-                builder.append(", definingType= null");
-            }
-            builder.append(", returnType=");
-            builder.append(returnType);
-            builder.append(", params=");
-            builder.append(params);
-            builder.append(", annotations=");
-            builder.append(annotations);
-            builder.append("]");
-            return builder.toString();
-        }
-    }
 }
\ No newline at end of file
diff --git a/opendaylight/sal/yang-prototype/code-generator/binding-generator-util/src/main/java/org/opendaylight/controller/binding/generator/util/generated/type/builder/MethodSignatureImpl.java b/opendaylight/sal/yang-prototype/code-generator/binding-generator-util/src/main/java/org/opendaylight/controller/binding/generator/util/generated/type/builder/MethodSignatureImpl.java
new file mode 100644 (file)
index 0000000..5be1cc9
--- /dev/null
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.binding.generator.util.generated.type.builder;
+
+import org.opendaylight.controller.sal.binding.model.api.AccessModifier;
+import org.opendaylight.controller.sal.binding.model.api.AnnotationType;
+import org.opendaylight.controller.sal.binding.model.api.MethodSignature;
+import org.opendaylight.controller.sal.binding.model.api.Type;
+
+import java.util.Collections;
+import java.util.List;
+
+class MethodSignatureImpl extends AbstractTypeMember implements MethodSignature {
+
+    private final List<Parameter> params;
+    private final boolean isAbstract;
+
+    public MethodSignatureImpl(final Type definingType, final String name,
+                               final List<AnnotationType> annotations,
+                               final String comment, final AccessModifier accessModifier,
+                               final Type returnType, final List<Parameter> params, boolean isFinal,
+                               boolean isAbstract) {
+        super(definingType, name, annotations, comment, accessModifier, returnType, isFinal);
+        this.params = Collections.unmodifiableList(params);
+        this.isAbstract = isAbstract;
+    }
+
+    @Override
+    public boolean isAbstract() {
+        return isAbstract;
+    }
+
+    @Override
+    public List<Parameter> getParameters() {
+        return params;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
+        result = prime * result
+                + ((params == null) ? 0 : params.hashCode());
+        result = prime * result
+                + ((getReturnType() == null) ? 0 : getReturnType().hashCode());
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null) {
+            return false;
+        }
+        if (getClass() != obj.getClass()) {
+            return false;
+        }
+        MethodSignatureImpl other = (MethodSignatureImpl) obj;
+        if (getName() == null) {
+            if (other.getName() != null) {
+                return false;
+            }
+        } else if (!getName().equals(other.getName())) {
+            return false;
+        }
+        if (params == null) {
+            if (other.params != null) {
+                return false;
+            }
+        } else if (!params.equals(other.params)) {
+            return false;
+        }
+        if (getReturnType() == null) {
+            if (other.getReturnType() != null) {
+                return false;
+            }
+        } else if (!getReturnType().equals(other.getReturnType())) {
+            return false;
+        }
+        return true;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder builder = new StringBuilder();
+        builder.append("MethodSignatureImpl [name=");
+        builder.append(getName());
+        builder.append(", comment=");
+        builder.append(getComment());
+        if (getDefiningType() != null) {
+            builder.append(", definingType=");
+            builder.append(getDefiningType().getPackageName());
+            builder.append(".");
+            builder.append(getDefiningType().getName());
+        } else {
+            builder.append(", definingType= null");
+        }
+        builder.append(", returnType=");
+        builder.append(getReturnType());
+        builder.append(", params=");
+        builder.append(params);
+        builder.append(", annotations=");
+        builder.append(getAnnotations());
+        builder.append("]");
+        return builder.toString();
+    }
+}
index 107dc5910bc2ea24a5d06ea17339cac9baf06c93..0f2daa86c38f290973fc1b24bcb283b95e26e605 100644 (file)
@@ -17,7 +17,6 @@ import java.util.List;
 
 import org.junit.Test;
 import org.opendaylight.controller.binding.generator.util.Types;
-import org.opendaylight.controller.binding.generator.util.generated.type.builder.GeneratedTOBuilderImpl;
 import org.opendaylight.controller.sal.binding.model.api.AnnotationType;
 import org.opendaylight.controller.sal.binding.model.api.GeneratedTransferObject;
 import org.opendaylight.controller.sal.binding.model.api.GeneratedType;
@@ -76,7 +75,7 @@ public class AnnotationBuilderTest {
 
         final MethodSignatureBuilder methodBuilder = genTypeBuilder
                 .addMethod("simpleMethod");
-        methodBuilder.addReturnType(Types.typeForClass(Integer.class));
+        methodBuilder.setReturnType(Types.typeForClass(Integer.class));
         final AnnotationTypeBuilder annotManAttr = methodBuilder
                 .addAnnotation("org.springframework.jmx.export.annotation",
                         "ManagedAttribute");
@@ -142,7 +141,7 @@ public class AnnotationBuilderTest {
 
         final GeneratedPropertyBuilder propertyBuilder = genTOBuilder
                 .addProperty("simpleProperty");
-        propertyBuilder.addReturnType(Types.typeForClass(Integer.class));
+        propertyBuilder.setReturnType(Types.typeForClass(Integer.class));
         final AnnotationTypeBuilder annotManAttr = propertyBuilder
                 .addAnnotation("org.springframework.jmx.export.annotation",
                         "ManagedAttribute");
index aaeec40604a61c264afef7d23e5f7111b115a1ef..877bcfce630113940aadbc238fd2b7700f02911c 100644 (file)
@@ -30,7 +30,6 @@ public final class ClassCodeGenerator implements CodeGenerator {
     @Override
     public Writer generate(Type type) throws IOException {
         final Writer writer = new StringWriter();
-        boolean isIdentity = type instanceof GeneratedTransferIdentityObject;
 
         if (type instanceof GeneratedTransferObject) {
             GeneratedTransferObject genTO = (GeneratedTransferObject) type;            
@@ -38,7 +37,7 @@ public final class ClassCodeGenerator implements CodeGenerator {
             
             final String currentPkg = genTO.getPackageName();
             final List<GeneratedProperty> fields = genTO.getProperties();
-            final List<Enumeration> enums = genTO.getEnumDefintions();
+            final List<Enumeration> enums = genTO.getEnumerations();
 
             writer.write(GeneratorUtil.createPackageDeclaration(currentPkg));
             writer.write(NL);
@@ -50,7 +49,7 @@ public final class ClassCodeGenerator implements CodeGenerator {
             writer.write(NL);
 
             writer.write(GeneratorUtil.createClassDeclaration(genTO, "",
-                    imports, isIdentity));
+                    imports, genTO.isAbstract()));
             writer.write(NL);
             writer.write(NL);
             
@@ -69,7 +68,7 @@ public final class ClassCodeGenerator implements CodeGenerator {
                 }
                 writer.write(NL);
                 writer.write(GeneratorUtil.createConstructor(genTO, TAB,
-                        imports, isIdentity) + NL);
+                        imports, genTO.isAbstract()) + NL);
                 writer.write(NL);
                 for (GeneratedProperty field : fields) {
                     writer.write(GeneratorUtil.createGetter(field, TAB,
index 5b3b17dbf6c73334fe471dd3e797f8a18e228749..804ac99ff26138d1e36d18c6dbbd99755fc1b946 100644 (file)
@@ -622,7 +622,7 @@ public final class GeneratorUtil {
         final String genTypePkg = genType.getPackageName();
 
         final List<Constant> constants = genType.getConstantDefinitions();
-        final List<MethodSignature> methods = genType.getMethodDefinitions();
+               final List<MethodSignature> methods = genType.getMethodDefinitions();
         List<Type> impl = genType.getImplements();
 
         // IMPLEMENTATIONS
index 38d3bcdc070dd4522a7c9d28ef28e2721bd10561..16d63efe1b527fe48d7da11cb468ab4bda54da7d 100644 (file)
@@ -82,7 +82,7 @@ public final class InterfaceGenerator implements CodeGenerator {
                        final List<Constant> constants = genType.getConstantDefinitions();
                        final List<MethodSignature> methods = genType
                                        .getMethodDefinitions();
-                       final List<Enumeration> enums = genType.getEnumDefintions();
+                       final List<Enumeration> enums = genType.getEnumerations();
 
                        writer.write(GeneratorUtil.createPackageDeclaration(genType
                                        .getPackageName()));
@@ -105,5 +105,4 @@ public final class InterfaceGenerator implements CodeGenerator {
                }
                return writer;
        }
-
 }
index 5dd011be32afe6849716b6279d0facd12673101a..8916131a3fe5bf5944a7598e826be249a6b02130 100644 (file)
@@ -110,11 +110,11 @@ public class ClassCodeGeneratorTest {
                 "simple.pack", "DefCtor");
 
         GeneratedPropertyBuilder propBuilder = toBuilder.addProperty("foo");
-        propBuilder.addReturnType(Types.typeForClass(String.class));
+        propBuilder.setReturnType(Types.typeForClass(String.class));
         propBuilder.setReadOnly(false);
 
         propBuilder = toBuilder.addProperty("bar");
-        propBuilder.addReturnType(Types.typeForClass(Integer.class));
+        propBuilder.setReturnType(Types.typeForClass(Integer.class));
         propBuilder.setReadOnly(false);
 
         final GeneratedTransferObject genTO = toBuilder.toInstance();
@@ -141,12 +141,12 @@ public class ClassCodeGeneratorTest {
                 "simple.pack", "DefCtor");
 
         GeneratedPropertyBuilder propBuilder = toBuilder.addProperty("foo");
-        propBuilder.addReturnType(Types.typeForClass(String.class));
+        propBuilder.setReturnType(Types.typeForClass(String.class));
         propBuilder.setReadOnly(false);
         toBuilder.addToStringProperty(propBuilder);
 
         propBuilder = toBuilder.addProperty("bar");
-        propBuilder.addReturnType(Types.typeForClass(Integer.class));
+        propBuilder.setReturnType(Types.typeForClass(Integer.class));
         propBuilder.setReadOnly(false);
         toBuilder.addToStringProperty(propBuilder);
         final GeneratedTransferObject genTO = toBuilder.toInstance();
index 5096dd88f8837e82e5b9f31155ad29022fdc0d30..52529e254e79a1648e72952be3bb89ee485d06c5 100644 (file)
@@ -7,6 +7,10 @@
  */\r
 package org.opendaylight.controller.sal.binding.model.api;\r
 \r
+/**\r
+ * Enum definition which provides four access modifiers that are described\r
+ * in Java programming language (Default, Private, Protected, Public).\r
+ */\r
 public enum AccessModifier {\r
-    PRIVATE, PUBLIC, PROTECTED\r
+    DEFAULT, PRIVATE, PUBLIC, PROTECTED\r
 }\r
index 7868675b1e6a40a21d6e14964a0ed218562a8a49..eec0339d0f17f32bfb03308b599fc7635614e02d 100644 (file)
@@ -9,25 +9,94 @@ package org.opendaylight.controller.sal.binding.model.api;
 
 import java.util.List;
 
-
+/**
+ * The Annotation Type interface is designed to hold information about
+ * annotation for any type that could be annotated in Java.
+ * <br>
+ * For sake of simplicity the Annotation Type is not designed to model exact
+ * behaviour of annotation mechanism, but just to hold information needed to
+ * model annotation over java Type definition.
+ */
 public interface AnnotationType extends Type {
-    
+
+    /**
+     * Returns the List of Annotations.
+     * <br>
+     * Each Annotation Type MAY have defined multiple Annotations.
+     *
+     * @return the List of Annotations.
+     */
     public List<AnnotationType> getAnnotations();
-    
+
+    /**
+     * Returns Parameter Definition assigned for given parameter name.
+     * <br>
+     * If Annotation does not contain parameter with specified param name,
+     * the method MAY return <code>null</code> value.
+     *
+     * @param paramName Parameter Name
+     * @return Parameter Definition assigned for given parameter name.
+     */
     public Parameter getParameter(final String paramName);
-    
+
+    /**
+     * Returns List of all parameters assigned to Annotation Type.
+     *
+     * @return List of all parameters assigned to Annotation Type.
+     */
     public List<Parameter> getParameters();
-    
+
+    /**
+     * Returns List of parameter names.
+     *
+     * @return List of parameter names.
+     */
     public List<String> getParameterNames();
-    
+
+    /**
+     * Returns <code>true</code> if annotation contains parameters.
+     *
+     * @return <code>true</code> if annotation contains parameters.
+     */
     public boolean containsParameters();
-    
+
+    /**
+     * Annotation Type parameter interface. For simplicity the Parameter
+     * contains values and value types as Strings. Every annotation which
+     * contains parameters could contain either single parameter or array of
+     * parameters. To model this purposes the by contract if the parameter
+     * contains single parameter the {@link #getValues()} method will return
+     * empty List and {@link #getValue()} MUST always return non-<code>null</code>
+     * parameter. If the Parameter holds List of values the singular {@link
+     * #getValue()} parameter MAY return <code>null</code> value.
+     */
     interface Parameter {
-        
+
+        /**
+         * Returns the Name of the parameter.
+         *
+         * @return the Name of the parameter.
+         */
         public String getName();
-        
+
+        /**
+         * Returns value in String format if Parameter contains singular value,
+         * otherwise MAY return <code>null</code>.
+         *
+         * @return value in String format if Parameter contains singular value.
+         */
         public String getValue();
-        
+
+        /**
+         * Returns List of Parameter assigned values in order in which they
+         * were assigned for given parameter name.
+         * <br>
+         * If there are multiple values assigned for given parameter name the
+         * method MUST NOT return empty List.
+         *
+         * @return List of Parameter assigned values in order in which they
+         * were assigned for given parameter name.
+         */
         public List<String> getValues();
     }
 }
index abde0da5e743a46d356de7738b4147038cfbc72b..092efc066b0fea703f8f32b026a262e812a592ca 100644 (file)
@@ -10,8 +10,18 @@ package org.opendaylight.controller.sal.binding.model.api;
 import java.io.IOException;\r
 import java.io.Writer;\r
 \r
+/**\r
+ *\r
+ *\r
+ */\r
 public interface CodeGenerator {\r
 \r
+    /**\r
+     *\r
+     * @param type\r
+     * @return\r
+     * @throws IOException\r
+     */\r
     Writer generate(Type type) throws IOException;\r
 \r
 }\r
index cad3460913d3d178759936dd67a9ea6c29a445e9..921a4733410a0a32e93de193f24245abeaa82682 100644 (file)
@@ -7,15 +7,61 @@
  */\r
 package org.opendaylight.controller.sal.binding.model.api;\r
 \r
+/**\r
+ * Interface Contact is designed to hold and model java constant. In Java\r
+ * there are no constant keywords instead of the constant is defined as\r
+ * static final field with assigned value. For this purpose the Constant\r
+ * interface contains methods {@link #getType()} to provide wrapped return\r
+ * Type of Constant, {@link #getName()} the Name of constant and the {@link\r
+ * #getValue()} for providing of value assigned to Constant. To determine of\r
+ * which type the constant value is it is recommended firstly to retrieve\r
+ * Type from constant. The Type interface holds base information like java\r
+ * package name and java type name (e.g. fully qualified name). From this\r
+ * string user should be able to determine to which type can be {@link\r
+ * #getValue()} type typecasted to unbox and provide value assigned to\r
+ * constant.\r
+ */\r
 public interface Constant {\r
 \r
+    /**\r
+     * Returns the Type that declares constant.\r
+     *\r
+     * @return the Type that declares constant.\r
+     */\r
     public Type getDefiningType();\r
 \r
+    /**\r
+     * Returns the return Type (or just Type) of the Constant.\r
+     *\r
+     * @return the return Type (or just Type) of the Constant.\r
+     */\r
     public Type getType();\r
 \r
+    /**\r
+     * Returns the name of constant.\r
+     * <br>\r
+     * By conventions the name SHOULD be in CAPITALS separated with\r
+     * underscores.\r
+     *\r
+     * @return the name of constant.\r
+     */\r
     public String getName();\r
 \r
+    /**\r
+     * Returns boxed value that is assigned for context.\r
+     *\r
+     * @return boxed value that is assigned for context.\r
+     */\r
     public Object getValue();\r
 \r
+    /**\r
+     * Returns Constant definition in formatted string.\r
+     * <br>\r
+     * <br>\r
+     * The expected string SHOULD be in format: <code>public final\r
+     * static [Type] CONSTANT_NAME = [value];</code>\r
+     *\r
+     * @return Constant definition in formatted string.\r
+     */\r
     public String toFormattedString();\r
 }\r
index 996423bb1bf67e35a7396a25b89a26fa90ed6f19..4115424ac835624014e9f2fd75c6ff0a971b580a 100644 (file)
@@ -9,16 +9,38 @@ package org.opendaylight.controller.sal.binding.model.api;
 
 import java.util.List;
 
+/**
+ *
+ */
 public interface Enumeration extends Type {
-    
+
+    /**
+     *
+     * @return
+     */
     public List<AnnotationType> getAnnotations();
-    
+
+    /**
+     *
+     * @return
+     */
     public Type getDefiningType();
 
+    /**
+     *
+     * @return
+     */
     public List<Pair> getValues();
 
+    /**
+     *
+     * @return
+     */
     public String toFormattedString();
 
+    /**
+     *
+     */
     interface Pair {
 
         public String getName();
index 462e1e1f63c5050b077c7fd13bdd673b2f498be0..119823d7a4054ba39845be4487e2d85b07b5dea3 100644 (file)
@@ -7,9 +7,24 @@
  */\r
 package org.opendaylight.controller.sal.binding.model.api;\r
 \r
-public interface GeneratedProperty extends MethodSignature {\r
+/**\r
+ * Generated Property extends interface {@link MethodSignature} interface.\r
+ * <br>\r
+ * The Generated Property interface is designed to store information of\r
+ * fields (or members) declared in Java Transfer Objects (or any java\r
+ * classes) and their access counterparts (getters and setters).\r
+ *\r
+ * @see MethodSignature\r
+ */\r
+public interface GeneratedProperty extends TypeMember {\r
 \r
+    /**\r
+     * Returns <code>true</code> if the property si declared as read-only.\r
+     * <br>\r
+     * If the property has flag <code>isReadOnly == true</code> the property\r
+     * SHOULD be generated as getter only.\r
+     *\r
+     * @return <code>true</code> if the property si declared as read-only.\r
+     */\r
     public boolean isReadOnly();\r
-\r
-    public boolean isFinal();\r
 }\r
index 6fa551e82122095cdcc86d06d756b2526c011ee6..e92dc77eee2a4f669679ab36e484ec7fefd9b3f2 100644 (file)
@@ -9,15 +9,64 @@ package org.opendaylight.controller.sal.binding.model.api;
 
 import java.util.List;
 
+/**
+ * Generated Transfer Object extends {@link GeneratedType} and is designed to
+ * represent Java Class. The Generated Transfer Object contains declarations
+ * of member fields stored in List of Properties. The Generated Transfer
+ * Object can be extended by exactly ONE Generated Transfer Object as Java
+ * don't allow multiple inheritance. For retrieval of implementing Generated
+ * Types use {@link #getImplements()} method.
+ * <br>
+ * Every transfer object SHOULD contain equals, hashCode and toString definitions.
+ * For this purpose retrieve definitions through {@link #getEqualsIdentifiers
+ * ()}, {@link #getHashCodeIdentifiers()} and {@link #getToStringIdentifiers
+ * ()}.
+ *
+ */
 public interface GeneratedTransferObject extends GeneratedType {
-    
+
+    /**
+     * Returns the extending Generated Transfer Object or <code>null</code>
+     * if there is no extending Generated Transfer Object.
+     *
+     * @return the extending Generated Transfer Object or <code>null</code>
+     * if there is no extending Generated Transfer Object.
+     */
     public GeneratedTransferObject getExtends();
-    
+
+    /**
+     * Returns List of Properties that are declared for Generated Transfer
+     * Object.
+     *
+     * @return List of Properties that are declared for Generated Transfer
+     * Object.
+     */
     public List<GeneratedProperty> getProperties();
-    
+
+    /**
+     * Returns List of Properties that are designated to define equality for
+     * Generated Transfer Object.
+     *
+     * @return List of Properties that are designated to define equality for
+     * Generated Transfer Object.
+     */
     public List<GeneratedProperty> getEqualsIdentifiers();
-    
+
+    /**
+     * Returns List of Properties that are designated to define identity for
+     * Generated Transfer Object.
+     *
+     * @return List of Properties that are designated to define identity for
+     * Generated Transfer Object.
+     */
     public List<GeneratedProperty> getHashCodeIdentifiers();
-    
+
+    /**
+     * Returns List of Properties that will be members of toString definition
+     * for Generated Transfer Object.
+     *
+     * @return List of Properties that will be members of toString definition
+     * for Generated Transfer Object.
+     */
     public List<GeneratedProperty> getToStringIdentifiers();
 }
index 82d1720714eaeee707a7ebf8b7fe2e809decb653..7a1a8f4f27d948ec5428445e0c61cc5fdfc1bc33 100644 (file)
@@ -16,6 +16,12 @@ import java.util.List;
  * <li><code>interface</code> name (with commentary that <b>SHOULD</b> be
  * present to proper define interface and base <i>contracts</i> specified for
  * interface)</li>
+ * <li>Each Generated Type can define list of types that Generated Type
+ * can implement to extend it's definition (i.e. interface extends list of
+ * interfaces or java class implements list of interfaces)</li>
+ * <li>Each Generated Type can contain multiple enclosed definitions of
+ * Generated Types (i.e. interface can contain N enclosed interface
+ * definitions or enclosed classes)</li>
  * <li><code>enum</code> and <code>constant</code> definitions (i.e. each
  * constant definition is by default defined as <code>public static final</code>
  * + type (either primitive or object) and constant name</li>
@@ -23,40 +29,76 @@ import java.util.List;
  * types) and return values</li>
  * </ul>
  * 
- * By the definition of the interface constant, enum and method definitions MUST
+ * By the definition of the interface constant, enum,
+ * enclosed types and method definitions MUST
  * be public, so there is no need to specify the scope of visibility.
- * 
- * 
  */
 public interface GeneratedType extends Type {
 
+    /**
+     * Returns the parent type if Generated Type is defined as enclosing type,
+     * otherwise returns <code>null</code>
+     *
+     * @return the parent type if Generated Type is defined as enclosing type,
+     * otherwise returns <code>null</code>
+     */
     public Type getParentType();
-    
+
+    /**
+     * Returns comment string associated with Generated Type.
+     *
+     * @return comment string associated with Generated Type.
+     */
     public String getComment();
-    
+
+    /**
+     * Returns List of annotation definitions associated with generated type.
+     *
+     * @return List of annotation definitions associated with generated type.
+     */
     public List<AnnotationType> getAnnotations();
-    
+
+    /**
+     * Returns <code>true</code> if The Generated Type is defined as abstract.
+     *
+     * @return <code>true</code> if The Generated Type is defined as abstract.
+     */
+    public boolean isAbstract();
+
+    /**
+     * Returns List of Types that Generated Type will implement.
+     *
+     * @return List of Types that Generated Type will implement.
+     */
     public List<Type> getImplements();
-    
+
     /**
-     * Returns Set of all Enumerator definitions associated with interface.
-     * 
-     * @return Set of all Enumerator definitions associated with interface.
+     * Returns List of enclosing Generated Types.
+     *
+     * @return List of enclosing Generated Types.
      */
-    public List<Enumeration> getEnumDefintions();
+    public List<GeneratedType> getEnclosedTypes();
 
     /**
+     * Returns List of all Enumerator definitions associated with Generated
+     * Type.
      * 
-     * 
-     * @return
+     * @return List of all Enumerator definitions associated with Generated
+     * Type.
+     */
+    public List<Enumeration> getEnumerations();
+
+    /**
+     * Returns List of Constant definitions associated with Generated Type.
+     *
+     * @return List of Constant definitions associated with Generated Type.
      */
     public List<Constant> getConstantDefinitions();
 
     /**
+     * Returns List of Method Definitions associated with Generated Type.
      * 
-     * 
-     * @return
+     * @return List of Method Definitions associated with Generated Type.
      */
     public List<MethodSignature> getMethodDefinitions();
-
 }
index dda1f01291c17ab5bb5e4572f09c25f6ffaa107c..88542e86f2c9f714f8f02a8f97bfe1366edc9338 100644 (file)
@@ -9,25 +9,62 @@ package org.opendaylight.controller.sal.binding.model.api;
 
 import java.util.List;
 
-public interface MethodSignature {
-    
-    public List<AnnotationType> getAnnotations();
-    
-    public String getName();
-
-    public String getComment();
-
-    public Type getDefiningType();
+/**
+ * The Method Signature interface contains simplified meta model for java
+ * method definition. Each method MUST be defined by name, return type,
+ * parameters and access modifier.
+ * <br>
+ * Additionally method MAY contain associated annotations and comment. By
+ * contract if method does not contain any comments or annotation definitions
+ * the {@link #getComment()} SHOULD rather return empty string and {@link
+ * #getAnnotations()} SHOULD rather return empty list than <code>null</code>
+ * values.
+ * <br>
+ * The defining Type contains the reference to Generated Type that declares
+ * Method Signature.
+ */
+public interface MethodSignature extends TypeMember {
 
-    public Type getReturnType();
+    /**
+     * Returns <code>true</code> if the method signature is defined as abstract.
+     * <br>
+     * By default in java all method declarations in interface are defined as abstract,
+     * but the user don't need necessary to declare abstract keyword in front of each method.
+     * <br>
+     * The abstract methods are allowed in Class definitions but only when the class is declared as abstract.
+     *
+     * @return <code>true</code> if the method signature is defined as abstract.
+     */
+    public boolean isAbstract();
 
+    /**
+     * Returns the List of parameters that method declare. If the method does
+     * not contain any parameters, the method will return empty List.
+     *
+     * @return the List of parameters that method declare.
+     */
     public List<Parameter> getParameters();
 
-    public AccessModifier getAccessModifier();
-
+    /**
+     * The Parameter interface is designed to hold the information of method
+     * Parameter(s). The parameter is defined by his Name which MUST be
+     * unique as java does not allow multiple parameters with same names for
+     * one method and Type that is associated with parameter.
+     */
     interface Parameter {
+
+        /**
+         * Returns the parameter name.
+         *
+         * @return the parameter name.
+         */
         public String getName();
 
+        /**
+         * Returns Type that is bounded to parameter name.
+         *
+         * @return Type that is bounded to parameter name.
+         */
         public Type getType();
     }
 }
index 1e800acaa926cc30842e460609042af9edf03c7e..86c4f5af04ccb6bd9e13ba95bddf301aca60a56f 100644 (file)
@@ -9,10 +9,29 @@ package org.opendaylight.controller.sal.binding.model.api;
 \r
 /**\r
  * Represents an instance of simple parametrized type such as List<String>.\r
+ *\r
+ * The parametrized Type is designed to be used to store information of Java\r
+ * Generic Type. The array of {@link #getActualTypeArguments()} holds\r
+ * information of all generic parameters defined for Parameterized Type.\r
  */\r
 public interface ParameterizedType extends Type {\r
 \r
+    /**\r
+     * Returns array of Types that are defined for Parameterized Type.\r
+     * <br>\r
+     * (for example if ParameterizedType encapsulates java generic Map that\r
+     * specifies two parameters Map<K,V> and the K is java.lang.Integer and V\r
+     * is defined as GeneratedType the array will contain two Types to store\r
+     * the information of generic parameters.)\r
+     *\r
+     * @return array of Types that are defined for Parameterized Type.\r
+     */\r
     Type[] getActualTypeArguments();\r
 \r
+    /**\r
+     * Returns the Raw Type definition of Parameterized Type.\r
+     *\r
+     * @return the Raw Type definition of Parameterized Type.\r
+     */\r
     Type getRawType();\r
 }\r
index 1ec3c9fab2e06da547a256f840846f03be87896e..c564ab46e4740a42150627d59bef7a63386d5f9a 100644 (file)
@@ -7,6 +7,13 @@
  */\r
 package org.opendaylight.controller.sal.binding.model.api;\r
 \r
+/**\r
+ * The Type interface defines the base type for all types defined in java.\r
+ * Each Type defined in java MUST contain name and package name,\r
+ * except of primitive types like int, byte etc. In case of mapping of\r
+ * primitive type the package name MUST be left as empty string.\r
+ *\r
+ */\r
 public interface Type {\r
     /**\r
      * Returns name of the package that interface belongs to.\r
@@ -21,4 +28,19 @@ public interface Type {
      * @return name of the interface.\r
      */\r
     public String getName();\r
+\r
+    /**\r
+     * Returns fully qualified name of Type.\r
+     * <br>\r
+     * The fully qualified name of Type MUST be returned in following format:\r
+     * <ul>\r
+     *     <li>If does not contains package name: [type name] (e.g. int, byte,\r
+     *     byte[],...)</li>\r
+     *     <li>If Type contains package name: [package name].[type name]\r
+     *     (e.g java.lang.Byte, org.opendaylight.controller.gen.GenType)</li>\r
+     * </ul>\r
+     *\r
+     * @return fully qualified name of Type.\r
+     */\r
+    public String getFullyQualifiedName();\r
 }\r
diff --git a/opendaylight/sal/yang-prototype/code-generator/binding-model-api/src/main/java/org/opendaylight/controller/sal/binding/model/api/TypeMember.java b/opendaylight/sal/yang-prototype/code-generator/binding-model-api/src/main/java/org/opendaylight/controller/sal/binding/model/api/TypeMember.java
new file mode 100644 (file)
index 0000000..e2176ff
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.sal.binding.model.api;
+
+import java.util.List;
+
+public interface TypeMember {
+
+    /**
+     * Returns List of annotation definitions associated with generated type.
+     *
+     * @return List of annotation definitions associated with generated type.
+     */
+    public List<AnnotationType> getAnnotations();
+
+    /**
+     * Returns the name of method.
+     *
+     * @return the name of method.
+     */
+    public String getName();
+
+    /**
+     * Returns comment string associated with method.
+     *
+     * @return comment string associated with method.
+     */
+    public String getComment();
+
+    /**
+     * Returns the Type that declares method.
+     *
+     * @return the Type that declares method.
+     */
+    public Type getDefiningType();
+
+    /**
+     * Returns the access modifier of method.
+     *
+     * @return the access modifier of method.
+     */
+    public AccessModifier getAccessModifier();
+
+    /**
+     * Returns the returning Type that methods returns.
+     *
+     * @return the returning Type that methods returns.
+     */
+    public Type getReturnType();
+
+    /**
+     * Returns <code>true</code> if method is declared as final.
+     *
+     * @return <code>true</code> if method is declared as final.
+     */
+    public boolean isFinal();
+}
index 6016274260f69aa8932be1ddc0815766bc862ac4..543c47b55d04a1bd33c0130a4ab6942f91688b1e 100644 (file)
@@ -12,13 +12,83 @@ import java.util.List;
 import org.opendaylight.controller.sal.binding.model.api.AnnotationType;
 import org.opendaylight.controller.sal.binding.model.api.Type;
 
+/**
+ * Annotation Type Builder Interface serves for creation and instantiation of
+ * immutable copy of Annotation Type. The Annotation Type Builder extends
+ * from {@link Type} interface. The Annotation Type contains set of methods
+ * which are capable to provide information about other Annotation Types and
+ * Annotation Parameters.
+ *
+ * @see AnnotationType
+ */
 public interface AnnotationTypeBuilder extends Type {
-    
+
+    /**
+     * The method creates new AnnotationTypeBuilder containing specified
+     * package name an annotation name.
+     * <br>
+     * Neither the package name or annotation name can contain
+     * <code>null</code> references. In case that
+     * any of parameters contains <code>null</code> the method SHOULD thrown
+     * {@link IllegalArgumentException}
+     *
+     * @param packageName Package Name of Annotation Type
+     * @param name Name of Annotation Type
+     * @return <code>new</code> instance of Annotation Type Builder.
+     */
     public AnnotationTypeBuilder addAnnotation(final String packageName, final String name);
-    
+
+    /**
+     * Adds the parameter into List of parameters for Annotation Type.
+     * <br>
+     * If there is already stored parameter with the same name as the new
+     * parameter, the value of the old one will be simply overwritten by the
+     * newer parameter.
+     * <br>
+     * Neither the param name or value can contain
+     * <code>null</code> references. In case that
+     * any of parameters contains <code>null</code> the method SHOULD thrown
+     * {@link IllegalArgumentException}
+     *
+     * @param paramName Parameter Name
+     * @param value Parameter Value
+     * @return <code>true</code> if the parameter has been successfully
+     * assigned for Annotation Type
+     */
     public boolean addParameter(final String paramName, String value);
-    
+
+    /**
+     * Adds the parameter with specified List of parameter values into List of
+     * parameters for Annotation Type.
+     * <br>
+     * If there is already stored parameter with the same name as the new
+     * parameter, the value of the old one will be simply overwritten by the
+     * newer parameter.
+     * <br>
+     * Neither the param name or value can contain
+     * <code>null</code> references. In case that
+     * any of parameters contains <code>null</code> the method SHOULD thrown
+     * {@link IllegalArgumentException}
+     *
+     * @param paramName Parameter Name
+     * @param values List of Values bounded to Parameter Name
+     * @return <code>true</code> if the parameter has been successfully
+     * assigned for Annotation Type
+     */
     public boolean addParameters(final String paramName, List<String> values);
-    
+
+    /**
+     * Returns <code>new</code> <i>immutable</i> instance of Annotation Type
+     * with values assigned in current instance of Annotation Type Builder.
+     * <br>
+     * The return Annotation Type instance is immutable thus no additional
+     * modification to Annotation Type Builder will have an impact to
+     * instantiated Annotation Type.
+     * <br>
+     * For this purpose call this method after
+     * all additions are complete.
+     *
+     * @return <code>new</code> <i>immutable</i> instance of Annotation Type.
+     */
     public AnnotationType toInstance();
 }
index 9716c6053e40a88c9bb7019e36536ae4d874b4d6..5f3d84c1d622734c21d64aa04b20b798224a2f27 100644 (file)
@@ -11,14 +11,39 @@ import org.opendaylight.controller.sal.binding.model.api.Enumeration;
 import org.opendaylight.controller.sal.binding.model.api.Type;
 
 /**
-
+ * Enum Builder is interface that contains methods to build and instantiate
+ * Enumeration definition.
  *
+ * @see Enumeration
  */
 public interface EnumBuilder extends Type {
-    
+
+    /**
+     * The method creates new AnnotationTypeBuilder containing specified
+     * package name an annotation name.
+     * <br>
+     * Neither the package name or annotation name can contain
+     * <code>null</code> references. In case that
+     * any of parameters contains <code>null</code> the method SHOULD thrown
+     * {@link IllegalArgumentException}
+     *
+     * @param packageName Package Name of Annotation Type
+     * @param name Name of Annotation Type
+     * @return <code>new</code> instance of Annotation Type Builder.
+     */
     public AnnotationTypeBuilder addAnnotation(final String packageName, final String name);
-    
+
+    /**
+     *
+     * @param name
+     * @param value
+     */
     public void addValue(final String name, final Integer value);
 
+    /**
+     *
+     * @param definingType
+     * @return
+     */
     public Enumeration toInstance(final Type definingType);
 }
index fd64cec8b79c0d41c9ab7ad5f9ea77f46bc36e56..f1df1fbc3b1d6e9b6db0e073ee97040f6c5b91ef 100644 (file)
@@ -7,29 +7,38 @@
   */
 package org.opendaylight.controller.sal.binding.model.api.type.builder;
 
-import org.opendaylight.controller.sal.binding.model.api.AccessModifier;
 import org.opendaylight.controller.sal.binding.model.api.GeneratedProperty;
 import org.opendaylight.controller.sal.binding.model.api.Type;
 
 /**
-
+ * Generated Property Builder is interface that contains methods to build and
+ * instantiate Generated Property definition.
  *
+ * @see GeneratedProperty
  */
-public interface GeneratedPropertyBuilder {
-    
-    public AnnotationTypeBuilder addAnnotation(final String packageName, final String name);
-    
-    public String getName();
-    
-    public boolean addReturnType(final Type returnType);
-    
-    public void accessorModifier(final AccessModifier modifier);
-    
-    public void addComment(final String comment);
-    
-    public void setFinal(final boolean isFinal);
-    
+public interface GeneratedPropertyBuilder extends TypeMemberBuilder {
+
+    /**
+     * Sets isReadOnly flag for property. If property is marked as read only
+     * it is the same as set property in java as final.
+     *
+     * @param isReadOnly Read Only property flag.
+     */
     public void setReadOnly(final boolean isReadOnly);
-    
+
+    /**
+     * Returns <code>new</code> <i>immutable</i> instance of Generated
+     * Property.
+     * <br>
+     * The <code>definingType</code> param cannot be <code>null</code>. The
+     * every member in Java MUST be declared and defined inside the scope of
+     * <code>class</code> definition. In case that
+     * defining Type will be passed as <code>null</code> reference the method
+     * SHOULD thrown {@link IllegalArgumentException}.
+     *
+     * @param definingType Defining Type of Generated Property
+     * @return <code>new</code> <i>immutable</i> instance of Generated
+     * Property.
+     */
     public GeneratedProperty toInstance(final Type definingType);
 }
index fc3495e184565f052f5b8a21a3f6577f1bac5e0f..8d36ad6c4635039798848e4dc5fdb1b27bb09be6 100644 (file)
@@ -10,23 +10,77 @@ package org.opendaylight.controller.sal.binding.model.api.type.builder;
 import org.opendaylight.controller.sal.binding.model.api.GeneratedTransferObject;
 
 /**
-
+ * Generated Transfer Object Builder is interface that contains methods to
+ * build and instantiate Generated Transfer Object definition.
+ *
+ * @see GeneratedTransferObject
  */
 public interface GeneratedTOBuilder extends GeneratedTypeBuilder {
 
-    public boolean addExtendsType(final GeneratedTransferObject genTransObj);
+    /**
+     * Add Generated Transfer Object from which will be extended current
+     * Generated Transfer Object.
+     * <br>
+     * By definition Java does not allow multiple
+     * inheritance, hence if there is already definition of Generated
+     * Transfer Object the extending object will be overwritten by lastly
+     * added Generated Transfer Object.
+     * <br>
+     * If Generated Transfer Object is <code>null</code> the method SHOULD
+     * throw {@link IllegalArgumentException}
+     *
+     * @param genTransObj Generated Transfer Object
+     */
+    public void setExtendsType(final GeneratedTransferObject genTransObj);
 
+    /**
+     * Add new Generated Property definition for Generated Transfer Object
+     * Builder and returns Generated Property Builder for specifying Property.
+     * <br>
+     * Name of Property cannot be <code>null</code>,
+     * if it is <code>null</code> the method SHOULD throw {@link IllegalArgumentException}
+     *
+     * @param name Name of Property
+     * @return <code>new</code> instance of Generated Property Builder.
+     */
     public GeneratedPropertyBuilder addProperty(final String name);
 
+    /**
+     * Add Property that will be part of <code>equals</code> definition.
+     * <br>
+     * If Generated Property Builder is <code>null</code> the method SHOULD
+     * throw {@link IllegalArgumentException}
+     *
+     * @param property Generated Property Builder
+     * @return <code>true</code> if addition of Generated Property into list
+     * of <code>equals</code> properties is successful.
+     */
     public boolean addEqualsIdentity(final GeneratedPropertyBuilder property);
 
+    /**
+     * Add Property that will be part of <code>hashCode</code> definition.
+     * <br>
+     * If Generated Property Builder is <code>null</code> the method SHOULD
+     * throw {@link IllegalArgumentException}
+     *
+     * @param property Generated Property Builder
+     * @return <code>true</code> if addition of Generated Property into list
+     * of <code>hashCode</code> properties is successful.
+     */
     public boolean addHashIdentity(final GeneratedPropertyBuilder property);
 
+    /**
+     * Add Property that will be part of <code>toString</code> definition.
+     * <br>
+     * If Generated Property Builder is <code>null</code> the method SHOULD
+     * throw {@link IllegalArgumentException}
+     *
+     * @param property Generated Property Builder
+     * @return <code>true</code> if addition of Generated Property into list
+     * of <code>toString</code> properties is successful.
+     */
     public boolean addToStringProperty(final GeneratedPropertyBuilder property);
 
     @Override
     public GeneratedTransferObject toInstance();
-
-    public GeneratedTransferObject toIdentityInstance();
-
 }
index 689e8311e2d30dd4b848fb2ff3f5275e5e8283cf..6bb58e0ca98b16d6046d5469bb8ac42e14dca0d4 100644 (file)
  */
 package org.opendaylight.controller.sal.binding.model.api.type.builder;
 
+import org.opendaylight.controller.sal.binding.model.api.Constant;
 import org.opendaylight.controller.sal.binding.model.api.GeneratedType;
 import org.opendaylight.controller.sal.binding.model.api.Type;
 
 /**
-
+ * Generated Type Builder interface is helper interface for building and
+ * defining the GeneratedType.
  *
+ * @see GeneratedType
  */
 public interface GeneratedTypeBuilder extends Type {
 
-    public Type getParentType();
+    /**
+     * Adds new Enclosing Type into definition of Generated Type and returns
+     * <code>new</code> Instance of Generated Type Builder.
+     * <br>
+     * There is no need of specifying of Package Name because enclosing Type
+     * is already defined inside Generated Type with specific package name.
+     * <br>
+     * The name of enclosing Type cannot be same as Name of parent type and
+     * if there is already defined enclosing type with the same name,
+     * the new enclosing type will simply overwrite the older definition.
+     * <br>
+     * If the name of enclosing type is <code>null</code> the method SHOULD
+     * throw {@link IllegalArgumentException}
+     *
+     * @param name Name of Enclosing Type
+     * @return <code>new</code> Instance of Generated Type Builder.
+     */
+    public GeneratedTypeBuilder addEnclosingType(final String name);
+
+    /**
+     * Adds new Enclosing Transfer Object into definition of Generated Type
+     * and returns <code>new</code> Instance of Generated TO Builder.
+     * <br>
+     * There is no need of specifying of Package Name because enclosing Type
+     * is already defined inside Generated Type with specific package name.
+     * <br>
+     * The name of enclosing Type cannot be same as Name of parent type and
+     * if there is already defined enclosing type with the same name,
+     * the new enclosing type will simply overwrite the older definition.
+     * <br>
+     * If the name of enclosing type is <code>null</code> the method SHOULD
+     * throw {@link IllegalArgumentException}
+     *
+     * @param name Name of Enclosing Type
+     * @return <code>new</code> Instance of Generated Type Builder.
+     */
+    public GeneratedTOBuilder addEnclosingTransferObject(final String name);
 
+    /**
+     * Adds String definition of comment into Method Signature definition.
+     * <br>
+     * The comment String MUST NOT contain anny comment specific chars (i.e.
+     * "/**" or "//") just plain String text description.
+     *
+     * @param comment Comment String.
+     */
     public void addComment(final String comment);
-    
+
+     /**
+     * The method creates new AnnotationTypeBuilder containing specified
+     * package name an annotation name.
+     * <br>
+     * Neither the package name or annotation name can contain
+     * <code>null</code> references. In case that
+     * any of parameters contains <code>null</code> the method SHOULD thrown
+     * {@link IllegalArgumentException}
+     *
+     * @param packageName Package Name of Annotation Type
+     * @param name Name of Annotation Type
+     * @return <code>new</code> instance of Annotation Type Builder.
+     */
     public AnnotationTypeBuilder addAnnotation(final String packageName, final String name);
-    
+
+    /**
+     * Sets the <code>abstract</code> flag to define Generated Type as <i>abstract</i> type.
+     *
+     * @param isAbstract abstract flag
+     */
+    public void setAbstract(boolean isAbstract);
+
+    /**
+     * Add Type to implements.
+     *
+     * @param genType Type to implement
+     * @return <code>true</code> if the addition of type is successful.
+     */
     public boolean addImplementsType(final Type genType);
-    
-    public ConstantBuilder addConstant(final Type type, final String name,
+
+    /**
+     * Adds Constant definition and returns <code>new</code> Constant instance.
+     * <br>
+     * By definition Constant MUST be defined by return Type,
+     * Name and assigned value. The name SHOULD be defined with cpaital
+     * letters. Neither of method parameters can be <code>null</code> and the
+     * method SHOULD throw {@link IllegalArgumentException} if the contract
+     * is broken.
+     *
+     * @param type Constant Type
+     * @param name Name of Constant
+     * @param value Assigned Value
+     * @return <code>new</code> Constant instance.
+     */
+    public Constant addConstant(final Type type, final String name,
             final Object value);
 
+    /**
+     * Adds new Enumeration definition for Generated Type Builder and returns
+     * Enum Builder for specifying all Enum parameters.
+     * <br>
+     * If there is already Enumeration stored with the same name,
+     * the old enum will be simply overwritten byt new enum definition.
+     * <br>
+     * Name of Enumeration cannot be <code>null</code>,
+     * if it is <code>null</code> the method SHOULD throw {@link IllegalArgumentException}
+     *
+     * @param name Enumeration Name
+     * @return <code>new</code> instance of Enumeration Builder.
+     */
     public EnumBuilder addEnumeration(final String name);
 
+    /**
+     * Add new Method Signature definition for Generated Type Builder and
+     * returns Method Signature Builder for specifying all Method parameters.
+     * <br>
+     * Name of Method cannot be <code>null</code>,
+     * if it is <code>null</code> the method SHOULD throw {@link IllegalArgumentException}
+     * <br>
+     * By <i>Default</i> the MethodSignatureBuilder SHOULD be pre-set as
+     * {@link MethodSignatureBuilder#setAbstract(true)}, {@link MethodSignatureBuilder#setFinal(false)} and
+     * {@link MethodSignatureBuilder#setAccessModifier(PUBLIC)}
+     *
+     * @param name Name of Method
+     * @return <code>new</code> instance of Method Signature Builder.
+     */
     public MethodSignatureBuilder addMethod(final String name);
 
+    /**
+     * Returns the <code>new</code> <i>immutable</i> instance of Generated
+     * Type.
+     *
+     * @return the <code>new</code> <i>immutable</i> instance of Generated
+     * Type.
+     */
     public GeneratedType toInstance();
 }
index 572d15faf4bee363e2c276cfd59b4788d5ce860e..70ea9bbb00491e074bef6b4216577006dc444e9c 100644 (file)
@@ -11,15 +11,58 @@ package org.opendaylight.controller.sal.binding.model.api.type.builder;
 import org.opendaylight.controller.sal.binding.model.api.MethodSignature;
 import org.opendaylight.controller.sal.binding.model.api.Type;
 
-public interface MethodSignatureBuilder {
-    
-    public AnnotationTypeBuilder addAnnotation(final String packageName, final String name);
-    
-    public void addReturnType(final Type returnType);
+/**
+ * Method Signature Builder serves solely for building Method Signature and
+ * returning the <code>new</code> instance of Method Signature.
+ * <br>
+ * By definition of {@link MethodSignature} the Method in java MUST contain
+ * Name, Return Type and Access Modifier. By default the Access Modifier can
+ * be set to public. The Method Signature builder does not contain method for
+ * addName due to enforce reason that MethodSignatureBuilder SHOULD be
+ * instantiated only once with defined method name.
+ * <br>
+ * The methods as {@link #addAnnotation(String, String)} and {@link #setComment(String)}
+ * can be used as optional because not all methods MUST contain annotation or
+ * comment definitions.
+ *
+ *
+ * @see MethodSignature
+ */
+public interface MethodSignatureBuilder extends TypeMemberBuilder {
 
-    public void addParameter(final Type type, final String name);
+    /**
+     * Sets the flag for declaration of method as abstract or non abstract. If the flag <code>isAbstract == true</code>
+     * The instantiated Method Signature MUST have return value for {@link org.opendaylight.controller.sal.binding
+     * .model.api.MethodSignature#isAbstract()} also equals to <code>true</code>.
+     *
+     * @param isAbstract is abstract flag
+     */
+    public void setAbstract(boolean isAbstract);
 
-    public void addComment(final String comment);
+    /**
+     * Adds Parameter into the List of method parameters. Neither the Name or
+     * Type of parameter can be <code>null</code>.
+     *
+     * <br>
+     * In case that any of parameters are defined as <code>null</code> the
+     * method SHOULD throw an {@link IllegalArgumentException}
+     *
+     * @param type Parameter Type
+     * @param name Parameter Name
+     */
+    public void addParameter(final Type type, final String name);
 
+    /**
+     * Returns <code>new</code> <i>immutable</i> instance of Method Signature.
+     * <br>
+     * The <code>definingType</code> param cannot be <code>null</code>. The
+     * every method in Java MUST be declared and defined inside the scope of
+     * <code>class</code> or <code>interface</code> definition. In case that
+     * defining Type will be passed as <code>null</code> reference the method
+     * SHOULD thrown {@link IllegalArgumentException}.
+     *
+     * @param definingType Defining Type of Method Signature
+     * @return <code>new</code> <i>immutable</i> instance of Method Signature.
+     */
     public MethodSignature toInstance(final Type definingType);
 }
diff --git a/opendaylight/sal/yang-prototype/code-generator/binding-model-api/src/main/java/org/opendaylight/controller/sal/binding/model/api/type/builder/TypeMemberBuilder.java b/opendaylight/sal/yang-prototype/code-generator/binding-model-api/src/main/java/org/opendaylight/controller/sal/binding/model/api/type/builder/TypeMemberBuilder.java
new file mode 100644 (file)
index 0000000..de19360
--- /dev/null
@@ -0,0 +1,69 @@
+package org.opendaylight.controller.sal.binding.model.api.type.builder;
+
+import org.opendaylight.controller.sal.binding.model.api.AccessModifier;
+import org.opendaylight.controller.sal.binding.model.api.Type;
+
+/**
+ *
+ */
+public interface TypeMemberBuilder {
+
+    /**
+     * The method creates new AnnotationTypeBuilder containing specified
+     * package name an annotation name.
+     * <br>
+     * Neither the package name or annotation name can contain
+     * <code>null</code> references. In case that
+     * any of parameters contains <code>null</code> the method SHOULD thrown
+     * {@link IllegalArgumentException}
+     *
+     * @param packageName Package Name of Annotation Type
+     * @param name Name of Annotation Type
+     * @return <code>new</code> instance of Annotation Type Builder.
+     */
+    public AnnotationTypeBuilder addAnnotation(final String packageName, final String name);
+
+    /**
+     * Returns the name of property.
+     *
+     * @return the name of property.
+     */
+    public String getName();
+
+    /**
+     * Adds return Type into Builder definition for Generated Property.
+     * <br>
+     * The return Type MUST NOT be <code>null</code>,
+     * otherwise the method SHOULD throw {@link IllegalArgumentException}
+     *
+     * @param returnType Return Type of property.
+     */
+    public void setReturnType(final Type returnType);
+
+    /**
+     * Sets the access modifier of property.
+     *
+     * @param modifier Access Modifier value.
+     */
+    public void setAccessModifier(final AccessModifier modifier);
+
+    /**
+     * Adds String definition of comment into Method Signature definition.
+     * <br>
+     * The comment String MUST NOT contain anny comment specific chars (i.e.
+     * "/**" or "//") just plain String text description.
+     *
+     * @param comment Comment String.
+     */
+    public void setComment(final String comment);
+
+    /**
+     * Sets the flag final for method signature. If this is set the method will be prohibited from overriding.
+     * <br>
+     * This setting is irrelevant for methods designated to be defined in interface definitions because interface
+     * can't have final method.
+     *
+     * @param isFinal Is Final
+     */
+    public void setFinal(final boolean isFinal);
+}