Added support for annotations in generated APIs. 51/251/1
authorlsedlak <lsedlak@cisco.com>
Thu, 25 Apr 2013 15:39:25 +0000 (17:39 +0200)
committerlsedlak <lsedlak@cisco.com>
Thu, 25 Apr 2013 15:44:21 +0000 (17:44 +0200)
Added AnnotationType and AnnotationTypeBuilder into binding-model-api;
Modified GeneratedTransferObject -> now extending from GeneratedType -
implementation modified accordingly;
Added getAnnotations property into: Enumeration, GeneratedType,
GeneratedTransferObject and MethodSignature interfaces;
Added addAnnotation method into EnumBuilder, GeneratedPropertyBuilder,
GeneratedTOBuilder, GeneratedTypeBuilder, MethodSignatureBuilder;

Added implementation of AnnotationType into all builder implementations
in binding-generator-impl project part;
Added AnnotationTypeTest into binding-generator-impl;
Package name in src/test/java for binding-generator-impl changed to
org.opendaylight.controller.sal.binding.generator.impl to
test package protected classes;

In binding-java-api-generator CompositeKeyGenerator renamed to
ClassCodeGenerator;
Added implementation to write annotations for interface and class *.java
files;
Added support methods for annotations to Generator Util class;

Signed-off-by: Lukas Sedlak <lsedlak@cisco.com>
27 files changed:
opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/main/java/org/opendaylight/controller/sal/binding/generator/impl/AnnotationTypeBuilderImpl.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/main/java/org/opendaylight/controller/sal/binding/generator/impl/ConstantBuilderImpl.java
opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/main/java/org/opendaylight/controller/sal/binding/generator/impl/EnumerationBuilderImpl.java
opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/main/java/org/opendaylight/controller/sal/binding/generator/impl/GeneratedTOBuilderImpl.java
opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/main/java/org/opendaylight/controller/sal/binding/generator/impl/GeneratedTypeBuilderImpl.java
opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/main/java/org/opendaylight/controller/sal/binding/generator/impl/MethodParameterImpl.java
opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/main/java/org/opendaylight/controller/sal/binding/generator/impl/MethodSignatureBuilderImpl.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/java/org/opendaylight/controller/sal/binding/generator/impl/AnnotationBuilderTest.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/java/org/opendaylight/controller/sal/binding/generator/impl/BaseTypeProvider.java [moved from opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/java/org/opendaylight/controller/sal/binding/yang/types/test/BaseTypeProvider.java with 94% similarity]
opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/java/org/opendaylight/controller/sal/binding/generator/impl/DefinedTypesProviderTest.java [moved from opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/java/org/opendaylight/controller/sal/binding/yang/types/test/DefinedTypesProviderTest.java with 82% similarity]
opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/java/org/opendaylight/controller/sal/binding/generator/impl/GeneratedTypesTest.java [moved from opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/java/org/opendaylight/controller/sal/binding/yang/types/test/GeneratedTypesTest.java with 98% similarity]
opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/java/org/opendaylight/controller/sal/binding/yang/types/test/package-info.java [deleted file]
opendaylight/sal/yang-prototype/code-generator/binding-java-api-generator/src/main/java/org/opendaylight/controller/sal/java/api/generator/ClassCodeGenerator.java [moved from opendaylight/sal/yang-prototype/code-generator/binding-java-api-generator/src/main/java/org/opendaylight/controller/sal/java/api/generator/CompositeKeyGenerator.java with 80% similarity]
opendaylight/sal/yang-prototype/code-generator/binding-java-api-generator/src/main/java/org/opendaylight/controller/sal/java/api/generator/GeneratorJavaFile.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-model-api/src/main/java/org/opendaylight/controller/sal/binding/model/api/AnnotationType.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/Enumeration.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/type/builder/AnnotationTypeBuilder.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/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

diff --git a/opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/main/java/org/opendaylight/controller/sal/binding/generator/impl/AnnotationTypeBuilderImpl.java b/opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/main/java/org/opendaylight/controller/sal/binding/generator/impl/AnnotationTypeBuilderImpl.java
new file mode 100644 (file)
index 0000000..ef64214
--- /dev/null
@@ -0,0 +1,327 @@
+package org.opendaylight.controller.sal.binding.generator.impl;
+
+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.type.builder.AnnotationTypeBuilder;
+
+final class AnnotationTypeBuilderImpl implements AnnotationTypeBuilder {
+    
+    private final String packageName;
+    private final String name;
+    private final List<AnnotationTypeBuilder> annotationBuilders;
+    private final List<AnnotationType.Parameter> parameters;
+    
+    public AnnotationTypeBuilderImpl(final String packageName, final String name) {
+        super();
+        this.packageName = packageName;
+        this.name = name;
+        
+        annotationBuilders = new ArrayList<AnnotationTypeBuilder>();
+        parameters = new ArrayList<AnnotationType.Parameter>();
+    }
+
+    @Override
+    public String getPackageName() {
+        return packageName;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public AnnotationTypeBuilder addAnnotation(final String packageName, final 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 addParameter(String paramName, String value) {
+        if ((paramName != null) && (value != null)) {
+            return parameters.add(new ParameterImpl(paramName, value));
+        }
+        return false;
+    }
+
+    @Override
+    public boolean addParameters(String paramName, List<String> values) {
+        if ((paramName != null) && (values != null)) {
+            return parameters.add(new ParameterImpl(paramName, values));
+        }
+        return false;
+    }
+
+    @Override
+    public AnnotationType toInstance() {
+        return new AnnotationTypeImpl(packageName, name, annotationBuilders, parameters);
+    }
+
+    @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;
+        }
+        AnnotationTypeBuilderImpl other = (AnnotationTypeBuilderImpl) 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("AnnotationTypeBuilder [packageName=");
+        builder.append(packageName);
+        builder.append(", name=");
+        builder.append(name);
+        builder.append(", annotationBuilders=");
+        builder.append(annotationBuilders);
+        builder.append(", parameters=");
+        builder.append(parameters);
+        builder.append("]");
+        return builder.toString();
+    }
+    
+    private static final class AnnotationTypeImpl implements AnnotationType {
+        
+        private final String packageName;
+        private final String name;
+        private List<AnnotationType> annotations;
+        private final List<AnnotationType.Parameter> parameters;
+        private List<String> paramNames;
+        
+        public AnnotationTypeImpl(String packageName, String name,
+                List<AnnotationTypeBuilder> annotationBuilders,
+                List<AnnotationType.Parameter> parameters) {
+            super();
+            this.packageName = packageName;
+            this.name = name;
+            
+            this.annotations = new ArrayList<AnnotationType>();
+            for (final AnnotationTypeBuilder builder : annotationBuilders) {
+                annotations.add(builder.toInstance());
+            }
+            
+            this.annotations = Collections.unmodifiableList(annotations); 
+            this.parameters = Collections.unmodifiableList(parameters);
+            
+            paramNames = new ArrayList<String>();
+            for (final AnnotationType.Parameter parameter : parameters) {
+                paramNames.add(parameter.getName());
+            }
+            this.paramNames = Collections.unmodifiableList(paramNames);
+        }
+        
+        @Override
+        public String getPackageName() {
+            return packageName;
+        }
+
+        @Override
+        public String getName() {
+            return name;
+        }
+
+        @Override
+        public List<AnnotationType> getAnnotations() {
+            return annotations;
+        }
+
+        @Override
+        public Parameter getParameter(final String paramName) {
+            if (paramName != null) {
+                for (final AnnotationType.Parameter parameter : parameters) {
+                    if (parameter.getName().equals(paramName)) {
+                        return parameter;
+                    }
+                }
+            }
+            return null;
+        }
+
+        @Override
+        public List<Parameter> getParameters() {
+            return parameters;
+        }
+
+        @Override
+        public List<String> getParameterNames() {
+            return paramNames;
+        }
+        
+        @Override
+        public boolean containsParameters() {
+            return !parameters.isEmpty();
+        }
+        
+        @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;
+            }
+            AnnotationTypeImpl other = (AnnotationTypeImpl) 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("AnnotationType [packageName=");
+            builder.append(packageName);
+            builder.append(", name=");
+            builder.append(name);
+            builder.append(", annotations=");
+            builder.append(annotations);
+            builder.append(", parameters=");
+            builder.append(parameters);
+            builder.append("]");
+            return builder.toString();
+        }
+    }
+    
+    private static final class ParameterImpl implements AnnotationType.Parameter {
+        
+        private final String name;
+        private final String value;
+        private final List<String> values;
+        
+        public ParameterImpl(String name, String value) {
+            super();
+            this.name = name;
+            this.value = value;
+            this.values = Collections.emptyList();
+        }
+        
+        public ParameterImpl(String name, List<String> values) {
+            super();
+            this.name = name;
+            this.values = values;
+            this.value = null;
+        }
+
+        @Override
+        public String getName() {
+            return name;
+        }
+
+        @Override
+        public String getValue() {
+            return value;
+        }
+
+        @Override
+        public List<String> getValues() {
+            return values;
+        }
+
+        @Override
+        public int hashCode() {
+            final int prime = 31;
+            int result = 1;
+            result = prime * result + ((name == null) ? 0 : name.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;
+            }
+            ParameterImpl other = (ParameterImpl) obj;
+            if (name == null) {
+                if (other.name != null) {
+                    return false;
+                }
+            } else if (!name.equals(other.name)) {
+                return false;
+            }
+            return true;
+        }
+
+        @Override
+        public String toString() {
+            StringBuilder builder = new StringBuilder();
+            builder.append("ParameterImpl [name=");
+            builder.append(name);
+            builder.append(", value=");
+            builder.append(value);
+            builder.append(", values=");
+            builder.append(values);
+            builder.append("]");
+            return builder.toString();
+        }
+    }
+}
index cb2fc87..cbe704a 100644 (file)
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.sal.binding.generator.impl;\r
-\r
-import org.opendaylight.controller.sal.binding.model.api.Constant;\r
-import org.opendaylight.controller.sal.binding.model.api.Type;\r
-import org.opendaylight.controller.sal.binding.model.api.type.builder.ConstantBuilder;\r
-\r
-final class ConstantBuilderImpl implements ConstantBuilder {\r
-\r
-    private final Type type;\r
-    private final String name;\r
-    private Object value;\r
-\r
-    public ConstantBuilderImpl(Type type, String name, Object value) {\r
-        super();\r
-        this.type = type;\r
-        this.name = name;\r
-        this.value = value;\r
-    }\r
-\r
-    public ConstantBuilderImpl(Type type, String name) {\r
-        super();\r
-        this.type = type;\r
-        this.name = name;\r
-    }\r
-\r
-    @Override\r
-    public void assignValue(Object value) {\r
-        this.value = value;\r
-    }\r
-\r
-    @Override\r
-    public Constant toInstance(final Type definingType) {\r
-        return new ConstantImpl(definingType, type, name, value);\r
-    }\r
-\r
-    private static final class ConstantImpl implements Constant {\r
-\r
-        final Type definingType;\r
-        private final Type type;\r
-        private final String name;\r
-        private final Object value;\r
-\r
-        public ConstantImpl(final Type definingType, final Type type,\r
-                final String name, final Object value) {\r
-            super();\r
-            this.definingType = definingType;\r
-            this.type = type;\r
-            this.name = name;\r
-            this.value = value;\r
-        }\r
-\r
-        @Override\r
-        public Type getDefiningType() {\r
-            return definingType;\r
-        }\r
-\r
-        @Override\r
-        public Type getType() {\r
-            return type;\r
-        }\r
-\r
-        @Override\r
-        public String getName() {\r
-            return name;\r
-        }\r
-\r
-        @Override\r
-        public Object getValue() {\r
-            return value;\r
-        }\r
-\r
-        @Override\r
-        public String toFormattedString() {\r
-            StringBuilder builder = new StringBuilder();\r
-            builder.append(type);\r
-            builder.append(" ");\r
-            builder.append(name);\r
-            builder.append(" ");\r
-            builder.append(value);\r
-            return builder.toString();\r
-        }\r
-\r
-        /*\r
-         * (non-Javadoc)\r
-         * \r
-         * @see java.lang.Object#hashCode()\r
-         */\r
-        @Override\r
-        public int hashCode() {\r
-            final int prime = 31;\r
-            int result = 1;\r
-            result = prime * result + ((name == null) ? 0 : name.hashCode());\r
-            result = prime * result + ((type == null) ? 0 : type.hashCode());\r
-            result = prime * result + ((value == null) ? 0 : value.hashCode());\r
-            if (definingType != null) {\r
-                result = prime\r
-                        * result\r
-                        + ((definingType.getPackageName() == null) ? 0\r
-                                : definingType.getPackageName().hashCode());\r
-                result = prime\r
-                        * result\r
-                        + ((definingType.getName() == null) ? 0 : definingType\r
-                                .getName().hashCode());\r
-            }\r
-            return result;\r
-        }\r
-\r
-        /*\r
-         * (non-Javadoc)\r
-         * \r
-         * @see java.lang.Object#equals(java.lang.Object)\r
-         */\r
-        @Override\r
-        public boolean equals(Object obj) {\r
-            if (this == obj) {\r
-                return true;\r
-            }\r
-            if (obj == null) {\r
-                return false;\r
-            }\r
-            if (getClass() != obj.getClass()) {\r
-                return false;\r
-            }\r
-            ConstantImpl other = (ConstantImpl) obj;\r
-            if (name == null) {\r
-                if (other.name != null) {\r
-                    return false;\r
-                }\r
-            } else if (!name.equals(other.name)) {\r
-                return false;\r
-            }\r
-            if (type == null) {\r
-                if (other.type != null) {\r
-                    return false;\r
-                }\r
-            } else if (!type.equals(other.type)) {\r
-                return false;\r
-            }\r
-            if (value == null) {\r
-                if (other.value != null) {\r
-                    return false;\r
-                }\r
-            } else if (!value.equals(other.value)) {\r
-                return false;\r
-            }\r
-            if (definingType == null) {\r
-                if (other.definingType != null) {\r
-                    return false;\r
-                }\r
-            } else if ((definingType != null) && (other.definingType != null)) {\r
-                if (!definingType.getPackageName().equals(\r
-                        other.definingType.getPackageName())\r
-                        && !definingType.getName().equals(\r
-                                other.definingType.getName())) {\r
-                    return false;\r
-                }\r
-            }\r
-            return true;\r
-        }\r
-\r
-        @Override\r
-        public String toString() {\r
-            StringBuilder builder = new StringBuilder();\r
-            builder.append("ConstantImpl [type=");\r
-            builder.append(type);\r
-            builder.append(", name=");\r
-            builder.append(name);\r
-            builder.append(", value=");\r
-            builder.append(value);\r
-            if (definingType != null) {\r
-                builder.append(", definingType=");\r
-                builder.append(definingType.getPackageName());\r
-                builder.append(".");\r
-                builder.append(definingType.getName());\r
-            } else {\r
-                builder.append(", definingType= null");\r
-            }\r
-            builder.append("]");\r
-            return builder.toString();\r
-        }\r
-    }\r
-}\r
+/*
+ * 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.generator.impl;
+
+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();
+        }
+    }
+}
index 4dde459..45d363d 100644 (file)
@@ -11,15 +11,18 @@ 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.Enumeration;
 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.EnumBuilder;
 
 final class EnumerationBuilderImpl implements EnumBuilder {
     private final String packageName;
     private final String name;
     private final List<Enumeration.Pair> values;
-
+    private final List<AnnotationTypeBuilder> annotationBuilders = new ArrayList<AnnotationTypeBuilder>();
+    
     public EnumerationBuilderImpl(final String packageName, final String name) {
         super();
         this.packageName = packageName;
@@ -37,6 +40,17 @@ final class EnumerationBuilderImpl implements EnumBuilder {
         return name;
     }
     
+    @Override
+    public AnnotationTypeBuilder addAnnotation(final String packageName, final 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 addValue(final String name, final Integer value) {
         values.add(new EnumPairImpl(name, value));
@@ -44,9 +58,9 @@ final class EnumerationBuilderImpl implements EnumBuilder {
 
     @Override
     public Enumeration toInstance(final Type definingType) {
-        return new EnumerationImpl(definingType, packageName, name, values);
+        return new EnumerationImpl(definingType, annotationBuilders, packageName, name, values);
     }
-
+    
     /*
      * (non-Javadoc)
      * 
@@ -191,7 +205,7 @@ final class EnumerationBuilderImpl implements EnumBuilder {
         @Override
         public String toString() {
             StringBuilder builder = new StringBuilder();
-            builder.append("EnumPairImpl [name=");
+            builder.append("EnumPair [name=");
             builder.append(name);
             builder.append(", value=");
             builder.append(value);
@@ -206,12 +220,18 @@ 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>();
+        
         public EnumerationImpl(final Type definingType,
+                final List<AnnotationTypeBuilder> annotationBuilders,
                 final String packageName, final String name,
                 final List<Pair> values) {
             super();
             this.definingType = definingType;
+            for (final AnnotationTypeBuilder builder : annotationBuilders) {
+                annotations.add(builder.toInstance());
+            }
+            this.annotations = Collections.unmodifiableList(annotations); 
             this.packageName = packageName;
             this.name = name;
             this.values = Collections.unmodifiableList(values);
@@ -236,6 +256,11 @@ final class EnumerationBuilderImpl implements EnumBuilder {
         public List<Pair> getValues() {
             return values;
         }
+        
+        @Override
+        public List<AnnotationType> getAnnotations() {
+            return annotations;
+        }
 
         @Override
         public String toFormattedString() {
@@ -279,17 +304,6 @@ final class EnumerationBuilderImpl implements EnumBuilder {
             result = prime * result
                     + ((values == null) ? 0 : values.hashCode());
 
-            if (definingType != null) {
-                result = prime
-                        * result
-                        + ((definingType.getPackageName() == null) ? 0
-                                : definingType.getPackageName().hashCode());
-                result = prime
-                        * result
-                        + ((definingType.getName() == null) ? 0 : definingType
-                                .getName().hashCode());
-            }
-
             return result;
         }
 
@@ -331,18 +345,6 @@ final class EnumerationBuilderImpl implements EnumBuilder {
             } else if (!values.equals(other.values)) {
                 return false;
             }
-            if (definingType == null) {
-                if (other.definingType != null) {
-                    return false;
-                }
-            } else if ((definingType != null) && (other.definingType != null)) {
-                if (!definingType.getPackageName().equals(
-                        other.definingType.getPackageName())
-                        && !definingType.getName().equals(
-                                other.definingType.getName())) {
-                    return false;
-                }
-            }
             return true;
         }
 
@@ -354,7 +356,7 @@ final class EnumerationBuilderImpl implements EnumBuilder {
         @Override
         public String toString() {
             StringBuilder builder = new StringBuilder();
-            builder.append("EnumerationImpl [packageName=");
+            builder.append("Enumeration [packageName=");
             builder.append(packageName);
             if (definingType != null) {
                 builder.append(", definingType=");
index ff232f7..f84c3cf 100644 (file)
@@ -12,20 +12,24 @@ 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.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;
 
 final class GeneratedTOBuilderImpl implements GeneratedTOBuilder {
     private String packageName;
     private final String name;
+    private String comment = "";
 
     private final List<EnumBuilder> enumerations = new ArrayList<EnumBuilder>();
     private final List<GeneratedPropertyBuilder> properties = new ArrayList<GeneratedPropertyBuilder>();
@@ -33,12 +37,16 @@ final class GeneratedTOBuilderImpl implements GeneratedTOBuilder {
     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>();
+
     public GeneratedTOBuilderImpl(String packageName, String name) {
         super();
         this.packageName = packageName;
         this.name = name;
     }
-    
+
     @Override
     public String getPackageName() {
         return packageName;
@@ -48,7 +56,30 @@ final class GeneratedTOBuilderImpl implements GeneratedTOBuilder {
     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 EnumBuilder addEnumeration(String name) {
         final EnumBuilder builder = new EnumerationBuilderImpl(packageName,
@@ -57,6 +88,22 @@ final class GeneratedTOBuilderImpl implements GeneratedTOBuilder {
         return builder;
     }
 
+    @Override
+    public ConstantBuilder addConstant(Type type, String name, Object value) {
+        final ConstantBuilder builder = new ConstantBuilderImpl(type, name,
+                value);
+        constantDefintions.add(builder);
+        return 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(
@@ -82,15 +129,17 @@ final class GeneratedTOBuilderImpl implements GeneratedTOBuilder {
 
     @Override
     public GeneratedTransferObject toInstance() {
-        return new GeneratedTransferObjectImpl(packageName, name, enumerations,
-                properties, equalsProperties, hashProperties,
-                toStringProperties);
+        return new GeneratedTransferObjectImpl(packageName, name, comment, 
+                annotationBuilders, 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 = "";
@@ -111,6 +160,19 @@ final class GeneratedTOBuilderImpl implements GeneratedTOBuilder {
             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) {
@@ -145,7 +207,7 @@ final class GeneratedTOBuilderImpl implements GeneratedTOBuilder {
 
         @Override
         public GeneratedProperty toInstance(final Type definingType) {
-            return new GeneratedPropertyImpl(name, comment, definingType,
+            return new GeneratedPropertyImpl(name, comment, annotationBuilders, definingType,
                     returnType, isFinal, isReadOnly, parameters, accessModifier);
         }
     }
@@ -154,6 +216,7 @@ final class GeneratedTOBuilderImpl implements GeneratedTOBuilder {
             GeneratedProperty {
 
         private final String name;
+        private List<AnnotationType> annotations;
         private final String comment;
         private final Type parent;
         private final Type returnType;
@@ -161,13 +224,18 @@ final class GeneratedTOBuilderImpl implements GeneratedTOBuilder {
         private final boolean isReadOnly;
         private final List<MethodSignature.Parameter> parameters;
         private final AccessModifier modifier;
-
+        
         public GeneratedPropertyImpl(final String name, final String comment,
-                final Type parent, final Type returnType,
+                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;
@@ -192,6 +260,11 @@ final class GeneratedTOBuilderImpl implements GeneratedTOBuilder {
             return parent;
         }
 
+        @Override
+        public List<AnnotationType> getAnnotations() {
+            return annotations;
+        }
+        
         @Override
         public Type getReturnType() {
             return returnType;
@@ -217,31 +290,15 @@ final class GeneratedTOBuilderImpl implements GeneratedTOBuilder {
             return isFinal;
         }
 
+        
+
         @Override
         public int hashCode() {
             final int prime = 31;
             int result = 1;
-            result = prime * result
-                    + ((comment == null) ? 0 : comment.hashCode());
-            result = prime * result + (isFinal ? 1231 : 1237);
-            result = prime * result + (isReadOnly ? 1231 : 1237);
-            result = prime * result
-                    + ((modifier == null) ? 0 : modifier.hashCode());
             result = prime * result + ((name == null) ? 0 : name.hashCode());
             result = prime * result
                     + ((parameters == null) ? 0 : parameters.hashCode());
-
-            if (parent != null) {
-                result = prime
-                        * result
-                        + ((parent.getPackageName() == null) ? 0 : parent
-                                .getPackageName().hashCode());
-                result = prime
-                        * result
-                        + ((parent.getName() == null) ? 0 : parent.getName()
-                                .hashCode());
-            }
-
             result = prime * result
                     + ((returnType == null) ? 0 : returnType.hashCode());
             return result;
@@ -259,22 +316,6 @@ final class GeneratedTOBuilderImpl implements GeneratedTOBuilder {
                 return false;
             }
             GeneratedPropertyImpl other = (GeneratedPropertyImpl) obj;
-            if (comment == null) {
-                if (other.comment != null) {
-                    return false;
-                }
-            } else if (!comment.equals(other.comment)) {
-                return false;
-            }
-            if (isFinal != other.isFinal) {
-                return false;
-            }
-            if (isReadOnly != other.isReadOnly) {
-                return false;
-            }
-            if (modifier != other.modifier) {
-                return false;
-            }
             if (name == null) {
                 if (other.name != null) {
                     return false;
@@ -289,22 +330,13 @@ final class GeneratedTOBuilderImpl implements GeneratedTOBuilder {
             } else if (!parameters.equals(other.parameters)) {
                 return false;
             }
-            if (parent == null) {
-                if (other.parent != null) {
-                    return false;
-                }
-            } else if ((parent != null) && (other.parent != null)) {
-                if (!parent.getPackageName().equals(
-                        other.parent.getPackageName())
-                        && !parent.getName().equals(other.parent.getName())) {
-                    return false;
-                }
-            }
             if (returnType == null) {
                 if (other.returnType != null) {
                     return false;
                 }
-            } else if (!returnType.equals(other.returnType)) {
+            } else if (!returnType.getPackageName().equals(other.returnType.getPackageName())) {
+                return false;
+            } else if (!returnType.getName().equals(other.returnType.getName())) {
                 return false;
             }
             return true;
@@ -315,6 +347,8 @@ final class GeneratedTOBuilderImpl implements GeneratedTOBuilder {
             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) {
@@ -323,7 +357,7 @@ final class GeneratedTOBuilderImpl implements GeneratedTOBuilder {
                 builder.append(".");
                 builder.append(parent.getName());
             } else {
-                builder.append(", parent= null");
+                builder.append(", parent=null");
             }
             builder.append(", returnType=");
             builder.append(returnType);
@@ -345,12 +379,49 @@ final class GeneratedTOBuilderImpl implements GeneratedTOBuilder {
 
         private final String packageName;
         private final String name;
-        // private final List<Constant> constants;
+        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;
+
+        public GeneratedTransferObjectImpl(final String packageName,
+                final String name,
+                final String comment,
+                final List<AnnotationTypeBuilder> annotationBuilders,
+                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);
+            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) {
@@ -370,6 +441,15 @@ final class GeneratedTOBuilderImpl implements GeneratedTOBuilder {
             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);
+        }
+
         private List<GeneratedProperty> toUnmodifiableProperties(
                 final List<GeneratedPropertyBuilder> propBuilders) {
             final List<GeneratedProperty> constants = new ArrayList<GeneratedProperty>();
@@ -379,22 +459,6 @@ final class GeneratedTOBuilderImpl implements GeneratedTOBuilder {
             return Collections.unmodifiableList(constants);
         }
 
-        public GeneratedTransferObjectImpl(String packageName, String name,
-                List<EnumBuilder> enumBuilders,
-                List<GeneratedPropertyBuilder> propBuilers,
-                List<GeneratedPropertyBuilder> equalsBuilers,
-                List<GeneratedPropertyBuilder> hashCodeBuilers,
-                List<GeneratedPropertyBuilder> stringBuilers) {
-            super();
-            this.packageName = packageName;
-            this.name = name;
-            this.enumerations = toUnmodifiableEnumerations(enumBuilders);
-            this.properties = toUnmodifiableProperties(propBuilers);
-            this.equalsProperties = toUnmodifiableProperties(equalsBuilers);
-            this.hashCodeProperties = toUnmodifiableProperties(hashCodeBuilers);
-            this.stringProperties = toUnmodifiableProperties(stringBuilers);
-        }
-
         @Override
         public String getPackageName() {
             return packageName;
@@ -405,11 +469,36 @@ final class GeneratedTOBuilderImpl implements GeneratedTOBuilder {
             return name;
         }
 
+        @Override
+        public Type getParentType() {
+            return null;
+        }
+        
+        @Override
+        public String getComment() {
+            return comment;
+        }
+        
+        @Override
+        public List<AnnotationType> getAnnotations() {
+            return annotations;
+        }
+
         @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;
@@ -430,42 +519,16 @@ final class GeneratedTOBuilderImpl implements GeneratedTOBuilder {
             return stringProperties;
         }
 
-        /*
-         * (non-Javadoc)
-         * 
-         * @see java.lang.Object#hashCode()
-         */
         @Override
         public int hashCode() {
             final int prime = 31;
             int result = 1;
-            result = prime * result
-                    + ((enumerations == null) ? 0 : enumerations.hashCode());
-            result = prime
-                    * result
-                    + ((equalsProperties == null) ? 0 : equalsProperties
-                            .hashCode());
-            result = prime
-                    * result
-                    + ((hashCodeProperties == null) ? 0 : hashCodeProperties
-                            .hashCode());
             result = prime * result + ((name == null) ? 0 : name.hashCode());
             result = prime * result
                     + ((packageName == null) ? 0 : packageName.hashCode());
-            result = prime * result
-                    + ((properties == null) ? 0 : properties.hashCode());
-            result = prime
-                    * result
-                    + ((stringProperties == null) ? 0 : stringProperties
-                            .hashCode());
             return result;
         }
 
-        /*
-         * (non-Javadoc)
-         * 
-         * @see java.lang.Object#equals(java.lang.Object)
-         */
         @Override
         public boolean equals(Object obj) {
             if (this == obj) {
@@ -478,27 +541,6 @@ final class GeneratedTOBuilderImpl implements GeneratedTOBuilder {
                 return false;
             }
             GeneratedTransferObjectImpl other = (GeneratedTransferObjectImpl) obj;
-            if (enumerations == null) {
-                if (other.enumerations != null) {
-                    return false;
-                }
-            } else if (!enumerations.equals(other.enumerations)) {
-                return false;
-            }
-            if (equalsProperties == null) {
-                if (other.equalsProperties != null) {
-                    return false;
-                }
-            } else if (!equalsProperties.equals(other.equalsProperties)) {
-                return false;
-            }
-            if (hashCodeProperties == null) {
-                if (other.hashCodeProperties != null) {
-                    return false;
-                }
-            } else if (!hashCodeProperties.equals(other.hashCodeProperties)) {
-                return false;
-            }
             if (name == null) {
                 if (other.name != null) {
                     return false;
@@ -513,35 +555,20 @@ final class GeneratedTOBuilderImpl implements GeneratedTOBuilder {
             } else if (!packageName.equals(other.packageName)) {
                 return false;
             }
-            if (properties == null) {
-                if (other.properties != null) {
-                    return false;
-                }
-            } else if (!properties.equals(other.properties)) {
-                return false;
-            }
-            if (stringProperties == null) {
-                if (other.stringProperties != null) {
-                    return false;
-                }
-            } else if (!stringProperties.equals(other.stringProperties)) {
-                return false;
-            }
             return true;
         }
 
-        /*
-         * (non-Javadoc)
-         * 
-         * @see java.lang.Object#toString()
-         */
         @Override
         public String toString() {
             StringBuilder builder = new StringBuilder();
-            builder.append("GeneratedTransferObjectImpl [packageName=");
+            builder.append("GeneratedTransferObject [packageName=");
             builder.append(packageName);
             builder.append(", name=");
             builder.append(name);
+            builder.append(", comment=");
+            builder.append(comment);
+            builder.append(", constants=");
+            builder.append(constants);
             builder.append(", enumerations=");
             builder.append(enumerations);
             builder.append(", properties=");
@@ -552,6 +579,10 @@ final 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("]");
             return builder.toString();
         }
index 2e4ed89..1b8246a 100644 (file)
@@ -11,12 +11,13 @@ 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.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;
@@ -25,8 +26,9 @@ import org.opendaylight.controller.sal.binding.model.api.type.builder.MethodSign
 public final class GeneratedTypeBuilderImpl implements GeneratedTypeBuilder {
 
     private final String packageName;
-    private String comment;
+    private String comment = "";
     private final String name;
+    private final List<AnnotationTypeBuilder> annotationBuilders = new ArrayList<AnnotationTypeBuilder>();
     private final List<EnumBuilder> enumDefinitions = new ArrayList<EnumBuilder>();
     private final List<ConstantBuilder> constantDefintions = new ArrayList<ConstantBuilder>();
     private final List<MethodSignatureBuilder> methodDefinitions = new ArrayList<MethodSignatureBuilder>();
@@ -56,20 +58,31 @@ public final class GeneratedTypeBuilderImpl implements GeneratedTypeBuilder {
         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 ConstantBuilder addConstant(Type type, String name, Object value) {
         final ConstantBuilder builder = new ConstantBuilderImpl(type, name,
                 value);
         constantDefintions.add(builder);
-
         return builder;
     }
 
     @Override
     public EnumBuilder addEnumeration(final String name) {
         final String innerPackageName = packageName + "." + this.name;
-        final EnumBuilder builder = new EnumerationBuilderImpl(innerPackageName,
-                name);
+        final EnumBuilder builder = new EnumerationBuilderImpl(
+                innerPackageName, name);
         enumDefinitions.add(builder);
         return builder;
     }
@@ -84,251 +97,9 @@ public final class GeneratedTypeBuilderImpl implements GeneratedTypeBuilder {
 
     @Override
     public GeneratedType toInstance() {
-        return new GeneratedTypeImpl(this, packageName, name, enumDefinitions,
-                constantDefintions, methodDefinitions);
-    }
-
-    private static final class MethodSignatureBuilderImpl implements
-            MethodSignatureBuilder {
-        private final String name;
-        private Type returnType;
-        private final List<MethodSignature.Parameter> parameters;
-        private String comment = "";
-        private final Type parent;
-
-        public MethodSignatureBuilderImpl(final Type parent, final String name) {
-            super();
-            this.name = name;
-            this.parent = parent;
-            parameters = new ArrayList<MethodSignature.Parameter>();
-            // TODO: move implementation elsewhere!
-
-        }
-
-        @Override
-        public void addReturnType(Type returnType) {
-            if (returnType != null) {
-                this.returnType = returnType;
-            }
-        }
-
-        @Override
-        public void addParameter(Type type, String name) {
-            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, comment,
-                    returnType, parameters);
-        }
-
-        @Override
-        public int hashCode() {
-            final int prime = 31;
-            int result = 1;
-            result = prime * result + ((name == null) ? 0 : name.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 (name == null) {
-                if (other.name != null) {
-                    return false;
-                }
-            } else if (!name.equals(other.name)) {
-                return false;
-            }
-            return true;
-        }
-
-        @Override
-        public String toString() {
-            StringBuilder builder = new StringBuilder();
-            builder.append("MethodBuilderImpl [name=");
-            builder.append(name);
-            builder.append(", returnType=");
-            builder.append(returnType);
-            builder.append(", parameters=");
-            builder.append(parameters);
-            builder.append(", comment=");
-            builder.append(comment);
-            builder.append(", parent=");
-            builder.append(parent.getName());
-            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;
-
-        public MethodSignatureImpl(final Type definingType, final String name,
-                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);
-        }
-
-        @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
-                    + ((comment == null) ? 0 : comment.hashCode());
-            result = prime * result + ((name == null) ? 0 : name.hashCode());
-            result = prime * result
-                    + ((params == null) ? 0 : params.hashCode());
-            result = prime * result
-                    + ((returnType == null) ? 0 : returnType.hashCode());
-
-            if (definingType != null) {
-                result = prime
-                        * result
-                        + ((definingType.getPackageName() == null) ? 0
-                                : definingType.getPackageName().hashCode());
-                result = prime
-                        * result
-                        + ((definingType.getName() == null) ? 0 : definingType
-                                .getName().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 (comment == null) {
-                if (other.comment != null) {
-                    return false;
-                }
-            } else if (!comment.equals(other.comment)) {
-                return false;
-            }
-            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 (definingType == null) {
-                if (other.definingType != null) {
-                    return false;
-                }
-            } else if ((definingType != null) && (other.definingType != null)) {
-                if (!definingType.getPackageName().equals(
-                        other.definingType.getPackageName())
-                        && !definingType.getName().equals(
-                                other.definingType.getName())) {
-                    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("MethodImpl [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("]");
-            return builder.toString();
-        }
+        return new GeneratedTypeImpl(this, packageName, name, comment,
+                annotationBuilders, enumDefinitions, constantDefintions,
+                methodDefinitions);
     }
 
     private static final class GeneratedTypeImpl implements GeneratedType {
@@ -336,24 +107,38 @@ public final class GeneratedTypeBuilderImpl implements GeneratedTypeBuilder {
         private final Type parent;
         private final String packageName;
         private final String name;
+        private final String comment;
+        private final List<AnnotationType> annotations;
         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 List<EnumBuilder> enumBuilders,
+                final String name, final String comment,
+                final List<AnnotationTypeBuilder> annotationBuilders,
+                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.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>();
@@ -396,6 +181,16 @@ public final class GeneratedTypeBuilderImpl implements GeneratedTypeBuilder {
             return parent;
         }
 
+        @Override
+        public String getComment() {
+            return comment;
+        }
+
+        @Override
+        public List<AnnotationType> getAnnotations() {
+            return annotations;
+        }
+
         @Override
         public List<Enumeration> getEnumDefintions() {
             return enumDefinitions;
@@ -486,12 +281,22 @@ public final class GeneratedTypeBuilderImpl implements GeneratedTypeBuilder {
         @Override
         public String toString() {
             StringBuilder builder = new StringBuilder();
-            builder.append("GeneratedTypeImpl [parent=");
-            builder.append(parent.getName());
-            builder.append(", packageName=");
+            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=");
index 08eab60..c17ff2b 100644 (file)
@@ -87,7 +87,7 @@ final class MethodParameterImpl implements Parameter {
     @Override
     public String toString() {
         StringBuilder builder = new StringBuilder();
-        builder.append("MethodParameterImpl [name=");
+        builder.append("MethodParameter [name=");
         builder.append(name);
         builder.append(", type=");
         builder.append(type.getPackageName());
diff --git a/opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/main/java/org/opendaylight/controller/sal/binding/generator/impl/MethodSignatureBuilderImpl.java b/opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/main/java/org/opendaylight/controller/sal/binding/generator/impl/MethodSignatureBuilderImpl.java
new file mode 100644 (file)
index 0000000..4e00bf2
--- /dev/null
@@ -0,0 +1,273 @@
+package org.opendaylight.controller.sal.binding.generator.impl;
+
+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;
+    private final List<MethodSignature.Parameter> parameters;
+    private final List<AnnotationTypeBuilder> annotationBuilders;
+    private String comment = "";
+    private final Type parent;
+
+    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>();
+    }
+
+    @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;
+        }
+    }
+
+    @Override
+    public void addParameter(Type type, String name) {
+        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);
+    }
+    
+    @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;
+        }
+        MethodSignatureBuilderImpl other = (MethodSignatureBuilderImpl) 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.equals(other.returnType)) {
+            return false;
+        }
+        return true;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder builder = new StringBuilder();
+        builder.append("MethodSignatureBuilderImpl [name=");
+        builder.append(name);
+        builder.append(", returnType=");
+        builder.append(returnType);
+        builder.append(", parameters=");
+        builder.append(parameters);
+        builder.append(", annotationBuilders=");
+        builder.append(annotationBuilders);
+        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("]");
+        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-impl/src/test/java/org/opendaylight/controller/sal/binding/generator/impl/AnnotationBuilderTest.java b/opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/java/org/opendaylight/controller/sal/binding/generator/impl/AnnotationBuilderTest.java
new file mode 100644 (file)
index 0000000..f08b77f
--- /dev/null
@@ -0,0 +1,126 @@
+/*
+ * 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.generator.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Test;
+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;
+import org.opendaylight.controller.sal.binding.model.api.type.builder.AnnotationTypeBuilder;
+import org.opendaylight.controller.sal.binding.model.api.type.builder.GeneratedTOBuilder;
+import org.opendaylight.controller.sal.binding.model.api.type.builder.GeneratedTypeBuilder;
+
+public class AnnotationBuilderTest {
+
+    @Test
+    public void generatedTypeAnnotationTest() {
+        GeneratedTypeBuilder genTypeBuilder = new GeneratedTOBuilderImpl(
+                "org.opendaylight.controller", "AnnotInterface");
+
+        genTypeBuilder.addAnnotation("javax.management", "MXBean");
+        final AnnotationTypeBuilder annotDesc = genTypeBuilder.addAnnotation(
+                "javax.management", "Description");
+        annotDesc.addParameter("description", "some sort of interface");
+        
+        final GeneratedType genType = genTypeBuilder.toInstance();
+        
+        assertNotNull(genType);
+        assertNotNull(genType.getAnnotations());
+        assertEquals(2, genType.getAnnotations().size());
+        
+        int annotCount = 0;
+        for (final AnnotationType annotation : genType.getAnnotations()) {
+            if (annotation.getPackageName().equals("javax.management")
+                    && annotation.getName().equals("MXBean")) {
+                annotCount++;
+                assertEquals(0, annotation.getParameters().size());
+            }
+            if (annotation.getPackageName().equals("javax.management")
+                    && annotation.getName().equals("Description")) {
+                annotCount++;
+                assertEquals(1, annotation.getParameters().size());
+                AnnotationType.Parameter param = annotation.getParameter("description");
+                assertNotNull(param);
+                assertEquals("description", param.getName());
+                assertNotNull(param.getValue());
+                assertEquals("some sort of interface", param.getValue());
+                assertNotNull(param.getValues());
+                assertTrue(param.getValues().isEmpty());
+            }
+        }
+        assertEquals(2, annotCount);
+    }
+
+    @Test
+    public void methodSignatureAnnotationTest() {
+        //TODO  add test for method annotations
+    }
+
+    @Test
+    public void generatedPropertyAnnotationTest() {
+        //TODO add test for property annotations
+    }
+
+    @Test
+    public void generatedTransfeObjectAnnotationTest() {
+        final GeneratedTOBuilder genTypeBuilder = new GeneratedTOBuilderImpl(
+                "org.opendaylight.controller", "AnnotClassCache");
+
+        genTypeBuilder.addAnnotation("javax.management", "MBean");
+        final AnnotationTypeBuilder annotNotify = genTypeBuilder.addAnnotation(
+                "javax.management", "NotificationInfo");
+
+        final List<String> notifyList = new ArrayList<String>();
+        notifyList.add("\"my.notif.type\"");
+        annotNotify.addParameters("types", notifyList);
+        annotNotify.addParameter("description",
+                "@Description(\"my notification\")");
+
+        GeneratedTransferObject genTO = genTypeBuilder.toInstance();
+
+        assertNotNull(genTO);
+        assertNotNull(genTO.getAnnotations());
+        assertEquals(2, genTO.getAnnotations().size());
+
+        int annotCount = 0;
+        for (final AnnotationType annotation : genTO.getAnnotations()) {
+            if (annotation.getPackageName().equals("javax.management")
+                    && annotation.getName().equals("MBean")) {
+                annotCount++;
+                assertEquals(0, annotation.getParameters().size());
+            }
+            if (annotation.getPackageName().equals("javax.management")
+                    && annotation.getName().equals("NotificationInfo")) {
+                annotCount++;
+                assertEquals(2, annotation.getParameters().size());
+                AnnotationType.Parameter param = annotation.getParameter("types");
+                assertNotNull(param);
+                assertEquals("types", param.getName());
+                assertNull(param.getValue());
+                assertNotNull(param.getValues());
+                assertEquals(1, param.getValues().size());
+                assertEquals("\"my.notif.type\"", param.getValues().get(0));
+                
+                param = annotation.getParameter("description");
+                assertNotNull(param);
+                assertEquals("description", param.getName());
+                assertNotNull(param.getValue());
+                assertEquals("@Description(\"my notification\")", param.getValue());
+            }
+        }
+        assertEquals(2, annotCount);
+    }
+}
@@ -1,40 +1,40 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.sal.binding.yang.types.test;\r
-\r
-import static org.junit.Assert.assertEquals;\r
-import static org.junit.Assert.assertTrue;\r
-\r
-import org.junit.Ignore;\r
-import org.junit.Test;\r
-import org.opendaylight.controller.binding.generator.util.Types;\r
-import org.opendaylight.controller.sal.binding.generator.spi.TypeProvider;\r
-import org.opendaylight.controller.sal.binding.model.api.ConcreteType;\r
-import org.opendaylight.controller.sal.binding.model.api.ParameterizedType;\r
-import org.opendaylight.controller.sal.binding.model.api.Type;\r
-import org.opendaylight.controller.sal.binding.yang.types.BaseYangTypes;\r
-\r
-public class BaseTypeProvider {\r
-\r
-    @Test\r
-    public void test() {\r
-        TypeProvider provider = BaseYangTypes.BASE_YANG_TYPES_PROVIDER;\r
-\r
-        Type stringType = provider.javaTypeForYangType("string");\r
-        assertEquals("java.lang", stringType.getPackageName());\r
-        assertEquals("String", stringType.getName());\r
-        assertTrue(stringType instanceof ConcreteType);\r
-        ParameterizedType stringBooleanMap = Types.mapTypeFor(\r
-                provider.javaTypeForYangType("string"),\r
-                provider.javaTypeForYangType("boolean"));\r
-        assertTrue(!(stringBooleanMap instanceof ConcreteType));\r
-        assertEquals("java.util", stringBooleanMap.getPackageName());\r
-        assertEquals("Map", stringBooleanMap.getName());\r
-        assertEquals(2, stringBooleanMap.getActualTypeArguments().length);\r
-    }\r
-}\r
+/*
+ * 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.generator.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Ignore;
+import org.junit.Test;
+import org.opendaylight.controller.binding.generator.util.Types;
+import org.opendaylight.controller.sal.binding.generator.spi.TypeProvider;
+import org.opendaylight.controller.sal.binding.model.api.ConcreteType;
+import org.opendaylight.controller.sal.binding.model.api.ParameterizedType;
+import org.opendaylight.controller.sal.binding.model.api.Type;
+import org.opendaylight.controller.sal.binding.yang.types.BaseYangTypes;
+
+public class BaseTypeProvider {
+
+    @Test
+    public void test() {
+        TypeProvider provider = BaseYangTypes.BASE_YANG_TYPES_PROVIDER;
+
+        Type stringType = provider.javaTypeForYangType("string");
+        assertEquals("java.lang", stringType.getPackageName());
+        assertEquals("String", stringType.getName());
+        assertTrue(stringType instanceof ConcreteType);
+        ParameterizedType stringBooleanMap = Types.mapTypeFor(
+                provider.javaTypeForYangType("string"),
+                provider.javaTypeForYangType("boolean"));
+        assertTrue(!(stringBooleanMap instanceof ConcreteType));
+        assertEquals("java.util", stringBooleanMap.getPackageName());
+        assertEquals("Map", stringBooleanMap.getName());
+        assertEquals(2, stringBooleanMap.getActualTypeArguments().length);
+    }
+}
@@ -1,12 +1,12 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.sal.binding.yang.types.test;\r
-\r
-public class DefinedTypesProviderTest {\r
-\r
-}\r
+/*
+ * 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.generator.impl;
+
+public class DefinedTypesProviderTest {
+
+}
@@ -5,7 +5,7 @@
  * 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.yang.types.test;
+package org.opendaylight.controller.sal.binding.generator.impl;
 
 import static org.junit.Assert.*;
 
@@ -418,7 +418,7 @@ public class GeneratedTypesTest {
         int genTypesCount = 0;
         int genTOsCount = 0;
         for (final Type type : genTypes) {
-            if (type instanceof GeneratedType) {
+            if (type instanceof GeneratedType && !(type instanceof GeneratedTransferObject)) {
                 final GeneratedType genType = (GeneratedType) type;
                 if (genType.getName().equals("ListParentContainer")) {
                     assertEquals(2, genType.getMethodDefinitions().size());
@@ -501,7 +501,7 @@ public class GeneratedTypesTest {
         int genTypesCount = 0;
         int genTOsCount = 0;
         for (final Type type : genTypes) {
-            if (type instanceof GeneratedType) {
+            if (type instanceof GeneratedType && !(type instanceof GeneratedTransferObject)) {
                 genTypesCount++;
             } else if (type instanceof GeneratedTransferObject) {
                 final GeneratedTransferObject genTO = (GeneratedTransferObject) type;
@@ -548,7 +548,7 @@ public class GeneratedTypesTest {
         int genTypesCount = 0;
         int genTOsCount = 0;
         for (final Type type : genTypes) {
-            if (type instanceof GeneratedType) {
+            if (type instanceof GeneratedType && !(type instanceof GeneratedTransferObject)) {
                 genTypesCount++;
             } else if (type instanceof GeneratedTransferObject) {
                 genTOsCount++;
diff --git a/opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/java/org/opendaylight/controller/sal/binding/yang/types/test/package-info.java b/opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/java/org/opendaylight/controller/sal/binding/yang/types/test/package-info.java
deleted file mode 100644 (file)
index 76e8a9b..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-/*\r
-  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
-  *\r
-  * This program and the accompanying materials are made available under the\r
-  * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
-  * and is available at http://www.eclipse.org/legal/epl-v10.html\r
-  */\r
-package org.opendaylight.controller.sal.binding.yang.types.test;
\ No newline at end of file
@@ -1,60 +1,66 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.sal.java.api.generator;\r
-\r
-import static org.opendaylight.controller.sal.java.api.generator.Constants.NL;\r
-import static org.opendaylight.controller.sal.java.api.generator.Constants.RCB;\r
-import static org.opendaylight.controller.sal.java.api.generator.Constants.TAB;\r
-\r
-import java.io.IOException;\r
-import java.io.StringWriter;\r
-import java.io.Writer;\r
-import java.util.List;\r
-\r
-import org.opendaylight.controller.sal.binding.model.api.CodeGenerator;\r
-import org.opendaylight.controller.sal.binding.model.api.GeneratedProperty;\r
-import org.opendaylight.controller.sal.binding.model.api.GeneratedTransferObject;\r
-import org.opendaylight.controller.sal.binding.model.api.Type;\r
-\r
-public class CompositeKeyGenerator implements CodeGenerator {\r
-\r
-    @Override\r
-    public Writer generate(Type type) throws IOException {\r
-        final Writer writer = new StringWriter();\r
-        if (type instanceof GeneratedTransferObject) {\r
-            GeneratedTransferObject genTO = (GeneratedTransferObject)type;\r
-            final List<GeneratedProperty> fields = genTO.getProperties();\r
-\r
-            writer.write(GeneratorUtil.createClassDeclarationWithPkgName(\r
-                    type.getPackageName(), type.getName(), ""));\r
-            writer.write(NL);\r
-            writer.write(NL);\r
-            \r
-            if (fields != null) {\r
-                for (GeneratedProperty field : fields) {\r
-                    writer.write(GeneratorUtil.createField(field, TAB) + NL);\r
-                }\r
-                writer.write(NL);\r
-                writer.write(GeneratorUtil.createConstructor(genTO, TAB) + NL);\r
-                writer.write(NL);\r
-                for (GeneratedProperty field : fields) {\r
-                    writer.write(GeneratorUtil.createGetter(field, TAB) + NL);\r
-                }\r
-                writer.write(NL);\r
-\r
-                writer.write(GeneratorUtil.createHashCode(genTO.getHashCodeIdentifiers(), TAB) + NL);\r
-                writer.write(GeneratorUtil.createEquals(genTO, genTO.getEqualsIdentifiers(), TAB) + NL);\r
-                writer.write(GeneratorUtil.createToString(genTO, genTO.getToStringIdentifiers(), TAB) + NL);\r
-\r
-                writer.write(RCB);\r
-            }\r
-        }\r
-        return writer;\r
-    }\r
-\r
-}\r
+/*
+ * 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.java.api.generator;
+
+import static org.opendaylight.controller.sal.java.api.generator.Constants.NL;
+import static org.opendaylight.controller.sal.java.api.generator.Constants.RCB;
+import static org.opendaylight.controller.sal.java.api.generator.Constants.TAB;
+
+import java.io.IOException;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.util.List;
+
+import org.opendaylight.controller.sal.binding.model.api.CodeGenerator;
+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.Type;
+
+public class ClassCodeGenerator implements CodeGenerator {
+
+    @Override
+    public Writer generate(Type type) throws IOException {
+        final Writer writer = new StringWriter();
+        if (type instanceof GeneratedTransferObject) {
+            GeneratedTransferObject genTO = (GeneratedTransferObject) type;
+            final List<GeneratedProperty> fields = genTO.getProperties();
+
+            writer.write(GeneratorUtil.createClassDeclarationWithPkgName(genTO,
+                    ""));
+            writer.write(NL);
+            writer.write(NL);
+
+            if (fields != null) {
+                for (GeneratedProperty field : fields) {
+                    writer.write(GeneratorUtil.createField(field, TAB) + NL);
+                }
+                writer.write(NL);
+                writer.write(GeneratorUtil.createConstructor(genTO, TAB) + NL);
+                writer.write(NL);
+                for (GeneratedProperty field : fields) {
+                    writer.write(GeneratorUtil.createGetter(field, TAB) + NL);
+                }
+                writer.write(NL);
+
+                writer.write(GeneratorUtil.createHashCode(
+                        genTO.getHashCodeIdentifiers(), TAB)
+                        + NL);
+                writer.write(GeneratorUtil.createEquals(genTO,
+                        genTO.getEqualsIdentifiers(), TAB)
+                        + NL);
+                writer.write(GeneratorUtil.createToString(genTO,
+                        genTO.getToStringIdentifiers(), TAB)
+                        + NL);
+
+                writer.write(RCB);
+            }
+        }
+        return writer;
+    }
+
+}
index f2388fe..32b3fa0 100644 (file)
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.sal.java.api.generator;\r
-\r
-import java.io.BufferedWriter;\r
-import java.io.File;\r
-import java.io.FileWriter;\r
-import java.io.IOException;\r
-import java.io.Writer;\r
-import java.util.ArrayList;\r
-import java.util.HashSet;\r
-import java.util.List;\r
-import java.util.Set;\r
-\r
-import org.opendaylight.controller.sal.binding.model.api.CodeGenerator;\r
-import org.opendaylight.controller.sal.binding.model.api.GeneratedTransferObject;\r
-import org.opendaylight.controller.sal.binding.model.api.GeneratedType;\r
-\r
-public class GeneratorJavaFile {\r
-\r
-    private final CodeGenerator interfaceGenerator;\r
-    private final CompositeKeyGenerator classGenerator;\r
-    private final Set<GeneratedType> types;\r
-    private final Set<GeneratedTransferObject> genTransferObjects;\r
-\r
-    public GeneratorJavaFile(final CodeGenerator codeGenerator,\r
-            final Set<GeneratedType> types) {\r
-        this.interfaceGenerator = codeGenerator;\r
-        this.types = types;\r
-        this.genTransferObjects = new HashSet<GeneratedTransferObject>();\r
-        classGenerator = new CompositeKeyGenerator();\r
-    }\r
-\r
-    public GeneratorJavaFile(final Set<GeneratedType> types,\r
-            final Set<GeneratedTransferObject> genTransferObjects) {\r
-        this.interfaceGenerator = new InterfaceGenerator();\r
-        this.classGenerator = new CompositeKeyGenerator();\r
-        this.types = types;\r
-        this.genTransferObjects = genTransferObjects;\r
-    }\r
-\r
-    public boolean generateToFile() {\r
-        return generateToFile(null);\r
-    }\r
-\r
-    public boolean generateToFile(String path) {\r
-        try {\r
-            for (GeneratedType type : types) {\r
-                String parentPath = generateParentPath(path,\r
-                        type.getPackageName());\r
-\r
-                File file = new File(parentPath, type.getName() + ".java");\r
-                File parent = file.getParentFile();\r
-                if (!parent.exists()) {\r
-                    parent.mkdirs();\r
-                }\r
-\r
-                if (!file.exists()) {\r
-                    FileWriter fw = null;\r
-                    BufferedWriter bw = null;\r
-\r
-                    file.createNewFile();\r
-                    fw = new FileWriter(file);\r
-                    bw = new BufferedWriter(fw);\r
-                    Writer writer = interfaceGenerator.generate(type);\r
-                    bw.write(writer.toString());\r
-\r
-                    if (bw != null) {\r
-                        try {\r
-                            bw.close();\r
-                        } catch (IOException e) {\r
-                            // TODO: log?\r
-                        }\r
-                    }\r
-                }\r
-            }\r
-            for (GeneratedTransferObject transferObject : genTransferObjects) {\r
-                String parentPath = generateParentPath(path,\r
-                        transferObject.getPackageName());\r
-\r
-                File file = new File(parentPath, transferObject.getName() + ".java");\r
-                File parent = file.getParentFile();\r
-                if (!parent.exists()) {\r
-                    parent.mkdirs();\r
-                }\r
-\r
-                if (!file.exists()) {\r
-                    FileWriter fw = null;\r
-                    BufferedWriter bw = null;\r
-\r
-                    file.createNewFile();\r
-                    fw = new FileWriter(file);\r
-                    bw = new BufferedWriter(fw);\r
-                    Writer writer = classGenerator.generate(transferObject);\r
-                    bw.write(writer.toString());\r
-\r
-                    if (bw != null) {\r
-                        try {\r
-                            bw.close();\r
-                        } catch (IOException e) {\r
-                            // TODO: log?\r
-                        }\r
-                    }\r
-                }\r
-            }\r
-            return true;\r
-        } catch (IOException e) {\r
-            // TODO: log?\r
-            return false;\r
-        }\r
-    }\r
-\r
-    private String generateParentPath(String path, String pkg) {\r
-        List<String> dirs = new ArrayList<String>();\r
-        String pkgPath = "";\r
-        if (pkg != null) {\r
-            if (pkg.length() > 0) {\r
-                if (pkg.contains(".")) {\r
-                    String[] split = pkg.split("\\.");\r
-                    for (String dir : split) {\r
-                        dirs.add(dir);\r
-                    }\r
-                } else {\r
-                    dirs.add(pkg);\r
-                }\r
-                for (int i = 0; i < dirs.size(); i++) {\r
-                    if (i == 0) {\r
-                        pkgPath += dirs.get(i);\r
-                    } else {\r
-                        pkgPath += File.separator + dirs.get(i);\r
-                    }\r
-                }\r
-            }\r
-        }\r
-        String fullPath = "";\r
-        if (path != null) {\r
-            if (path.endsWith(File.separator)) {\r
-                fullPath = path + pkgPath;\r
-            } else {\r
-                fullPath = path + File.separator + pkgPath;\r
-            }\r
-        } else {\r
-            fullPath = pkgPath;\r
-        }\r
-        return fullPath;\r
-    }\r
-\r
-}\r
+/*
+ * 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.java.api.generator;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.opendaylight.controller.sal.binding.model.api.CodeGenerator;
+import org.opendaylight.controller.sal.binding.model.api.GeneratedTransferObject;
+import org.opendaylight.controller.sal.binding.model.api.GeneratedType;
+
+public class GeneratorJavaFile {
+
+    private final CodeGenerator interfaceGenerator;
+    private final ClassCodeGenerator classGenerator;
+    private final Set<GeneratedType> types;
+    private final Set<GeneratedTransferObject> genTransferObjects;
+
+    public GeneratorJavaFile(final CodeGenerator codeGenerator,
+            final Set<GeneratedType> types) {
+        this.interfaceGenerator = codeGenerator;
+        this.types = types;
+        this.genTransferObjects = new HashSet<GeneratedTransferObject>();
+        classGenerator = new ClassCodeGenerator();
+    }
+
+    public GeneratorJavaFile(final Set<GeneratedType> types,
+            final Set<GeneratedTransferObject> genTransferObjects) {
+        this.interfaceGenerator = new InterfaceGenerator();
+        this.classGenerator = new ClassCodeGenerator();
+        this.types = types;
+        this.genTransferObjects = genTransferObjects;
+    }
+
+    public boolean generateToFile() {
+        return generateToFile(null);
+    }
+
+    public boolean generateToFile(String path) {
+        try {
+            for (GeneratedType type : types) {
+                String parentPath = generateParentPath(path,
+                        type.getPackageName());
+
+                File file = new File(parentPath, type.getName() + ".java");
+                File parent = file.getParentFile();
+                if (!parent.exists()) {
+                    parent.mkdirs();
+                }
+
+                if (!file.exists()) {
+                    FileWriter fw = null;
+                    BufferedWriter bw = null;
+
+                    file.createNewFile();
+                    fw = new FileWriter(file);
+                    bw = new BufferedWriter(fw);
+                    Writer writer = interfaceGenerator.generate(type);
+                    bw.write(writer.toString());
+
+                    if (bw != null) {
+                        try {
+                            bw.close();
+                        } catch (IOException e) {
+                            // TODO: log?
+                        }
+                    }
+                }
+            }
+            for (GeneratedTransferObject transferObject : genTransferObjects) {
+                String parentPath = generateParentPath(path,
+                        transferObject.getPackageName());
+
+                File file = new File(parentPath, transferObject.getName() + ".java");
+                File parent = file.getParentFile();
+                if (!parent.exists()) {
+                    parent.mkdirs();
+                }
+
+                if (!file.exists()) {
+                    FileWriter fw = null;
+                    BufferedWriter bw = null;
+
+                    file.createNewFile();
+                    fw = new FileWriter(file);
+                    bw = new BufferedWriter(fw);
+                    Writer writer = classGenerator.generate(transferObject);
+                    bw.write(writer.toString());
+
+                    if (bw != null) {
+                        try {
+                            bw.close();
+                        } catch (IOException e) {
+                            // TODO: log?
+                        }
+                    }
+                }
+            }
+            return true;
+        } catch (IOException e) {
+            // TODO: log?
+            return false;
+        }
+    }
+
+    private String generateParentPath(String path, String pkg) {
+        List<String> dirs = new ArrayList<String>();
+        String pkgPath = "";
+        if (pkg != null) {
+            if (pkg.length() > 0) {
+                if (pkg.contains(".")) {
+                    String[] split = pkg.split("\\.");
+                    for (String dir : split) {
+                        dirs.add(dir);
+                    }
+                } else {
+                    dirs.add(pkg);
+                }
+                for (int i = 0; i < dirs.size(); i++) {
+                    if (i == 0) {
+                        pkgPath += dirs.get(i);
+                    } else {
+                        pkgPath += File.separator + dirs.get(i);
+                    }
+                }
+            }
+        }
+        String fullPath = "";
+        if (path != null) {
+            if (path.endsWith(File.separator)) {
+                fullPath = path + pkgPath;
+            } else {
+                fullPath = path + File.separator + pkgPath;
+            }
+        } else {
+            fullPath = pkgPath;
+        }
+        return fullPath;
+    }
+
+}
index a4018a5..b4387fe 100644 (file)
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.sal.java.api.generator;\r
-\r
-import static org.opendaylight.controller.sal.java.api.generator.Constants.CLASS;\r
-import static org.opendaylight.controller.sal.java.api.generator.Constants.COMMA;\r
-import static org.opendaylight.controller.sal.java.api.generator.Constants.ENUM;\r
-import static org.opendaylight.controller.sal.java.api.generator.Constants.FINAL;\r
-import static org.opendaylight.controller.sal.java.api.generator.Constants.GAP;\r
-import static org.opendaylight.controller.sal.java.api.generator.Constants.IFC;\r
-import static org.opendaylight.controller.sal.java.api.generator.Constants.LB;\r
-import static org.opendaylight.controller.sal.java.api.generator.Constants.LCB;\r
-import static org.opendaylight.controller.sal.java.api.generator.Constants.NL;\r
-import static org.opendaylight.controller.sal.java.api.generator.Constants.PKG;\r
-import static org.opendaylight.controller.sal.java.api.generator.Constants.PRIVATE;\r
-import static org.opendaylight.controller.sal.java.api.generator.Constants.PUBLIC;\r
-import static org.opendaylight.controller.sal.java.api.generator.Constants.RB;\r
-import static org.opendaylight.controller.sal.java.api.generator.Constants.RCB;\r
-import static org.opendaylight.controller.sal.java.api.generator.Constants.SC;\r
-import static org.opendaylight.controller.sal.java.api.generator.Constants.STATIC;\r
-import static org.opendaylight.controller.sal.java.api.generator.Constants.TAB;\r
-\r
-import java.util.Arrays;\r
-import java.util.HashSet;\r
-import java.util.List;\r
-import java.util.Set;\r
-\r
-import org.opendaylight.controller.sal.binding.model.api.Constant;\r
-import org.opendaylight.controller.sal.binding.model.api.Enumeration;\r
-import org.opendaylight.controller.sal.binding.model.api.Enumeration.Pair;\r
-import org.opendaylight.controller.sal.binding.model.api.GeneratedProperty;\r
-import org.opendaylight.controller.sal.binding.model.api.GeneratedTransferObject;\r
-import org.opendaylight.controller.sal.binding.model.api.MethodSignature;\r
-import org.opendaylight.controller.sal.binding.model.api.MethodSignature.Parameter;\r
-import org.opendaylight.controller.sal.binding.model.api.ParameterizedType;\r
-import org.opendaylight.controller.sal.binding.model.api.Type;\r
-\r
-public class GeneratorUtil {\r
-\r
-    private static final String[] SET_VALUES = new String[] { "abstract",\r
-            "assert", "boolean", "break", "byte", "case", "catch", "char",\r
-            "class", "const", "continue", "default", "double", "do", "else",\r
-            "enum", "extends", "false", "final", "finally", "float", "for",\r
-            "goto", "if", "implements", "import", "instanceof", "int",\r
-            "interface", "long", "native", "new", "null", "package", "private",\r
-            "protected", "public", "return", "short", "static", "strictfp",\r
-            "super", "switch", "synchronized", "this", "throw", "throws",\r
-            "transient", "true", "try", "void", "volatile", "while" };\r
-\r
-    public static final Set<String> JAVA_RESERVED_WORDS = new HashSet<String>(\r
-            Arrays.asList(SET_VALUES));\r
-\r
-    private GeneratorUtil() {\r
-    }\r
-\r
-    private static String validateParamName(final String paramName) {\r
-        if (paramName != null) {\r
-            if (JAVA_RESERVED_WORDS.contains(paramName)) {\r
-                return "_" + paramName;\r
-            }\r
-        }\r
-        return paramName;\r
-    }\r
-\r
-    public static String createIfcDeclarationWithPkgName(\r
-            final String packageName, final String name, final String indent) {\r
-        return createFileDeclarationWithPkgName(IFC,\r
-                packageName, validateParamName(name), indent);\r
-    }\r
-\r
-    public static String createClassDeclarationWithPkgName(\r
-            final String packageName, final String name, final String indent) {\r
-        return createFileDeclarationWithPkgName(CLASS,\r
-                packageName, validateParamName(name), indent);\r
-    }\r
-\r
-    private static String createFileDeclarationWithPkgName(final String type,\r
-            final String packageName, final String name, final String indent) {\r
-        final StringBuilder builder = new StringBuilder();\r
-        builder.append(PKG + GAP + packageName + SC);\r
-        builder.append(NL);\r
-        builder.append(NL);\r
-        builder.append(PUBLIC + GAP + type + GAP + validateParamName(name) + GAP + LCB);\r
-        return builder.toString();\r
-    }\r
-\r
-    public static String createConstant(final Constant constant,\r
-            final String indent) {\r
-        final StringBuilder builder = new StringBuilder();\r
-        builder.append(indent + PUBLIC + GAP + STATIC + GAP + FINAL + GAP);\r
-        builder.append(getExplicitType(constant.getType()) + GAP\r
-                + constant.getName());\r
-        builder.append(GAP + "=" + GAP);\r
-        builder.append(constant.getValue() + SC);\r
-        return builder.toString();\r
-    }\r
-\r
-    public static String createField(final GeneratedProperty property,\r
-            final String indent) {\r
-        final StringBuilder builder = new StringBuilder();\r
-        builder.append(indent + PRIVATE + GAP);\r
-        builder.append(getExplicitType(property.getReturnType()) + GAP\r
-                + property.getName());\r
-        builder.append(SC);\r
-        return builder.toString();\r
-    }\r
-\r
-    /**\r
-     * Create method declaration in interface.\r
-     * \r
-     * @param method\r
-     * @param indent\r
-     * @return\r
-     */\r
-    public static String createMethodDeclaration(final MethodSignature method,\r
-            final String indent) {\r
-        final String comment = method.getComment();\r
-        final Type type = method.getReturnType();\r
-        final String name = method.getName();\r
-        final List<Parameter> parameters = method.getParameters();\r
-\r
-        final StringBuilder builder = new StringBuilder();\r
-        createComment(builder, comment, indent);\r
-\r
-        builder.append(indent + getExplicitType(type) + GAP + name);\r
-        builder.append(LB);\r
-        for (int i = 0; i < parameters.size(); i++) {\r
-            Parameter p = parameters.get(i);\r
-            String separator = COMMA;\r
-            if (i + 1 == parameters.size()) {\r
-                separator = "";\r
-            }\r
-            builder.append(getExplicitType(p.getType()) + GAP + validateParamName(p.getName())\r
-                    + separator);\r
-        }\r
-        builder.append(RB);\r
-        builder.append(SC);\r
-\r
-        return builder.toString();\r
-    }\r
-\r
-    public static String createConstructor(\r
-            GeneratedTransferObject genTransferObject, final String indent) {\r
-        final StringBuilder builder = new StringBuilder();\r
-\r
-        final List<GeneratedProperty> properties = genTransferObject\r
-                .getProperties();\r
-        builder.append(indent);\r
-        builder.append(PUBLIC);\r
-        builder.append(GAP);\r
-        builder.append(genTransferObject.getName());\r
-        builder.append(LB);\r
-\r
-        boolean first = true;\r
-        if (properties != null) {\r
-            for (final GeneratedProperty property : properties) {\r
-                if (first) {\r
-                    builder.append(getExplicitType(property.getReturnType()));\r
-                    builder.append(" ");\r
-                    builder.append(property.getName());\r
-                    first = false;\r
-                } else {\r
-                    builder.append(", ");\r
-                    builder.append(getExplicitType(property.getReturnType()));\r
-                    builder.append(builder.append(" "));\r
-                    builder.append(property.getName());\r
-                }\r
-            }\r
-        }\r
-\r
-        builder.append(RB);\r
-        builder.append(GAP);\r
-        builder.append(LCB);\r
-        builder.append(NL);\r
-        builder.append(indent);\r
-        builder.append(TAB);\r
-        builder.append("super();");\r
-        builder.append(NL);\r
-\r
-        if (properties != null) {\r
-            for (final GeneratedProperty property : properties) {\r
-                builder.append(indent);\r
-                builder.append(TAB);\r
-                builder.append("this.");\r
-                builder.append(property.getName());\r
-                builder.append(" = ");\r
-                builder.append(property.getName());\r
-                builder.append(SC);\r
-                builder.append(NL);\r
-            }\r
-        }\r
-\r
-        builder.append(indent);\r
-        builder.append(RCB);\r
-\r
-        return builder.toString();\r
-    }\r
-\r
-    public static String createGetter(final GeneratedProperty property,\r
-            final String indent) {\r
-        final StringBuilder builder = new StringBuilder();\r
-\r
-        final Type type = property.getReturnType();\r
-        final String varName = property.getName();\r
-        final char first = Character.toUpperCase(varName.charAt(0));\r
-        final String methodName = "get" + first + varName.substring(1);\r
-\r
-        builder.append(indent + PUBLIC + GAP + getExplicitType(type) + GAP\r
-                + methodName);\r
-        builder.append(LB + RB + LCB + NL);\r
-\r
-        String currentIndent = indent + TAB;\r
-\r
-        builder.append(currentIndent + "return " + varName + SC + NL);\r
-\r
-        builder.append(indent + RCB);\r
-        return builder.toString();\r
-    }\r
-\r
-    public static String createHashCode(\r
-            final List<GeneratedProperty> properties, final String indent) {\r
-        StringBuilder builder = new StringBuilder();\r
-        builder.append(indent + "public int hashCode() {" + NL);\r
-        builder.append(indent + TAB + "final int prime = 31;" + NL);\r
-        builder.append(indent + TAB + "int result = 1;" + NL);\r
-\r
-        for (GeneratedProperty property : properties) {\r
-            String fieldName = property.getName();\r
-            builder.append(indent + TAB + "result = prime * result + (("\r
-                    + fieldName + " == null) ? 0 : " + fieldName\r
-                    + ".hashCode());" + NL);\r
-        }\r
-\r
-        builder.append(indent + TAB + "return result;" + NL);\r
-        builder.append(indent + RCB + NL);\r
-        return builder.toString();\r
-    }\r
-\r
-    public static String createEquals(final GeneratedTransferObject type,\r
-            final List<GeneratedProperty> properties, final String indent) {\r
-        StringBuilder builder = new StringBuilder();\r
-        final String indent1 = indent + TAB;\r
-        final String indent2 = indent + TAB + TAB;\r
-        final String indent3 = indent + TAB + TAB + TAB;\r
-\r
-        builder.append(indent + "public boolean equals(Object obj) {" + NL);\r
-        builder.append(indent1 + "if (this == obj) {" + NL);\r
-        builder.append(indent2 + "return true;" + NL);\r
-        builder.append(indent1 + "}" + NL);\r
-        builder.append(indent1 + "if (obj == null) {" + NL);\r
-        builder.append(indent2 + "return false;" + NL);\r
-        builder.append(indent1 + "}" + NL);\r
-        builder.append(indent1 + "if (getClass() != obj.getClass()) {" + NL);\r
-        builder.append(indent2 + "return false;" + NL);\r
-        builder.append(indent1 + "}" + NL);\r
-\r
-        String typeStr = type.getPackageName() + "." + type.getName();\r
-        builder.append(indent1 + typeStr + " other = (" + typeStr + ") obj;"\r
-                + NL);\r
-\r
-        for (GeneratedProperty property : properties) {\r
-            String fieldName = property.getName();\r
-            builder.append(indent1 + "if (" + fieldName + " == null) {" + NL);\r
-            builder.append(indent2 + "if (other." + fieldName + " != null) {"\r
-                    + NL);\r
-            builder.append(indent3 + "return false;" + NL);\r
-            builder.append(indent2 + "}" + NL);\r
-            builder.append(indent1 + "} else if (!" + fieldName\r
-                    + ".equals(other." + fieldName + ")) {" + NL);\r
-            builder.append(indent2 + "return false;" + NL);\r
-            builder.append(indent1 + "}" + NL);\r
-        }\r
-\r
-        builder.append(indent1 + "return true;" + NL);\r
-\r
-        builder.append(indent + RCB + NL);\r
-        return builder.toString();\r
-    }\r
-\r
-    public static String createToString(final GeneratedTransferObject type,\r
-            final List<GeneratedProperty> properties, final String indent) {\r
-        StringBuilder builder = new StringBuilder();\r
-        builder.append(indent);\r
-        builder.append("public String toString() {");\r
-        builder.append(NL);\r
-        builder.append(indent);\r
-        builder.append(TAB);\r
-        builder.append("StringBuilder builder = new StringBuilder();");\r
-        builder.append(NL);\r
-        builder.append(indent);\r
-        builder.append(TAB);\r
-        builder.append("builder.append(\"");\r
-        builder.append(type.getName());\r
-        builder.append(" [");\r
-\r
-        boolean first = true;\r
-        for (GeneratedProperty property : properties) {\r
-            if (first) {\r
-                builder.append(property.getName());\r
-                builder.append("=\");");\r
-                builder.append(NL);\r
-                builder.append(indent);\r
-                builder.append(TAB);\r
-                builder.append("builder.append(");\r
-                builder.append(property.getName());\r
-                builder.append(");");\r
-                first = false;\r
-            } else {\r
-                builder.append(NL);\r
-                builder.append(indent);\r
-                builder.append(TAB);\r
-                builder.append("builder.append(\", ");\r
-                builder.append(property.getName());\r
-                builder.append("=\");");\r
-                builder.append(NL);\r
-                builder.append(indent);\r
-                builder.append(TAB);\r
-                builder.append("builder.append(\", ");\r
-                builder.append(property.getName());\r
-                builder.append(");");\r
-            }\r
-        }\r
-        builder.append(NL);\r
-        builder.append(indent);\r
-        builder.append(TAB);\r
-        builder.append("builder.append(\"]\");");\r
-        builder.append(NL);\r
-        builder.append(indent);\r
-        builder.append(TAB);\r
-        builder.append("return builder.toString();");\r
-\r
-        builder.append(NL);\r
-        builder.append(indent);\r
-        builder.append(RCB);\r
-        builder.append(NL);\r
-        return builder.toString();\r
-    }\r
-\r
-    public static String createEnum(final Enumeration enumeration,\r
-            final String indent) {\r
-        final StringBuilder builder = new StringBuilder(indent + ENUM + GAP\r
-                + enumeration.getName() + GAP + LCB + NL);\r
-\r
-        String separator = COMMA;\r
-        final List<Pair> values = enumeration.getValues();\r
-        builder.append(indent + TAB);\r
-        for (int i = 0; i < values.size(); i++) {\r
-            if (i + 1 == values.size()) {\r
-                separator = SC;\r
-            }\r
-            builder.append(values.get(i).getName() + separator);\r
-        }\r
-        builder.append(NL);\r
-        builder.append(indent + RCB);\r
-        return builder.toString();\r
-    }\r
-\r
-    private static String getExplicitType(final Type type) {\r
-        String packageName = type.getPackageName();\r
-        if (packageName.endsWith(".")) {\r
-            packageName = packageName.substring(0, packageName.length() - 1);\r
-        }\r
-        final StringBuilder builder = new StringBuilder(packageName + "."\r
-                + type.getName());\r
-        if (type instanceof ParameterizedType) {\r
-            ParameterizedType pType = (ParameterizedType) type;\r
-            Type[] pTypes = pType.getActualTypeArguments();\r
-            builder.append("<");\r
-            builder.append(getParameters(pTypes));\r
-            builder.append(">");\r
-        }\r
-        if (builder.toString().equals("java.lang.Void")) {\r
-            return "void";\r
-        }\r
-        return builder.toString();\r
-    }\r
-\r
-    private static String getParameters(final Type[] pTypes) {\r
-        final StringBuilder builder = new StringBuilder();\r
-        for (int i = 0; i < pTypes.length; i++) {\r
-            Type t = pTypes[i];\r
-\r
-            String separator = COMMA;\r
-            if (i + 1 == pTypes.length) {\r
-                separator = "";\r
-            }\r
-            builder.append(getExplicitType(t) + separator);\r
-        }\r
-        return builder.toString();\r
-    }\r
-\r
-    private static void createComment(final StringBuilder builder,\r
-            final String comment, final String indent) {\r
-        if (comment != null && comment.length() > 0) {\r
-            builder.append(indent + "/*" + NL);\r
-            builder.append(indent + comment + NL);\r
-            builder.append(indent + "*/" + NL);\r
-        }\r
-    }\r
-\r
-}\r
+/*
+ * 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.java.api.generator;
+
+import static org.opendaylight.controller.sal.java.api.generator.Constants.CLASS;
+import static org.opendaylight.controller.sal.java.api.generator.Constants.COMMA;
+import static org.opendaylight.controller.sal.java.api.generator.Constants.ENUM;
+import static org.opendaylight.controller.sal.java.api.generator.Constants.FINAL;
+import static org.opendaylight.controller.sal.java.api.generator.Constants.GAP;
+import static org.opendaylight.controller.sal.java.api.generator.Constants.IFC;
+import static org.opendaylight.controller.sal.java.api.generator.Constants.LB;
+import static org.opendaylight.controller.sal.java.api.generator.Constants.LCB;
+import static org.opendaylight.controller.sal.java.api.generator.Constants.NL;
+import static org.opendaylight.controller.sal.java.api.generator.Constants.PKG;
+import static org.opendaylight.controller.sal.java.api.generator.Constants.PRIVATE;
+import static org.opendaylight.controller.sal.java.api.generator.Constants.PUBLIC;
+import static org.opendaylight.controller.sal.java.api.generator.Constants.RB;
+import static org.opendaylight.controller.sal.java.api.generator.Constants.RCB;
+import static org.opendaylight.controller.sal.java.api.generator.Constants.SC;
+import static org.opendaylight.controller.sal.java.api.generator.Constants.STATIC;
+import static org.opendaylight.controller.sal.java.api.generator.Constants.TAB;
+
+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.Enumeration.Pair;
+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.ParameterizedType;
+import org.opendaylight.controller.sal.binding.model.api.Type;
+
+public class GeneratorUtil {
+
+    private GeneratorUtil() {
+    }
+
+    public static String createIfcDeclarationWithPkgName(
+            final GeneratedType genType, final String indent) {
+        return createFileDeclarationWithPkgName(IFC, genType, indent);
+    }
+
+    public static String createClassDeclarationWithPkgName(
+            final GeneratedTransferObject genTransferObject, final String indent) {
+        return createFileDeclarationWithPkgName(CLASS, genTransferObject,
+                indent);
+    }
+
+    private static String createFileDeclarationWithPkgName(final String type,
+            final GeneratedType genType, final String indent) {
+        final StringBuilder builder = new StringBuilder();
+        builder.append(PKG + GAP + genType.getPackageName() + SC);
+        builder.append(NL);
+        builder.append(NL);
+
+        if (!genType.getAnnotations().isEmpty()) {
+            final List<AnnotationType> annotations = genType.getAnnotations();
+            appendAnnotations(builder, annotations);
+            builder.append(NL);
+        }
+        builder.append(PUBLIC + GAP + type + GAP + genType.getName() + GAP
+                + LCB);
+        return builder.toString();
+    }
+
+    private static StringBuilder appendAnnotations(final StringBuilder builder, final List<AnnotationType> annotations) {
+        if ((builder != null) && (annotations != null)) {
+            for (final AnnotationType annotation : annotations) {
+                builder.append("@");
+                builder.append(annotation.getPackageName());
+                builder.append(".");
+                builder.append(annotation.getName());
+
+                if (annotation.containsParameters()) {
+                    builder.append("(");
+                    final List<AnnotationType.Parameter> parameters = annotation
+                            .getParameters();
+                    appendAnnotationParams(builder, parameters);
+                    builder.append(")");
+                }
+            }
+        }
+        return builder;
+    }
+
+    private static StringBuilder appendAnnotationParams(
+            final StringBuilder builder,
+            final List<AnnotationType.Parameter> parameters) {
+        if (parameters != null) {
+            int i = 0;
+            for (final AnnotationType.Parameter param : parameters) {
+                if (param == null) {
+                    continue;
+                }
+                if (i > 0) {
+                    builder.append(", ");
+                }
+                final String paramName = param.getName();
+                if (param.getValue() != null) {
+                    builder.append(paramName);
+                    builder.append(" = ");
+                    builder.append(param.getValue());
+                } else {
+                    builder.append(paramName);
+                    builder.append(" = {");
+                    final List<String> values = param.getValues();
+                    builder.append(values.get(0));
+                    for (int j = 1; j < values.size(); ++j) {
+                        builder.append(", ");
+                        builder.append(values.get(j));
+                    }
+                    builder.append("}");
+                }
+                i++;
+            }
+        }
+        return builder;
+    }
+
+    public static String createConstant(final Constant constant,
+            final String indent) {
+        final StringBuilder builder = new StringBuilder();
+        builder.append(indent + PUBLIC + GAP + STATIC + GAP + FINAL + GAP);
+        builder.append(getExplicitType(constant.getType()) + GAP
+                + constant.getName());
+        builder.append(GAP + "=" + GAP);
+        builder.append(constant.getValue() + SC);
+        return builder.toString();
+    }
+
+    public static String createField(final GeneratedProperty property,
+            final String indent) {
+        final StringBuilder builder = new StringBuilder();
+        builder.append(indent);
+        if (!property.getAnnotations().isEmpty()) {
+            final List<AnnotationType> annotations = property.getAnnotations();
+            appendAnnotations(builder, annotations);
+            builder.append(NL);
+        }
+        builder.append(indent + PRIVATE + GAP);
+        builder.append(getExplicitType(property.getReturnType()) + GAP
+                + property.getName());
+        builder.append(SC);
+        return builder.toString();
+    }
+
+    /**
+     * Create method declaration in interface.
+     * 
+     * @param method
+     * @param indent
+     * @return
+     */
+    public static String createMethodDeclaration(final MethodSignature method,
+            final String indent) {
+        final String comment = method.getComment();
+        final Type type = method.getReturnType();
+        final String name = method.getName();
+        final List<Parameter> parameters = method.getParameters();
+
+        final StringBuilder builder = new StringBuilder();
+        createComment(builder, comment, indent);
+        builder.append(NL);
+        builder.append(indent);
+        
+        if (!method.getAnnotations().isEmpty()) {
+            final List<AnnotationType> annotations = method.getAnnotations();
+            appendAnnotations(builder, annotations);
+            builder.append(NL);
+        }
+        
+        builder.append(indent + getExplicitType(type) + GAP + name);
+        builder.append(LB);
+        for (int i = 0; i < parameters.size(); i++) {
+            Parameter p = parameters.get(i);
+            String separator = COMMA;
+            if (i + 1 == parameters.size()) {
+                separator = "";
+            }
+            builder.append(getExplicitType(p.getType()) + GAP + p.getName()
+                    + separator);
+        }
+        builder.append(RB);
+        builder.append(SC);
+
+        return builder.toString();
+    }
+
+    public static String createConstructor(
+            GeneratedTransferObject genTransferObject, final String indent) {
+        final StringBuilder builder = new StringBuilder();
+
+        final List<GeneratedProperty> properties = genTransferObject
+                .getProperties();
+        builder.append(indent);
+        builder.append(PUBLIC);
+        builder.append(GAP);
+        builder.append(genTransferObject.getName());
+        builder.append(LB);
+
+        boolean first = true;
+        if (properties != null) {
+            for (final GeneratedProperty property : properties) {
+                if (first) {
+                    builder.append(getExplicitType(property.getReturnType()));
+                    builder.append(" ");
+                    builder.append(property.getName());
+                    first = false;
+                } else {
+                    builder.append(", ");
+                    builder.append(getExplicitType(property.getReturnType()));
+                    builder.append(builder.append(" "));
+                    builder.append(property.getName());
+                }
+            }
+        }
+
+        builder.append(RB);
+        builder.append(GAP);
+        builder.append(LCB);
+        builder.append(NL);
+        builder.append(indent);
+        builder.append(TAB);
+        builder.append("super();");
+        builder.append(NL);
+
+        if (properties != null) {
+            for (final GeneratedProperty property : properties) {
+                builder.append(indent);
+                builder.append(TAB);
+                builder.append("this.");
+                builder.append(property.getName());
+                builder.append(" = ");
+                builder.append(property.getName());
+                builder.append(SC);
+                builder.append(NL);
+            }
+        }
+
+        builder.append(indent);
+        builder.append(RCB);
+
+        return builder.toString();
+    }
+
+    public static String createGetter(final GeneratedProperty property,
+            final String indent) {
+        final StringBuilder builder = new StringBuilder();
+
+        final Type type = property.getReturnType();
+        final String varName = property.getName();
+        final char first = Character.toUpperCase(varName.charAt(0));
+        final String methodName = "get" + first + varName.substring(1);
+
+        builder.append(indent + PUBLIC + GAP + getExplicitType(type) + GAP
+                + methodName);
+        builder.append(LB + RB + LCB + NL);
+
+        String currentIndent = indent + TAB;
+
+        builder.append(currentIndent + "return " + varName + SC + NL);
+
+        builder.append(indent + RCB);
+        return builder.toString();
+    }
+
+    public static String createHashCode(
+            final List<GeneratedProperty> properties, final String indent) {
+        StringBuilder builder = new StringBuilder();
+        builder.append(indent + "public int hashCode() {" + NL);
+        builder.append(indent + TAB + "final int prime = 31;" + NL);
+        builder.append(indent + TAB + "int result = 1;" + NL);
+
+        for (GeneratedProperty property : properties) {
+            String fieldName = property.getName();
+            builder.append(indent + TAB + "result = prime * result + (("
+                    + fieldName + " == null) ? 0 : " + fieldName
+                    + ".hashCode());" + NL);
+        }
+
+        builder.append(indent + TAB + "return result;" + NL);
+        builder.append(indent + RCB + NL);
+        return builder.toString();
+    }
+
+    public static String createEquals(final GeneratedTransferObject type,
+            final List<GeneratedProperty> properties, final String indent) {
+        StringBuilder builder = new StringBuilder();
+        final String indent1 = indent + TAB;
+        final String indent2 = indent + TAB + TAB;
+        final String indent3 = indent + TAB + TAB + TAB;
+
+        builder.append(indent + "public boolean equals(Object obj) {" + NL);
+        builder.append(indent1 + "if (this == obj) {" + NL);
+        builder.append(indent2 + "return true;" + NL);
+        builder.append(indent1 + "}" + NL);
+        builder.append(indent1 + "if (obj == null) {" + NL);
+        builder.append(indent2 + "return false;" + NL);
+        builder.append(indent1 + "}" + NL);
+        builder.append(indent1 + "if (getClass() != obj.getClass()) {" + NL);
+        builder.append(indent2 + "return false;" + NL);
+        builder.append(indent1 + "}" + NL);
+
+        String typeStr = type.getPackageName() + "." + type.getName();
+        builder.append(indent1 + typeStr + " other = (" + typeStr + ") obj;"
+                + NL);
+
+        for (GeneratedProperty property : properties) {
+            String fieldName = property.getName();
+            builder.append(indent1 + "if (" + fieldName + " == null) {" + NL);
+            builder.append(indent2 + "if (other." + fieldName + " != null) {"
+                    + NL);
+            builder.append(indent3 + "return false;" + NL);
+            builder.append(indent2 + "}" + NL);
+            builder.append(indent1 + "} else if (!" + fieldName
+                    + ".equals(other." + fieldName + ")) {" + NL);
+            builder.append(indent2 + "return false;" + NL);
+            builder.append(indent1 + "}" + NL);
+        }
+
+        builder.append(indent1 + "return true;" + NL);
+
+        builder.append(indent + RCB + NL);
+        return builder.toString();
+    }
+
+    public static String createToString(final GeneratedTransferObject type,
+            final List<GeneratedProperty> properties, final String indent) {
+        StringBuilder builder = new StringBuilder();
+        builder.append(indent);
+        builder.append("public String toString() {");
+        builder.append(NL);
+        builder.append(indent);
+        builder.append(TAB);
+        builder.append("StringBuilder builder = new StringBuilder();");
+        builder.append(NL);
+        builder.append(indent);
+        builder.append(TAB);
+        builder.append("builder.append(\"");
+        builder.append(type.getName());
+        builder.append(" [");
+
+        boolean first = true;
+        for (GeneratedProperty property : properties) {
+            if (first) {
+                builder.append(property.getName());
+                builder.append("=\");");
+                builder.append(NL);
+                builder.append(indent);
+                builder.append(TAB);
+                builder.append("builder.append(");
+                builder.append(property.getName());
+                builder.append(");");
+                first = false;
+            } else {
+                builder.append(NL);
+                builder.append(indent);
+                builder.append(TAB);
+                builder.append("builder.append(\", ");
+                builder.append(property.getName());
+                builder.append("=\");");
+                builder.append(NL);
+                builder.append(indent);
+                builder.append(TAB);
+                builder.append("builder.append(\", ");
+                builder.append(property.getName());
+                builder.append(");");
+            }
+        }
+        builder.append(NL);
+        builder.append(indent);
+        builder.append(TAB);
+        builder.append("builder.append(\"]\");");
+        builder.append(NL);
+        builder.append(indent);
+        builder.append(TAB);
+        builder.append("return builder.toString();");
+
+        builder.append(NL);
+        builder.append(indent);
+        builder.append(RCB);
+        builder.append(NL);
+        return builder.toString();
+    }
+
+    public static String createEnum(final Enumeration enumeration,
+            final String indent) {
+        final StringBuilder builder = new StringBuilder(indent + ENUM + GAP
+                + enumeration.getName() + GAP + LCB + NL);
+
+        String separator = COMMA;
+        final List<Pair> values = enumeration.getValues();
+        builder.append(indent + TAB);
+        for (int i = 0; i < values.size(); i++) {
+            if (i + 1 == values.size()) {
+                separator = SC;
+            }
+            builder.append(values.get(i).getName() + separator);
+        }
+        builder.append(NL);
+        builder.append(indent + RCB);
+        return builder.toString();
+    }
+
+    private static String getExplicitType(final Type type) {
+        String packageName = type.getPackageName();
+        if (packageName.endsWith(".")) {
+            packageName = packageName.substring(0, packageName.length() - 1);
+        }
+        final StringBuilder builder = new StringBuilder(packageName + "."
+                + type.getName());
+        if (type instanceof ParameterizedType) {
+            ParameterizedType pType = (ParameterizedType) type;
+            Type[] pTypes = pType.getActualTypeArguments();
+            builder.append("<");
+            builder.append(getParameters(pTypes));
+            builder.append(">");
+        }
+        if (builder.toString().equals("java.lang.Void")) {
+            return "void";
+        }
+        return builder.toString();
+    }
+
+    private static String getParameters(final Type[] pTypes) {
+        final StringBuilder builder = new StringBuilder();
+        for (int i = 0; i < pTypes.length; i++) {
+            Type t = pTypes[i];
+
+            String separator = COMMA;
+            if (i + 1 == pTypes.length) {
+                separator = "";
+            }
+            builder.append(getExplicitType(t) + separator);
+        }
+        return builder.toString();
+    }
+
+    private static void createComment(final StringBuilder builder,
+            final String comment, final String indent) {
+        if (comment != null && comment.length() > 0) {
+            builder.append(indent + "/*" + NL);
+            builder.append(indent + comment + NL);
+            builder.append(indent + "*/" + NL);
+        }
+    }
+
+}
index a947866..bb5b91b 100644 (file)
@@ -1,67 +1,69 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.sal.java.api.generator;\r
-\r
-import static org.opendaylight.controller.sal.java.api.generator.Constants.NL;\r
-import static org.opendaylight.controller.sal.java.api.generator.Constants.RCB;\r
-import static org.opendaylight.controller.sal.java.api.generator.Constants.TAB;\r
-\r
-import java.io.IOException;\r
-import java.io.StringWriter;\r
-import java.io.Writer;\r
-import java.util.List;\r
-\r
-import org.opendaylight.controller.sal.binding.model.api.CodeGenerator;\r
-import org.opendaylight.controller.sal.binding.model.api.Constant;\r
-import org.opendaylight.controller.sal.binding.model.api.Enumeration;\r
-import org.opendaylight.controller.sal.binding.model.api.GeneratedType;\r
-import org.opendaylight.controller.sal.binding.model.api.MethodSignature;\r
-import org.opendaylight.controller.sal.binding.model.api.Type;\r
-\r
-public class InterfaceGenerator implements CodeGenerator {\r
-\r
-    public Writer generate(Type type) throws IOException {\r
-        Writer writer = new StringWriter();\r
-        if (type instanceof GeneratedType) {\r
-            GeneratedType genType = (GeneratedType) type;\r
-            \r
-            final List<Constant> constants = genType.getConstantDefinitions();\r
-            final List<MethodSignature> methods = genType.getMethodDefinitions();\r
-            final List<Enumeration> enums = genType.getEnumDefintions();\r
-\r
-            writer.write(GeneratorUtil.createIfcDeclarationWithPkgName(\r
-                    type.getPackageName(), type.getName(), ""));\r
-            writer.write(NL);\r
-\r
-            if (constants != null) {\r
-                for (Constant c : constants) {\r
-                    writer.write(GeneratorUtil.createConstant(c, TAB) + NL);\r
-                }\r
-                writer.write(NL);\r
-            }\r
-\r
-            if (methods != null) {\r
-                for (MethodSignature m : methods) {\r
-                    writer.write(GeneratorUtil.createMethodDeclaration(m, TAB) + NL);\r
-                }\r
-                writer.write(NL);\r
-            }\r
-\r
-            if (enums != null) {\r
-                for (Enumeration e : enums) {\r
-                    writer.write(GeneratorUtil.createEnum(e, TAB) + NL);\r
-                }\r
-                writer.write(NL);\r
-            }\r
-\r
-            writer.write(RCB);\r
-        }\r
-        return writer;\r
-    }\r
-\r
-}\r
+/*
+ * 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.java.api.generator;
+
+import static org.opendaylight.controller.sal.java.api.generator.Constants.NL;
+import static org.opendaylight.controller.sal.java.api.generator.Constants.RCB;
+import static org.opendaylight.controller.sal.java.api.generator.Constants.TAB;
+
+import java.io.IOException;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.util.List;
+
+import org.opendaylight.controller.sal.binding.model.api.CodeGenerator;
+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;
+
+public class InterfaceGenerator implements CodeGenerator {
+
+    public Writer generate(Type type) throws IOException {
+        Writer writer = new StringWriter();
+        if (type instanceof GeneratedType) {
+            GeneratedType genType = (GeneratedType) type;
+
+            final List<Constant> constants = genType.getConstantDefinitions();
+            final List<MethodSignature> methods = genType
+                    .getMethodDefinitions();
+            final List<Enumeration> enums = genType.getEnumDefintions();
+
+            writer.write(GeneratorUtil.createIfcDeclarationWithPkgName(genType,
+                    ""));
+            writer.write(NL);
+
+            if (constants != null) {
+                for (Constant c : constants) {
+                    writer.write(GeneratorUtil.createConstant(c, TAB) + NL);
+                }
+                writer.write(NL);
+            }
+
+            if (methods != null) {
+                for (MethodSignature m : methods) {
+                    writer.write(GeneratorUtil.createMethodDeclaration(m, TAB)
+                            + NL);
+                }
+                writer.write(NL);
+            }
+
+            if (enums != null) {
+                for (Enumeration e : enums) {
+                    writer.write(GeneratorUtil.createEnum(e, TAB) + NL);
+                }
+                writer.write(NL);
+            }
+
+            writer.write(RCB);
+        }
+        return writer;
+    }
+
+}
diff --git a/opendaylight/sal/yang-prototype/code-generator/binding-model-api/src/main/java/org/opendaylight/controller/sal/binding/model/api/AnnotationType.java b/opendaylight/sal/yang-prototype/code-generator/binding-model-api/src/main/java/org/opendaylight/controller/sal/binding/model/api/AnnotationType.java
new file mode 100644 (file)
index 0000000..7868675
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * 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 AnnotationType extends Type {
+    
+    public List<AnnotationType> getAnnotations();
+    
+    public Parameter getParameter(final String paramName);
+    
+    public List<Parameter> getParameters();
+    
+    public List<String> getParameterNames();
+    
+    public boolean containsParameters();
+    
+    interface Parameter {
+        
+        public String getName();
+        
+        public String getValue();
+        
+        public List<String> getValues();
+    }
+}
index bfce017..996423b 100644 (file)
@@ -1,26 +1,28 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.sal.binding.model.api;\r
-\r
-import java.util.List;\r
-\r
-public interface Enumeration extends Type {\r
-\r
-    public Type getDefiningType();\r
-\r
-    public List<Pair> getValues();\r
-\r
-    public String toFormattedString();\r
-\r
-    interface Pair {\r
-\r
-        public String getName();\r
-\r
-        public Integer getValue();\r
-    }\r
-}\r
+/*
+ * 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 Enumeration extends Type {
+    
+    public List<AnnotationType> getAnnotations();
+    
+    public Type getDefiningType();
+
+    public List<Pair> getValues();
+
+    public String toFormattedString();
+
+    interface Pair {
+
+        public String getName();
+
+        public Integer getValue();
+    }
+}
index 4bed98a..95a1ec9 100644 (file)
@@ -8,16 +8,8 @@
 package org.opendaylight.controller.sal.binding.model.api;
 
 import java.util.List;
-import java.util.Set;
 
-public interface GeneratedTransferObject extends Type {
-    
-    /**
-     * Returns Set of all Enumerator definitions associated with interface.
-     * 
-     * @return Set of all Enumerator definitions associated with interface.
-     */
-    public List<Enumeration> getEnumDefintions();
+public interface GeneratedTransferObject extends GeneratedType {
     
     public List<GeneratedProperty> getProperties();
     
index 5382311..2f70ac5 100644 (file)
@@ -1,56 +1,60 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.sal.binding.model.api;\r
-\r
-import java.util.List;\r
-\r
-/**\r
- * Every Java interface has to be specified with:\r
- * <ul>\r
- * <li><code>package</code> that belongs into</li>\r
- * <li><code>interface</code> name (with commentary that <b>SHOULD</b> be\r
- * present to proper define interface and base <i>contracts</i> specified for\r
- * interface)</li>\r
- * <li><code>enum</code> and <code>constant</code> definitions (i.e. each\r
- * constant definition is by default defined as <code>public static final</code>\r
- * + type (either primitive or object) and constant name</li>\r
- * <li><code>method definitions</code> with specified input parameters (with\r
- * types) and return values</li>\r
- * </ul>\r
- * \r
- * By the definition of the interface constant, enum and method definitions MUST\r
- * be public, so there is no need to specify the scope of visibility.\r
- * \r
- * \r
- */\r
-public interface GeneratedType extends Type {\r
-\r
-    public Type getParentType();\r
-\r
-    /**\r
-     * Returns Set of all Enumerator definitions associated with interface.\r
-     * \r
-     * @return Set of all Enumerator definitions associated with interface.\r
-     */\r
-    public List<Enumeration> getEnumDefintions();\r
-\r
-    /**\r
-     * \r
-     * \r
-     * @return\r
-     */\r
-    public List<Constant> getConstantDefinitions();\r
-\r
-    /**\r
-     * \r
-     * \r
-     * @return\r
-     */\r
-    public List<MethodSignature> getMethodDefinitions();\r
-\r
-}\r
+/*
+ * 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;
+
+/**
+ * Every Java interface has to be specified with:
+ * <ul>
+ * <li><code>package</code> that belongs into</li>
+ * <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><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>
+ * <li><code>method definitions</code> with specified input parameters (with
+ * types) and return values</li>
+ * </ul>
+ * 
+ * By the definition of the interface constant, enum and method definitions MUST
+ * be public, so there is no need to specify the scope of visibility.
+ * 
+ * 
+ */
+public interface GeneratedType extends Type {
+
+    public Type getParentType();
+    
+    public String getComment();
+    
+    public List<AnnotationType> getAnnotations();
+    
+    /**
+     * Returns Set of all Enumerator definitions associated with interface.
+     * 
+     * @return Set of all Enumerator definitions associated with interface.
+     */
+    public List<Enumeration> getEnumDefintions();
+
+    /**
+     * 
+     * 
+     * @return
+     */
+    public List<Constant> getConstantDefinitions();
+
+    /**
+     * 
+     * 
+     * @return
+     */
+    public List<MethodSignature> getMethodDefinitions();
+
+}
index 603ffdb..dda1f01 100644 (file)
@@ -1,31 +1,33 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.sal.binding.model.api;\r
-\r
-import java.util.List;\r
-\r
-public interface MethodSignature {\r
-\r
-    public String getName();\r
-\r
-    public String getComment();\r
-\r
-    public Type getDefiningType();\r
-\r
-    public Type getReturnType();\r
-\r
-    public List<Parameter> getParameters();\r
-\r
-    public AccessModifier getAccessModifier();\r
-\r
-    interface Parameter {\r
-        public String getName();\r
-\r
-        public Type getType();\r
-    }\r
-}\r
+/*
+ * 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 MethodSignature {
+    
+    public List<AnnotationType> getAnnotations();
+    
+    public String getName();
+
+    public String getComment();
+
+    public Type getDefiningType();
+
+    public Type getReturnType();
+
+    public List<Parameter> getParameters();
+
+    public AccessModifier getAccessModifier();
+
+    interface Parameter {
+        public String getName();
+
+        public Type getType();
+    }
+}
diff --git a/opendaylight/sal/yang-prototype/code-generator/binding-model-api/src/main/java/org/opendaylight/controller/sal/binding/model/api/type/builder/AnnotationTypeBuilder.java b/opendaylight/sal/yang-prototype/code-generator/binding-model-api/src/main/java/org/opendaylight/controller/sal/binding/model/api/type/builder/AnnotationTypeBuilder.java
new file mode 100644 (file)
index 0000000..6016274
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * 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.type.builder;
+
+import java.util.List;
+
+import org.opendaylight.controller.sal.binding.model.api.AnnotationType;
+import org.opendaylight.controller.sal.binding.model.api.Type;
+
+public interface AnnotationTypeBuilder extends Type {
+    
+    public AnnotationTypeBuilder addAnnotation(final String packageName, final String name);
+    
+    public boolean addParameter(final String paramName, String value);
+    
+    public boolean addParameters(final String paramName, List<String> values);
+    
+    public AnnotationType toInstance();
+}
index 114a82a..9716c60 100644 (file)
@@ -16,6 +16,8 @@ import org.opendaylight.controller.sal.binding.model.api.Type;
  */
 public interface EnumBuilder extends Type {
     
+    public AnnotationTypeBuilder addAnnotation(final String packageName, final String name);
+    
     public void addValue(final String name, final Integer value);
 
     public Enumeration toInstance(final Type definingType);
index c01e740..fd64cec 100644 (file)
@@ -1,33 +1,35 @@
-/*\r
-  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
-  *\r
-  * This program and the accompanying materials are made available under the\r
-  * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
-  * and is available at http://www.eclipse.org/legal/epl-v10.html\r
-  */\r
-package org.opendaylight.controller.sal.binding.model.api.type.builder;\r
-\r
-import org.opendaylight.controller.sal.binding.model.api.AccessModifier;\r
-import org.opendaylight.controller.sal.binding.model.api.GeneratedProperty;\r
-import org.opendaylight.controller.sal.binding.model.api.Type;\r
-\r
-/**\r
-\r
- *\r
- */\r
-public interface GeneratedPropertyBuilder {\r
-    \r
-    public String getName();\r
-    \r
-    public boolean addReturnType(final Type returnType);\r
-    \r
-    public void accessorModifier(final AccessModifier modifier);\r
-    \r
-    public void addComment(final String comment);\r
-    \r
-    public void setFinal(final boolean isFinal);\r
-    \r
-    public void setReadOnly(final boolean isReadOnly);\r
-    \r
-    public GeneratedProperty toInstance(final Type definingType);\r
-}\r
+/*
+  * 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.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;
+
+/**
+
+ *
+ */
+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 void setReadOnly(final boolean isReadOnly);
+    
+    public GeneratedProperty toInstance(final Type definingType);
+}
index ff55fe5..2fc4ccf 100644 (file)
@@ -1,30 +1,27 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.sal.binding.model.api.type.builder;\r
-\r
-import org.opendaylight.controller.sal.binding.model.api.GeneratedTransferObject;\r
-import org.opendaylight.controller.sal.binding.model.api.Type;\r
-\r
-/**\r
-\r
- *\r
- */\r
-public interface GeneratedTOBuilder extends Type {\r
-\r
-    public EnumBuilder addEnumeration(final String name);\r
-\r
-    public GeneratedPropertyBuilder addProperty(final String name);\r
-\r
-    public boolean addEqualsIdentity(final GeneratedPropertyBuilder property);\r
-\r
-    public boolean addHashIdentity(final GeneratedPropertyBuilder property);\r
-\r
-    public boolean addToStringProperty(final GeneratedPropertyBuilder property);\r
-\r
-    public GeneratedTransferObject toInstance();\r
-}\r
+/*
+ * 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.type.builder;
+
+import org.opendaylight.controller.sal.binding.model.api.GeneratedTransferObject;
+
+/**
+
+ */
+public interface GeneratedTOBuilder extends GeneratedTypeBuilder {
+
+    public GeneratedPropertyBuilder addProperty(final String name);
+
+    public boolean addEqualsIdentity(final GeneratedPropertyBuilder property);
+
+    public boolean addHashIdentity(final GeneratedPropertyBuilder property);
+
+    public boolean addToStringProperty(final GeneratedPropertyBuilder property);
+
+    @Override
+    public GeneratedTransferObject toInstance();
+}
index 6b21250..55c6abc 100644 (file)
@@ -1,31 +1,33 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.sal.binding.model.api.type.builder;\r
-\r
-import org.opendaylight.controller.sal.binding.model.api.GeneratedType;\r
-import org.opendaylight.controller.sal.binding.model.api.Type;\r
-\r
-/**\r
-\r
- *\r
- */\r
-public interface GeneratedTypeBuilder extends Type {\r
-\r
-    public Type getParentType();\r
-\r
-    public void addComment(final String comment);\r
-\r
-    public ConstantBuilder addConstant(final Type type, final String name,\r
-            final Object value);\r
-\r
-    public EnumBuilder addEnumeration(final String name);\r
-\r
-    public MethodSignatureBuilder addMethod(final String name);\r
-\r
-    public GeneratedType toInstance();\r
-}\r
+/*
+ * 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.type.builder;
+
+import org.opendaylight.controller.sal.binding.model.api.GeneratedType;
+import org.opendaylight.controller.sal.binding.model.api.Type;
+
+/**
+
+ *
+ */
+public interface GeneratedTypeBuilder extends Type {
+
+    public Type getParentType();
+
+    public void addComment(final String comment);
+    
+    public AnnotationTypeBuilder addAnnotation(final String packageName, final String name);
+    
+    public ConstantBuilder addConstant(final Type type, final String name,
+            final Object value);
+
+    public EnumBuilder addEnumeration(final String name);
+
+    public MethodSignatureBuilder addMethod(final String name);
+
+    public GeneratedType toInstance();
+}
index 349a342..572d15f 100644 (file)
@@ -1,23 +1,25 @@
-/**\r
-\r
- *\r
- * March 2013\r
- *\r
- * Copyright (c) 2013 by Cisco Systems, Inc.\r
- * All rights reserved.\r
- */\r
-package org.opendaylight.controller.sal.binding.model.api.type.builder;\r
-\r
-import org.opendaylight.controller.sal.binding.model.api.MethodSignature;\r
-import org.opendaylight.controller.sal.binding.model.api.Type;\r
-\r
-public interface MethodSignatureBuilder {\r
-\r
-    public void addReturnType(final Type returnType);\r
-\r
-    public void addParameter(final Type type, final String name);\r
-\r
-    public void addComment(final String comment);\r
-\r
-    public MethodSignature toInstance(final Type definingType);\r
-}\r
+/**
+
+ *
+ * March 2013
+ *
+ * Copyright (c) 2013 by Cisco Systems, Inc.
+ * All rights reserved.
+ */
+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);
+
+    public void addParameter(final Type type, final String name);
+
+    public void addComment(final String comment);
+
+    public MethodSignature toInstance(final Type definingType);
+}

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.