Updated binding model 74/974/2
authorTony Tkacik <ttkacik@cisco.com>
Fri, 23 Aug 2013 07:30:57 +0000 (09:30 +0200)
committerTony Tkacik <ttkacik@cisco.com>
Fri, 23 Aug 2013 08:15:35 +0000 (10:15 +0200)
 - Added properties to GeneratedType
 - Cleaned up implementation of Type Builders
 - renamed getExtends to getSuperType

Change-Id: I8c20747e346fb7b81c196b6405bc63ee28a86f08
Signed-off-by: Tony Tkacik <ttkacik@cisco.com>
14 files changed:
code-generator/binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/generator/impl/BindingGeneratorImpl.java
code-generator/binding-generator-impl/src/test/java/org/opendaylight/yangtools/sal/binding/generator/impl/ExtendedTypedefTest.java
code-generator/binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/AbstractBaseType.java
code-generator/binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/AbstractGeneratedType.java
code-generator/binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/AbstractGeneratedTypeBuilder.java
code-generator/binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/EnumerationBuilderImpl.java
code-generator/binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/GeneratedTOBuilderImpl.java
code-generator/binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/GeneratedTypeBuilderImpl.java
code-generator/binding-java-api-generator/src/main/java/org/opendaylight/yangtools/sal/java/api/generator/ClassTemplate.xtend
code-generator/binding-java-api-generator/src/main/java/org/opendaylight/yangtools/sal/java/api/generator/GeneratorUtil.java
code-generator/binding-model-api/src/main/java/org/opendaylight/yangtools/sal/binding/model/api/GeneratedTransferObject.java
code-generator/binding-model-api/src/main/java/org/opendaylight/yangtools/sal/binding/model/api/GeneratedType.java
code-generator/binding-model-api/src/main/java/org/opendaylight/yangtools/sal/binding/model/api/type/builder/GeneratedTOBuilder.java
code-generator/binding-model-api/src/main/java/org/opendaylight/yangtools/sal/binding/model/api/type/builder/GeneratedTypeBuilder.java

index 9e14532d5a50a0118e89e66ad4d4b5f1898045b1..e4660f583c9ff50356781be263bb2c26d1116612 100644 (file)
@@ -1749,6 +1749,7 @@ public final class BindingGeneratorImpl implements BindingGenerator {
      */\r
     private MethodSignatureBuilder constructGetter(final GeneratedTypeBuilder interfaceBuilder,\r
             final String schemaNodeName, final String comment, final Type returnType) {\r
+        \r
         final MethodSignatureBuilder getMethod = interfaceBuilder.addMethod(getterMethodName(schemaNodeName,returnType));\r
 \r
         getMethod.setComment(comment);\r
@@ -1757,40 +1758,6 @@ public final class BindingGeneratorImpl implements BindingGenerator {
         return getMethod;\r
     }\r
 \r
-    /**\r
-     * Creates a method signature builder as a part of\r
-     * <code>interfaceBuilder</code> for <code>schemaNodeName</code>\r
-     *\r
-     * The method signature builder is created for the setter method of\r
-     * <code>schemaNodeName</code>. Also <code>comment</code>\r
-     * <code>parameterType</code> data are added to the builder. The return type\r
-     * of the method is set to <code>void</code>.\r
-     *\r
-     * @param interfaceBuilder\r
-     *            generated type builder for which the setter method should be\r
-     *            created\r
-     * @param schemaNodeName\r
-     *            string with schema node name. The name will be the part of the\r
-     *            setter method name.\r
-     * @param comment\r
-     *            string with comment for the setter method\r
-     * @param parameterType\r
-     *            type which represents the type of the setter method input\r
-     *            parameter\r
-     * @return method signature builder which represents the setter method of\r
-     *         <code>interfaceBuilder</code>\r
-     */\r
-    private MethodSignatureBuilder constructSetter(final GeneratedTypeBuilder interfaceBuilder,\r
-            final String schemaNodeName, final String comment, final Type parameterType) {\r
-        final MethodSignatureBuilder setMethod = interfaceBuilder.addMethod(setterMethodName(schemaNodeName));\r
-\r
-        setMethod.setComment(comment);\r
-        setMethod.addParameter(parameterType, parseToValidParamName(schemaNodeName));\r
-        setMethod.setReturnType(Types.voidType());\r
-\r
-        return setMethod;\r
-    }\r
-\r
     private List<Type> listToGenType(final String basePackageName, final ListSchemaNode list) {\r
         Preconditions.checkArgument(basePackageName != null,"Package Name for Generated Type cannot be NULL.");\r
         Preconditions.checkArgument(list != null,"List Schema Node cannot be NULL.");\r
index 15be6a47b7dee82d09ad81dab2cf05bb607ee3b4..a08a9bbf3ed42efcc62be4a2a04f0e54539a2ce6 100644 (file)
-package org.opendaylight.yangtools.sal.binding.generator.impl;
-
-import static org.junit.Assert.*;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;
-import org.opendaylight.yangtools.sal.binding.model.api.GeneratedProperty;
-import org.opendaylight.yangtools.sal.binding.model.api.GeneratedTransferObject;
-import org.opendaylight.yangtools.sal.binding.model.api.Type;
-import org.opendaylight.yangtools.sal.binding.yang.types.BaseYangTypes;
-import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
-import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
-
-public class ExtendedTypedefTest {
-
-    private final static List<File> testModels = new ArrayList<File>();
-    private final static String testFolderPath = AugmentedTypeTest.class.getResource("/typedef-of-typedef").getPath();
-
-    @BeforeClass
-    public static void loadTestResources() {
-        final File testFolder = new File(testFolderPath);
-
-        for (final File fileEntry : testFolder.listFiles()) {
-            if (fileEntry.isFile()) {
-                testModels.add(fileEntry);
-            }
-        }
-    }
-
-    @Test
-    public void constantGenerationTest() {
-        final YangModelParser parser = new YangParserImpl();
-        final Set<Module> modules = parser.parseYangModels(testModels);
-        final SchemaContext context = parser.resolveSchemaContext(modules);
-
-        assertNotNull(context);
-        final BindingGenerator bindingGen = new BindingGeneratorImpl();
-        final List<Type> genTypes = bindingGen.generateTypes(context);
-
-        GeneratedTransferObject simpleTypedef4 = null;
-        GeneratedTransferObject extendedTypedefUnion = null;
-        GeneratedTransferObject unionTypedef = null;
-        GeneratedTransferObject typedefFromImport = null;
-        for (final Type type : genTypes) {
-            if (type instanceof GeneratedTransferObject) {
-                if (type.getName().equals("SimpleTypedef4")) {
-                    simpleTypedef4 = (GeneratedTransferObject) type;
-                } else if (type.getName().equals("ExtendedTypedefUnion")) {
-                    extendedTypedefUnion = (GeneratedTransferObject) type;
-                } else if (type.getName().equals("UnionTypedef")) {
-                    unionTypedef = (GeneratedTransferObject) type;
-                } else if (type.getName().equals("TypedefFromImport")) {
-                    typedefFromImport = (GeneratedTransferObject) type;
-                }
-            }
-        }
-
-        // typedef-from-import
-        assertNotNull("TypedefFromImport not found", typedefFromImport);
-        List<GeneratedProperty> properties = typedefFromImport.getProperties();
-        assertTrue("Properties of TypedefFromImport should be empty", properties.isEmpty());
-        assertEquals("TypedefFromImport should be extended", "Ipv4Address", typedefFromImport.getExtends().getName());
-
-        // simple-typedef4
-        assertNotNull("SimpleTypedef4 not found", simpleTypedef4);
-        assertNotNull("ExtendedTypedefUnion not found", extendedTypedefUnion);
-        assertNotNull("UnionTypedef", unionTypedef);
-
-        properties = simpleTypedef4.getProperties();
-        assertTrue("SimpleTypedef4 shouldn't have properties.", properties.isEmpty());
-
-        GeneratedTransferObject extendTO = simpleTypedef4.getExtends();
-        assertNotNull("SimpleTypedef4 should have extend.", extendTO);
-        assertEquals("Incorrect extension for SimpleTypedef4.", "SimpleTypedef3", extendTO.getName());
-        properties = extendTO.getProperties();
-        assertTrue("SimpleTypedef3 shouldn't have properties.", properties.isEmpty());
-
-        extendTO = extendTO.getExtends();
-        assertNotNull("SimpleTypedef3 should have extend.", extendTO);
-        assertEquals("Incorrect extension for SimpleTypedef3.", "SimpleTypedef2", extendTO.getName());
-        properties = extendTO.getProperties();
-        assertTrue("SimpleTypedef2 shouldn't have properties.", properties.isEmpty());
-
-        extendTO = extendTO.getExtends();
-        assertNotNull("SimpleTypedef2 should have extend.", extendTO);
-        assertEquals("SimpleTypedef2 should be extended with SimpleTypedef1.", "SimpleTypedef1", extendTO.getName());
-        properties = extendTO.getProperties();
-        assertEquals("Incorrect number of properties in class SimpleTypedef1.", 1, properties.size());
-
-        assertEquals("Incorrect property's name", "value", properties.get(0).getName());
-        assertEquals("Property's incorrect type", BaseYangTypes.UINT8_TYPE, properties.get(0).getReturnType());
-
-        extendTO = extendTO.getExtends();
-        assertNull("SimpleTypedef1 shouldn't have extend.", extendTO);
-
-        // extended-typedef-union
-        assertNotNull("ExtendedTypedefUnion object not found", extendedTypedefUnion);
-        properties = extendedTypedefUnion.getProperties();
-        assertTrue("ExtendedTypedefUnion shouldn't have any property", properties.isEmpty());
-
-        extendTO = extendedTypedefUnion.getExtends();
-        assertEquals("Incorrect extension fo ExtendedTypedefUnion.", "UnionTypedef", extendTO.getName());
-        assertNull("UnionTypedef shouldn't be extended", extendTO.getExtends());
-        assertEquals("Incorrect number of properties for UnionTypedef.", 4, extendTO.getProperties().size());
-
-        GeneratedProperty simpleTypedef4Property = null;
-        GeneratedProperty simpleTypedef1Property = null;
-        GeneratedProperty byteTypeProperty = null;
-        GeneratedProperty typedefEnumFruitProperty = null;
-        for (GeneratedProperty genProperty : extendTO.getProperties()) {
-            if (genProperty.getName().equals("simpleTypedef1")) {
-                simpleTypedef1Property = genProperty;
-            } else if (genProperty.getName().equals("simpleTypedef4")) {
-                simpleTypedef4Property = genProperty;
-            } else if (genProperty.getName().equals("byteType")) {
-                byteTypeProperty = genProperty;
-            } else if (genProperty.getName().equals("typedefEnumFruit")) {
-                typedefEnumFruitProperty = genProperty;
-            }
-        }
-
-        assertNotNull("simpleTypedef4 property not found in UnionTypedef", simpleTypedef4Property);
-        assertNotNull("simpleTypedef1 property not found in UnionTypedef", simpleTypedef1Property);
-        assertNotNull("byteType property not found in UnionTypedef", byteTypeProperty);
-        assertNotNull("typedefEnumFruit property not found in UnionTypedef", typedefEnumFruitProperty);
-
-        assertEquals("Incorrect type for property simpleTypedef4.", "SimpleTypedef4", simpleTypedef4Property
-                .getReturnType().getName());
-        assertEquals("Incorrect type for property simpleTypedef1.", "SimpleTypedef1", simpleTypedef1Property
-                .getReturnType().getName());
-        assertEquals("Incorrect type for property byteType.", "ByteType", byteTypeProperty.getReturnType().getName());
-        assertEquals("Incorrect type for property typedefEnumFruit.", "TypedefEnumFruit", typedefEnumFruitProperty
-                .getReturnType().getName());
-    }
-
-}
+package org.opendaylight.yangtools.sal.binding.generator.impl;\r
+\r
+import static org.junit.Assert.*;\r
+\r
+import java.io.File;\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+import java.util.Set;\r
+\r
+import org.junit.BeforeClass;\r
+import org.junit.Test;\r
+import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;\r
+import org.opendaylight.yangtools.sal.binding.model.api.GeneratedProperty;\r
+import org.opendaylight.yangtools.sal.binding.model.api.GeneratedTransferObject;\r
+import org.opendaylight.yangtools.sal.binding.model.api.Type;\r
+import org.opendaylight.yangtools.sal.binding.yang.types.BaseYangTypes;\r
+import org.opendaylight.yangtools.yang.model.api.Module;\r
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;\r
+import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;\r
+import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;\r
+\r
+public class ExtendedTypedefTest {\r
+\r
+    private final static List<File> testModels = new ArrayList<File>();\r
+    private final static String testFolderPath = AugmentedTypeTest.class.getResource("/typedef-of-typedef").getPath();\r
+\r
+    @BeforeClass\r
+    public static void loadTestResources() {\r
+        final File testFolder = new File(testFolderPath);\r
+\r
+        for (final File fileEntry : testFolder.listFiles()) {\r
+            if (fileEntry.isFile()) {\r
+                testModels.add(fileEntry);\r
+            }\r
+        }\r
+    }\r
+\r
+    @Test\r
+    public void constantGenerationTest() {\r
+        final YangModelParser parser = new YangParserImpl();\r
+        final Set<Module> modules = parser.parseYangModels(testModels);\r
+        final SchemaContext context = parser.resolveSchemaContext(modules);\r
+\r
+        assertNotNull(context);\r
+        final BindingGenerator bindingGen = new BindingGeneratorImpl();\r
+        final List<Type> genTypes = bindingGen.generateTypes(context);\r
+\r
+        GeneratedTransferObject simpleTypedef4 = null;\r
+        GeneratedTransferObject extendedTypedefUnion = null;\r
+        GeneratedTransferObject unionTypedef = null;\r
+        GeneratedTransferObject typedefFromImport = null;\r
+        for (final Type type : genTypes) {\r
+            if (type instanceof GeneratedTransferObject) {\r
+                if (type.getName().equals("SimpleTypedef4")) {\r
+                    simpleTypedef4 = (GeneratedTransferObject) type;\r
+                } else if (type.getName().equals("ExtendedTypedefUnion")) {\r
+                    extendedTypedefUnion = (GeneratedTransferObject) type;\r
+                } else if (type.getName().equals("UnionTypedef")) {\r
+                    unionTypedef = (GeneratedTransferObject) type;\r
+                } else if (type.getName().equals("TypedefFromImport")) {\r
+                    typedefFromImport = (GeneratedTransferObject) type;\r
+                }\r
+            }\r
+        }\r
+\r
+        // typedef-from-import\r
+        assertNotNull("TypedefFromImport not found", typedefFromImport);\r
+        List<GeneratedProperty> properties = typedefFromImport.getProperties();\r
+        assertTrue("Properties of TypedefFromImport should be empty", properties.isEmpty());\r
+        assertEquals("TypedefFromImport should be extended", "Ipv4Address", typedefFromImport.getSuperType().getName());\r
+\r
+        // simple-typedef4\r
+        assertNotNull("SimpleTypedef4 not found", simpleTypedef4);\r
+        assertNotNull("ExtendedTypedefUnion not found", extendedTypedefUnion);\r
+        assertNotNull("UnionTypedef", unionTypedef);\r
+\r
+        properties = simpleTypedef4.getProperties();\r
+        assertTrue("SimpleTypedef4 shouldn't have properties.", properties.isEmpty());\r
+\r
+        GeneratedTransferObject extendTO = simpleTypedef4.getSuperType();\r
+        assertNotNull("SimpleTypedef4 should have extend.", extendTO);\r
+        assertEquals("Incorrect extension for SimpleTypedef4.", "SimpleTypedef3", extendTO.getName());\r
+        properties = extendTO.getProperties();\r
+        assertTrue("SimpleTypedef3 shouldn't have properties.", properties.isEmpty());\r
+\r
+        extendTO = extendTO.getSuperType();\r
+        assertNotNull("SimpleTypedef3 should have extend.", extendTO);\r
+        assertEquals("Incorrect extension for SimpleTypedef3.", "SimpleTypedef2", extendTO.getName());\r
+        properties = extendTO.getProperties();\r
+        assertTrue("SimpleTypedef2 shouldn't have properties.", properties.isEmpty());\r
+\r
+        extendTO = extendTO.getSuperType();\r
+        assertNotNull("SimpleTypedef2 should have extend.", extendTO);\r
+        assertEquals("SimpleTypedef2 should be extended with SimpleTypedef1.", "SimpleTypedef1", extendTO.getName());\r
+        properties = extendTO.getProperties();\r
+        assertEquals("Incorrect number of properties in class SimpleTypedef1.", 1, properties.size());\r
+\r
+        assertEquals("Incorrect property's name", "value", properties.get(0).getName());\r
+        assertEquals("Property's incorrect type", BaseYangTypes.UINT8_TYPE, properties.get(0).getReturnType());\r
+\r
+        extendTO = extendTO.getSuperType();\r
+        assertNull("SimpleTypedef1 shouldn't have extend.", extendTO);\r
+\r
+        // extended-typedef-union\r
+        assertNotNull("ExtendedTypedefUnion object not found", extendedTypedefUnion);\r
+        properties = extendedTypedefUnion.getProperties();\r
+        assertTrue("ExtendedTypedefUnion shouldn't have any property", properties.isEmpty());\r
+\r
+        extendTO = extendedTypedefUnion.getSuperType();\r
+        assertEquals("Incorrect extension fo ExtendedTypedefUnion.", "UnionTypedef", extendTO.getName());\r
+        assertNull("UnionTypedef shouldn't be extended", extendTO.getSuperType());\r
+        assertEquals("Incorrect number of properties for UnionTypedef.", 4, extendTO.getProperties().size());\r
+\r
+        GeneratedProperty simpleTypedef4Property = null;\r
+        GeneratedProperty simpleTypedef1Property = null;\r
+        GeneratedProperty byteTypeProperty = null;\r
+        GeneratedProperty typedefEnumFruitProperty = null;\r
+        for (GeneratedProperty genProperty : extendTO.getProperties()) {\r
+            if (genProperty.getName().equals("simpleTypedef1")) {\r
+                simpleTypedef1Property = genProperty;\r
+            } else if (genProperty.getName().equals("simpleTypedef4")) {\r
+                simpleTypedef4Property = genProperty;\r
+            } else if (genProperty.getName().equals("byteType")) {\r
+                byteTypeProperty = genProperty;\r
+            } else if (genProperty.getName().equals("typedefEnumFruit")) {\r
+                typedefEnumFruitProperty = genProperty;\r
+            }\r
+        }\r
+\r
+        assertNotNull("simpleTypedef4 property not found in UnionTypedef", simpleTypedef4Property);\r
+        assertNotNull("simpleTypedef1 property not found in UnionTypedef", simpleTypedef1Property);\r
+        assertNotNull("byteType property not found in UnionTypedef", byteTypeProperty);\r
+        assertNotNull("typedefEnumFruit property not found in UnionTypedef", typedefEnumFruitProperty);\r
+\r
+        assertEquals("Incorrect type for property simpleTypedef4.", "SimpleTypedef4", simpleTypedef4Property\r
+                .getReturnType().getName());\r
+        assertEquals("Incorrect type for property simpleTypedef1.", "SimpleTypedef1", simpleTypedef1Property\r
+                .getReturnType().getName());\r
+        assertEquals("Incorrect type for property byteType.", "ByteType", byteTypeProperty.getReturnType().getName());\r
+        assertEquals("Incorrect type for property typedefEnumFruit.", "TypedefEnumFruit", typedefEnumFruitProperty\r
+                .getReturnType().getName());\r
+    }\r
+\r
+}\r
index 5707c78053b3635b8252554cc8e32f59a2b701cb..27d4cffae7aab5c78400150967dcedf8520ec1d5 100644 (file)
-/*
- * 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.yangtools.binding.generator.util;
-
-import org.opendaylight.yangtools.sal.binding.model.api.Type;
-
-/**
- * It is used only as ancestor for other <code>Type</code>s
- * 
- */
-public class AbstractBaseType implements Type {
-
-    /**
-     * Name of the package to which this <code>Type</code> belongs.
-     */
-    private final String packageName;
-
-    /**
-     * Name of this <code>Type</code>.
-     */
-    private final String name;
-
-    @Override
-    public String getPackageName() {
-        return packageName;
-    }
-
-    @Override
-    public String getName() {
-        return name;
-    }
-
-    @Override
-    public String getFullyQualifiedName() {
-        if (packageName.isEmpty()) {
-            return name;
-        } else {
-            return packageName + "." + name;
-        }
-    }
-
-    /**
-     * Constructs the instance of this class with the concrete package name type
-     * name.
-     * 
-     * @param pkName
-     *            string with the package name to which this <code>Type</code>
-     *            belongs
-     * @param name
-     *            string with the name for this <code>Type</code>
-     */
-    protected AbstractBaseType(String pkName, String name) {
-        this.packageName = pkName;
-        this.name = name;
-    }
-
-    @Override
-    public int hashCode() {
-        final int prime = 31;
-        int result = 1;
-        result = prime * result + ((name == null) ? 0 : name.hashCode());
-        result = prime * result + ((packageName == null) ? 0 : packageName.hashCode());
-        return result;
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        if (this == obj)
-            return true;
-        if (obj == null)
-            return false;
-        if (getClass() != obj.getClass())
-            return false;
-        Type other = (Type) obj;
-        if (name == null) {
-            if (other.getName() != null)
-                return false;
-        } else if (!name.equals(other.getName()))
-            return false;
-        if (packageName == null) {
-            if (other.getPackageName() != null)
-                return false;
-        } else if (!packageName.equals(other.getPackageName()))
-            return false;
-        return true;
-    }
-
-    @Override
-    public String toString() {
-        if (packageName.isEmpty()) {
-            return "Type (" + name + ")";
-        }
-        return "Type (" + packageName + "." + name + ")";
-    }
-}
+/*\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.yangtools.binding.generator.util;\r
+\r
+import org.opendaylight.yangtools.sal.binding.model.api.Type;\r
+\r
+/**\r
+ * It is used only as ancestor for other <code>Type</code>s\r
+ * \r
+ */\r
+public class AbstractBaseType implements Type {\r
+\r
+    /**\r
+     * Name of the package to which this <code>Type</code> belongs.\r
+     */\r
+    private final String packageName;\r
+\r
+    /**\r
+     * Name of this <code>Type</code>.\r
+     */\r
+    private final String name;\r
+\r
+    @Override\r
+    public String getPackageName() {\r
+        return packageName;\r
+    }\r
+\r
+    @Override\r
+    public String getName() {\r
+        return name;\r
+    }\r
+\r
+    @Override\r
+    public String getFullyQualifiedName() {\r
+        if (packageName.isEmpty()) {\r
+            return name;\r
+        } else {\r
+            return packageName + "." + name;\r
+        }\r
+    }\r
+\r
+    /**\r
+     * Constructs the instance of this class with the concrete package name type\r
+     * name.\r
+     * \r
+     * @param pkName\r
+     *            string with the package name to which this <code>Type</code>\r
+     *            belongs\r
+     * @param name\r
+     *            string with the name for this <code>Type</code>\r
+     */\r
+    protected AbstractBaseType(String pkName, String name) {\r
+        if (pkName == null) {\r
+            throw new IllegalArgumentException("Package Name for Generated Type cannot be null!");\r
+        }\r
+        if (name == null) {\r
+            throw new IllegalArgumentException("Name of Generated Type cannot be null!");\r
+        }\r
+        this.packageName = pkName;\r
+        this.name = name;\r
+    }\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 + ((packageName == null) ? 0 : packageName.hashCode());\r
+        return result;\r
+    }\r
+\r
+    @Override\r
+    public boolean equals(Object obj) {\r
+        if (this == obj)\r
+            return true;\r
+        if (obj == null)\r
+            return false;\r
+        if (getClass() != obj.getClass())\r
+            return false;\r
+        Type other = (Type) obj;\r
+        if (name == null) {\r
+            if (other.getName() != null)\r
+                return false;\r
+        } else if (!name.equals(other.getName()))\r
+            return false;\r
+        if (packageName == null) {\r
+            if (other.getPackageName() != null)\r
+                return false;\r
+        } else if (!packageName.equals(other.getPackageName()))\r
+            return false;\r
+        return true;\r
+    }\r
+\r
+    @Override\r
+    public String toString() {\r
+        if (packageName.isEmpty()) {\r
+            return "Type (" + name + ")";\r
+        }\r
+        return "Type (" + packageName + "." + name + ")";\r
+    }\r
+}\r
index 1c0c52ed7f54f9cdd31cb895f75875ffe4918093..8a2d5a35969c704935d28c964ac72930bcc2a7c3 100644 (file)
-/*
- * 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.yangtools.binding.generator.util.generated.type.builder;
-
-import org.opendaylight.yangtools.binding.generator.util.AbstractBaseType;
-import org.opendaylight.yangtools.sal.binding.model.api.*;
-import org.opendaylight.yangtools.sal.binding.model.api.type.builder.*;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-abstract class AbstractGeneratedType extends AbstractBaseType implements GeneratedType {
-
-    private final Type parent;
-    private final String comment;
-    private final List<AnnotationType> annotations;
-    private final List<Type> implementsTypes;
-    private final List<Enumeration> enumerations;
-    private final List<Constant> constants;
-    private final List<MethodSignature> methodSignatures;
-    private final List<GeneratedType> enclosedTypes;
-    private final boolean isAbstract;
-
-    public AbstractGeneratedType(final Type parent, final String packageName, final String name, final String comment,
-            final List<AnnotationTypeBuilder> annotationBuilders, final boolean isAbstract,
-            final List<Type> implementsTypes, final List<GeneratedTypeBuilder> enclosedGenTypeBuilders,
-            final List<GeneratedTOBuilder> enclosedGenTOBuilders, final List<EnumBuilder> enumBuilders,
-            final List<Constant> constants, final List<MethodSignatureBuilder> methodBuilders) {
-        super(packageName, name);
-        this.parent = parent;
-        this.comment = comment;
-        this.annotations = toUnmodifiableAnnotations(annotationBuilders);
-        this.implementsTypes = Collections.unmodifiableList(implementsTypes);
-        this.constants = Collections.unmodifiableList(constants);
-        this.enumerations = toUnmodifiableEnumerations(enumBuilders);
-        this.methodSignatures = toUnmodifiableMethods(methodBuilders);
-        this.enclosedTypes = toUnmodifiableEnclosedTypes(enclosedGenTypeBuilders, enclosedGenTOBuilders);
-        this.isAbstract = isAbstract;
-    }
-
-    private List<GeneratedType> toUnmodifiableEnclosedTypes(final List<GeneratedTypeBuilder> enclosedGenTypeBuilders,
-            final List<GeneratedTOBuilder> enclosedGenTOBuilders) {
-        final List<GeneratedType> enclosedTypes = new ArrayList<>();
-        for (final GeneratedTypeBuilder builder : enclosedGenTypeBuilders) {
-            if (builder != null) {
-                enclosedTypes.add(builder.toInstance());
-            }
-        }
-
-        for (final GeneratedTOBuilder builder : enclosedGenTOBuilders) {
-            if (builder != null) {
-                enclosedTypes.add(builder.toInstance());
-            }
-        }
-        return enclosedTypes;
-    }
-
-    protected List<AnnotationType> toUnmodifiableAnnotations(final List<AnnotationTypeBuilder> annotationBuilders) {
-        final List<AnnotationType> annotations = new ArrayList<>();
-        for (final AnnotationTypeBuilder builder : annotationBuilders) {
-            annotations.add(builder.toInstance());
-        }
-        return Collections.unmodifiableList(annotations);
-    }
-
-    protected List<MethodSignature> toUnmodifiableMethods(List<MethodSignatureBuilder> methodBuilders) {
-        final List<MethodSignature> methods = new ArrayList<>();
-        for (final MethodSignatureBuilder methodBuilder : methodBuilders) {
-            methods.add(methodBuilder.toInstance(this));
-        }
-        return Collections.unmodifiableList(methods);
-    }
-
-    protected List<Enumeration> toUnmodifiableEnumerations(List<EnumBuilder> enumBuilders) {
-        final List<Enumeration> enums = new ArrayList<>();
-        for (final EnumBuilder enumBuilder : enumBuilders) {
-            enums.add(enumBuilder.toInstance(this));
-        }
-        return Collections.unmodifiableList(enums);
-    }
-
-    @Override
-    public Type getParentType() {
-        return parent;
-    }
-
-    @Override
-    public String getComment() {
-        return comment;
-    }
-
-    @Override
-    public List<AnnotationType> getAnnotations() {
-        return annotations;
-    }
-
-    @Override
-    public boolean isAbstract() {
-        return isAbstract;
-    }
-
-    @Override
-    public List<Type> getImplements() {
-        return implementsTypes;
-    }
-
-    @Override
-    public List<GeneratedType> getEnclosedTypes() {
-        return enclosedTypes;
-    }
-
-    @Override
-    public List<Enumeration> getEnumerations() {
-        return enumerations;
-    }
-
-    @Override
-    public List<Constant> getConstantDefinitions() {
-        return constants;
-    }
-
-    @Override
-    public List<MethodSignature> getMethodDefinitions() {
-        return methodSignatures;
-    }
-
-    @Override
-    public String toString() {
-        StringBuilder builder = new StringBuilder();
-        builder.append("GeneratedType [packageName=");
-        builder.append(getPackageName());
-        builder.append(", name=");
-        builder.append(getName());
-        if (parent != null) {
-            builder.append(", parent=");
-            builder.append(parent.getFullyQualifiedName());
-        } else {
-            builder.append(", parent=null");
-        }
-        builder.append(", comment=");
-        builder.append(comment);
-        builder.append(", annotations=");
-        builder.append(annotations);
-        builder.append(", enclosedTypes=");
-        builder.append(enclosedTypes);
-        builder.append(", enumerations=");
-        builder.append(enumerations);
-        builder.append(", constants=");
-        builder.append(constants);
-        builder.append(", methodSignatures=");
-        builder.append(methodSignatures);
-        builder.append("]");
-        return builder.toString();
-    }
-}
+/*\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.yangtools.binding.generator.util.generated.type.builder;\r
+\r
+import org.opendaylight.yangtools.binding.generator.util.AbstractBaseType;\r
+import org.opendaylight.yangtools.sal.binding.model.api.*;\r
+import org.opendaylight.yangtools.sal.binding.model.api.type.builder.*;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collections;\r
+import java.util.List;\r
+\r
+abstract class AbstractGeneratedType extends AbstractBaseType implements GeneratedType {\r
+\r
+    private final Type parent;\r
+    private final String comment;\r
+    private final List<AnnotationType> annotations;\r
+    private final List<Type> implementsTypes;\r
+    private final List<Enumeration> enumerations;\r
+    private final List<Constant> constants;\r
+    private final List<MethodSignature> methodSignatures;\r
+    private final List<GeneratedType> enclosedTypes;\r
+    private final List<GeneratedProperty> properties;\r
+    private final boolean isAbstract;\r
+\r
+    \r
+    public AbstractGeneratedType(AbstractGeneratedTypeBuilder builder) {\r
+        super(builder.getPackageName(),builder.getName());\r
+        this.parent = builder.getParent();\r
+        this.comment = builder.getComment();\r
+        this.annotations = toUnmodifiableAnnotations(builder.getAnnotations());\r
+        this.implementsTypes = Collections.unmodifiableList(builder.getImplementsTypes());\r
+        this.constants = Collections.unmodifiableList(builder.getConstants());\r
+        this.enumerations = toUnmodifiableEnumerations(builder.getEnumerations());\r
+        this.methodSignatures = toUnmodifiableMethods(builder.getMethodDefinitions());\r
+        this.enclosedTypes = toUnmodifiableEnclosedTypes(builder.getEnclosedTypes(), builder.getEnclosedTransferObjects());\r
+        this.properties = toUnmodifiableProperties(builder.getProperties());\r
+        this.isAbstract = builder.isAbstract();\r
+    }\r
+    \r
+    public AbstractGeneratedType(final Type parent, final String packageName, final String name, final String comment,\r
+            final List<AnnotationTypeBuilder> annotationBuilders, final boolean isAbstract,\r
+            final List<Type> implementsTypes, final List<GeneratedTypeBuilder> enclosedGenTypeBuilders,\r
+            final List<GeneratedTOBuilder> enclosedGenTOBuilders, final List<EnumBuilder> enumBuilders,\r
+            final List<Constant> constants, final List<MethodSignatureBuilder> methodBuilders,final List<GeneratedPropertyBuilder> propertyBuilders) {\r
+        super(packageName, name);\r
+        this.parent = parent;\r
+        this.comment = comment;\r
+        this.annotations = toUnmodifiableAnnotations(annotationBuilders);\r
+        this.implementsTypes = Collections.unmodifiableList(implementsTypes);\r
+        this.constants = Collections.unmodifiableList(constants);\r
+        this.enumerations = toUnmodifiableEnumerations(enumBuilders);\r
+        this.methodSignatures = toUnmodifiableMethods(methodBuilders);\r
+        this.enclosedTypes = toUnmodifiableEnclosedTypes(enclosedGenTypeBuilders, enclosedGenTOBuilders);\r
+        this.properties = toUnmodifiableProperties(propertyBuilders);\r
+        this.isAbstract = isAbstract;\r
+        \r
+    }\r
+\r
+    private List<GeneratedType> toUnmodifiableEnclosedTypes(final List<GeneratedTypeBuilder> enclosedGenTypeBuilders,\r
+            final List<GeneratedTOBuilder> enclosedGenTOBuilders) {\r
+        final List<GeneratedType> enclosedTypes = new ArrayList<>();\r
+        for (final GeneratedTypeBuilder builder : enclosedGenTypeBuilders) {\r
+            if (builder != null) {\r
+                enclosedTypes.add(builder.toInstance());\r
+            }\r
+        }\r
+\r
+        for (final GeneratedTOBuilder builder : enclosedGenTOBuilders) {\r
+            if (builder != null) {\r
+                enclosedTypes.add(builder.toInstance());\r
+            }\r
+        }\r
+        return enclosedTypes;\r
+    }\r
+\r
+    protected final List<AnnotationType> toUnmodifiableAnnotations(final List<AnnotationTypeBuilder> annotationBuilders) {\r
+        final List<AnnotationType> annotations = new ArrayList<>();\r
+        for (final AnnotationTypeBuilder builder : annotationBuilders) {\r
+            annotations.add(builder.toInstance());\r
+        }\r
+        return Collections.unmodifiableList(annotations);\r
+    }\r
+\r
+    protected final List<MethodSignature> toUnmodifiableMethods(List<MethodSignatureBuilder> methodBuilders) {\r
+        final List<MethodSignature> methods = new ArrayList<>();\r
+        for (final MethodSignatureBuilder methodBuilder : methodBuilders) {\r
+            methods.add(methodBuilder.toInstance(this));\r
+        }\r
+        return Collections.unmodifiableList(methods);\r
+    }\r
+\r
+    protected final List<Enumeration> toUnmodifiableEnumerations(List<EnumBuilder> enumBuilders) {\r
+        final List<Enumeration> enums = new ArrayList<>();\r
+        for (final EnumBuilder enumBuilder : enumBuilders) {\r
+            enums.add(enumBuilder.toInstance(this));\r
+        }\r
+        return Collections.unmodifiableList(enums);\r
+    }\r
+\r
+    protected final List<GeneratedProperty> toUnmodifiableProperties(List<GeneratedPropertyBuilder> methodBuilders) {\r
+        final List<GeneratedProperty> methods = new ArrayList<>();\r
+        for (final GeneratedPropertyBuilder methodBuilder : methodBuilders) {\r
+            methods.add(methodBuilder.toInstance(this));\r
+        }\r
+        return Collections.unmodifiableList(methods);\r
+    }\r
+    \r
+    \r
+    @Override\r
+    public final Type getParentType() {\r
+        return parent;\r
+    }\r
+\r
+    @Override\r
+    public final String getComment() {\r
+        return comment;\r
+    }\r
+\r
+    @Override\r
+    public final List<AnnotationType> getAnnotations() {\r
+        return annotations;\r
+    }\r
+\r
+    @Override\r
+    public final boolean isAbstract() {\r
+        return isAbstract;\r
+    }\r
+\r
+    @Override\r
+    public final List<Type> getImplements() {\r
+        return implementsTypes;\r
+    }\r
+\r
+    @Override\r
+    public final List<GeneratedType> getEnclosedTypes() {\r
+        return enclosedTypes;\r
+    }\r
+\r
+    @Override\r
+    public final List<Enumeration> getEnumerations() {\r
+        return enumerations;\r
+    }\r
+\r
+    @Override\r
+    public final List<Constant> getConstantDefinitions() {\r
+        return constants;\r
+    }\r
+\r
+    @Override\r
+    public final List<MethodSignature> getMethodDefinitions() {\r
+        return methodSignatures;\r
+    }\r
+    \r
+    public final List<GeneratedProperty> getProperties() {\r
+        return properties;\r
+    }\r
+    \r
+    \r
+\r
+    @Override\r
+    public String toString() {\r
+        StringBuilder builder = new StringBuilder();\r
+        builder.append("GeneratedType [packageName=");\r
+        builder.append(getPackageName());\r
+        builder.append(", name=");\r
+        builder.append(getName());\r
+        if (parent != null) {\r
+            builder.append(", parent=");\r
+            builder.append(parent.getFullyQualifiedName());\r
+        } else {\r
+            builder.append(", parent=null");\r
+        }\r
+        builder.append(", comment=");\r
+        builder.append(comment);\r
+        builder.append(", annotations=");\r
+        builder.append(annotations);\r
+        builder.append(", enclosedTypes=");\r
+        builder.append(enclosedTypes);\r
+        builder.append(", enumerations=");\r
+        builder.append(enumerations);\r
+        builder.append(", constants=");\r
+        builder.append(constants);\r
+        builder.append(", methodSignatures=");\r
+        builder.append(methodSignatures);\r
+        builder.append("]");\r
+        return builder.toString();\r
+    }\r
+}\r
index d47757a14cee6a09d79fde284f624d9abf770ec0..1eb60fc5db3635999e951a4cba3ea6e46deb228d 100644 (file)
-/*
- * 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.yangtools.binding.generator.util.generated.type.builder;
-
-import org.opendaylight.yangtools.binding.generator.util.AbstractBaseType;
-import org.opendaylight.yangtools.sal.binding.model.api.AccessModifier;
-import org.opendaylight.yangtools.sal.binding.model.api.Constant;
-import org.opendaylight.yangtools.sal.binding.model.api.Type;
-import org.opendaylight.yangtools.sal.binding.model.api.type.builder.*;
-
-import java.util.ArrayList;
-import java.util.List;
-
-abstract class AbstractGeneratedTypeBuilder extends AbstractBaseType implements GeneratedTypeBuilder {
-
-    private final String packageName;
-    private String comment = "";
-    private final String name;
-
-    private final List<AnnotationTypeBuilder> annotationBuilders = new ArrayList<>();
-    private final List<Type> implementsTypes = new ArrayList<>();
-    private final List<EnumBuilder> enumDefinitions = new ArrayList<>();
-    private final List<Constant> constants = new ArrayList<>();
-    private final List<MethodSignatureBuilder> methodDefinitions = new ArrayList<>();
-    private final List<GeneratedTypeBuilder> enclosedTypes = new ArrayList<>();
-    private final List<GeneratedTOBuilder> enclosingTransferObjects = new ArrayList<>();
-    private boolean isAbstract;
-
-    public AbstractGeneratedTypeBuilder(final String packageName, final String name) {
-        super(packageName, name);
-        if (packageName == null) {
-            throw new IllegalArgumentException("Package Name for Generated Type cannot be null!");
-        }
-        if (name == null) {
-            throw new IllegalArgumentException("Name of Generated Type cannot be null!");
-        }
-        this.packageName = packageName;
-        this.name = name;
-    }
-
-    protected String getComment() {
-        return comment;
-    }
-
-    protected List<AnnotationTypeBuilder> getAnnotations() {
-        return annotationBuilders;
-    }
-
-    protected boolean isAbstract() {
-        return isAbstract;
-    }
-
-    protected List<Type> getImplementsTypes() {
-        return implementsTypes;
-    }
-
-    protected List<EnumBuilder> getEnumerations() {
-        return enumDefinitions;
-    }
-
-    protected List<Constant> getConstants() {
-        return constants;
-    }
-
-    protected List<MethodSignatureBuilder> getMethodDefinitions() {
-        return methodDefinitions;
-    }
-
-    protected List<GeneratedTypeBuilder> getEnclosedTypes() {
-        return enclosedTypes;
-    }
-
-    protected List<GeneratedTOBuilder> getEnclosedTransferObjects() {
-        return enclosingTransferObjects;
-    }
-
-    @Override
-    public GeneratedTypeBuilder addEnclosingType(String name) {
-        if (name == null) {
-            throw new IllegalArgumentException("Name for Enclosing Generated Type cannot be null!");
-        }
-        GeneratedTypeBuilder builder = new GeneratedTOBuilderImpl(getFullyQualifiedName(), name);
-        enclosedTypes.add(builder);
-        return builder;
-    }
-
-    @Override
-    public GeneratedTOBuilder addEnclosingTransferObject(String name) {
-        if (name == null) {
-            throw new IllegalArgumentException("Name for Enclosing Generated Transfer Object cannot be null!");
-        }
-        GeneratedTOBuilder builder = new GeneratedTOBuilderImpl(getFullyQualifiedName(), name);
-        enclosingTransferObjects.add(builder);
-        return builder;
-    }
-
-    @Override
-    public void addEnclosingTransferObject(final GeneratedTOBuilder genTOBuilder) {
-        if (genTOBuilder == null) {
-            throw new IllegalArgumentException("Parameter genTOBuilder cannot be null!");
-        }
-        enclosingTransferObjects.add(genTOBuilder);
-    }
-
-    @Override
-    public void addComment(String comment) {
-        this.comment = comment;
-    }
-
-    @Override
-    public AnnotationTypeBuilder addAnnotation(final String packageName, final String name) {
-        if (packageName == null) {
-            throw new IllegalArgumentException("Package Name for Annotation Type cannot be null!");
-        }
-        if (name == null) {
-            throw new IllegalArgumentException("Name of Annotation Type cannot be null!");
-        }
-
-        final AnnotationTypeBuilder builder = new AnnotationTypeBuilderImpl(packageName, name);
-        annotationBuilders.add(builder);
-        return builder;
-    }
-
-    @Override
-    public void setAbstract(boolean isAbstract) {
-        this.isAbstract = isAbstract;
-    }
-
-    @Override
-    public boolean addImplementsType(Type genType) {
-        if (genType == null) {
-            throw new IllegalArgumentException("Type cannot be null");
-        }
-        return implementsTypes.add(genType);
-    }
-
-    @Override
-    public Constant addConstant(Type type, String name, Object value) {
-        if (type == null) {
-            throw new IllegalArgumentException("Returning Type for Constant cannot be null!");
-        }
-        if (name == null) {
-            throw new IllegalArgumentException("Name of constant cannot be null!");
-        }
-
-        final Constant constant = new ConstantImpl(this, type, name, value);
-        constants.add(constant);
-        return constant;
-    }
-
-    @Override
-    public EnumBuilder addEnumeration(String name) {
-        if (name == null) {
-            throw new IllegalArgumentException("Name of enumeration cannot be null!");
-        }
-        final EnumBuilder builder = new EnumerationBuilderImpl(getFullyQualifiedName(), name);
-        enumDefinitions.add(builder);
-        return builder;
-    }
-
-    @Override
-    public MethodSignatureBuilder addMethod(String name) {
-        if (name == null) {
-            throw new IllegalArgumentException("Name of method cannot be null!");
-        }
-        final MethodSignatureBuilder builder = new MethodSignatureBuilderImpl(name);
-        builder.setAccessModifier(AccessModifier.PUBLIC);
-        builder.setAbstract(true);
-        methodDefinitions.add(builder);
-        return builder;
-    }
-
-    @Override
-    public boolean containsMethod(String name) {
-        if (name == null) {
-            throw new IllegalArgumentException("Parameter name can't be null");
-        }
-        for (MethodSignatureBuilder methodDefinition : methodDefinitions) {
-            if (name.equals(methodDefinition.getName())) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    @Override
-    public int hashCode() {
-        final int prime = 31;
-        int result = 1;
-        result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
-        result = prime * result + ((getPackageName() == null) ? 0 : getPackageName().hashCode());
-        return result;
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        if (this == obj) {
-            return true;
-        }
-        if (obj == null) {
-            return false;
-        }
-        if (getClass() != obj.getClass()) {
-            return false;
-        }
-        AbstractGeneratedTypeBuilder other = (AbstractGeneratedTypeBuilder) obj;
-        if (getName() == null) {
-            if (other.getName() != null) {
-                return false;
-            }
-        } else if (!getName().equals(other.getName())) {
-            return false;
-        }
-        if (getPackageName() == null) {
-            if (other.getPackageName() != null) {
-                return false;
-            }
-        } else if (!getPackageName().equals(other.getPackageName())) {
-            return false;
-        }
-        return true;
-    }
-}
+/*\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.yangtools.binding.generator.util.generated.type.builder;\r
+\r
+import org.opendaylight.yangtools.binding.generator.util.AbstractBaseType;\r
+import org.opendaylight.yangtools.sal.binding.model.api.AccessModifier;\r
+import org.opendaylight.yangtools.sal.binding.model.api.Constant;\r
+import org.opendaylight.yangtools.sal.binding.model.api.Type;\r
+import org.opendaylight.yangtools.sal.binding.model.api.type.builder.*;\r
+\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+\r
+abstract class AbstractGeneratedTypeBuilder extends AbstractBaseType implements GeneratedTypeBuilder {\r
+\r
+    private String comment = "";\r
+\r
+    private final List<AnnotationTypeBuilder> annotationBuilders = new ArrayList<>();\r
+    private final List<Type> implementsTypes = new ArrayList<>();\r
+    private final List<EnumBuilder> enumDefinitions = new ArrayList<>();\r
+    private final List<Constant> constants = new ArrayList<>();\r
+    private final List<MethodSignatureBuilder> methodDefinitions = new ArrayList<>();\r
+    private final List<GeneratedTypeBuilder> enclosedTypes = new ArrayList<>();\r
+    private final List<GeneratedTOBuilder> enclosingTransferObjects = new ArrayList<>();\r
+    private final List<GeneratedPropertyBuilder> properties = new ArrayList<>();\r
+    private boolean isAbstract;\r
+\r
+    public AbstractGeneratedTypeBuilder(final String packageName, final String name) {\r
+        super(packageName, name);\r
+    }\r
+\r
+    protected String getComment() {\r
+        return comment;\r
+    }\r
+\r
+    protected List<AnnotationTypeBuilder> getAnnotations() {\r
+        return annotationBuilders;\r
+    }\r
+\r
+    protected boolean isAbstract() {\r
+        return isAbstract;\r
+    }\r
+\r
+    protected List<Type> getImplementsTypes() {\r
+        return implementsTypes;\r
+    }\r
+\r
+    protected List<EnumBuilder> getEnumerations() {\r
+        return enumDefinitions;\r
+    }\r
+\r
+    protected List<Constant> getConstants() {\r
+        return constants;\r
+    }\r
+\r
+    protected List<MethodSignatureBuilder> getMethodDefinitions() {\r
+        return methodDefinitions;\r
+    }\r
+\r
+    protected List<GeneratedTypeBuilder> getEnclosedTypes() {\r
+        return enclosedTypes;\r
+    }\r
+\r
+    protected List<GeneratedTOBuilder> getEnclosedTransferObjects() {\r
+        return enclosingTransferObjects;\r
+    }\r
+\r
+    @Override\r
+    public GeneratedTypeBuilder addEnclosingType(String name) {\r
+        if (name == null) {\r
+            throw new IllegalArgumentException("Name for Enclosing Generated Type cannot be null!");\r
+        }\r
+        GeneratedTypeBuilder builder = new GeneratedTOBuilderImpl(getFullyQualifiedName(), name);\r
+        enclosedTypes.add(builder);\r
+        return builder;\r
+    }\r
+\r
+    @Override\r
+    public GeneratedTOBuilder addEnclosingTransferObject(String name) {\r
+        if (name == null) {\r
+            throw new IllegalArgumentException("Name for Enclosing Generated Transfer Object cannot be null!");\r
+        }\r
+        GeneratedTOBuilder builder = new GeneratedTOBuilderImpl(getFullyQualifiedName(), name);\r
+        enclosingTransferObjects.add(builder);\r
+        return builder;\r
+    }\r
+\r
+    @Override\r
+    public void addEnclosingTransferObject(final GeneratedTOBuilder genTOBuilder) {\r
+        if (genTOBuilder == null) {\r
+            throw new IllegalArgumentException("Parameter genTOBuilder cannot be null!");\r
+        }\r
+        enclosingTransferObjects.add(genTOBuilder);\r
+    }\r
+\r
+    @Override\r
+    public void addComment(String comment) {\r
+        this.comment = comment;\r
+    }\r
+\r
+    @Override\r
+    public AnnotationTypeBuilder addAnnotation(final String packageName, final String name) {\r
+        if (packageName == null) {\r
+            throw new IllegalArgumentException("Package Name for Annotation Type cannot be null!");\r
+        }\r
+        if (name == null) {\r
+            throw new IllegalArgumentException("Name of Annotation Type cannot be null!");\r
+        }\r
+\r
+        final AnnotationTypeBuilder builder = new AnnotationTypeBuilderImpl(packageName, name);\r
+        annotationBuilders.add(builder);\r
+        return builder;\r
+    }\r
+\r
+    @Override\r
+    public void setAbstract(boolean isAbstract) {\r
+        this.isAbstract = isAbstract;\r
+    }\r
+\r
+    @Override\r
+    public boolean addImplementsType(Type genType) {\r
+        if (genType == null) {\r
+            throw new IllegalArgumentException("Type cannot be null");\r
+        }\r
+        return implementsTypes.add(genType);\r
+    }\r
+\r
+    @Override\r
+    public Constant addConstant(Type type, String name, Object value) {\r
+        if (type == null) {\r
+            throw new IllegalArgumentException("Returning Type for Constant cannot be null!");\r
+        }\r
+        if (name == null) {\r
+            throw new IllegalArgumentException("Name of constant cannot be null!");\r
+        }\r
+\r
+        final Constant constant = new ConstantImpl(this, type, name, value);\r
+        constants.add(constant);\r
+        return constant;\r
+    }\r
+\r
+    @Override\r
+    public EnumBuilder addEnumeration(String name) {\r
+        if (name == null) {\r
+            throw new IllegalArgumentException("Name of enumeration cannot be null!");\r
+        }\r
+        final EnumBuilder builder = new EnumerationBuilderImpl(getFullyQualifiedName(), name);\r
+        enumDefinitions.add(builder);\r
+        return builder;\r
+    }\r
+\r
+    @Override\r
+    public MethodSignatureBuilder addMethod(String name) {\r
+        if (name == null) {\r
+            throw new IllegalArgumentException("Name of method cannot be null!");\r
+        }\r
+        final MethodSignatureBuilder builder = new MethodSignatureBuilderImpl(name);\r
+        builder.setAccessModifier(AccessModifier.PUBLIC);\r
+        builder.setAbstract(true);\r
+        methodDefinitions.add(builder);\r
+        return builder;\r
+    }\r
+\r
+    @Override\r
+    public boolean containsMethod(String name) {\r
+        if (name == null) {\r
+            throw new IllegalArgumentException("Parameter name can't be null");\r
+        }\r
+        for (MethodSignatureBuilder methodDefinition : methodDefinitions) {\r
+            if (name.equals(methodDefinition.getName())) {\r
+                return true;\r
+            }\r
+        }\r
+        return false;\r
+    }\r
+    \r
+    @Override\r
+    public GeneratedPropertyBuilder addProperty(String name) {\r
+        final GeneratedPropertyBuilder builder = new GeneratedPropertyBuilderImpl(name);\r
+        builder.setAccessModifier(AccessModifier.PUBLIC);\r
+        properties.add(builder);\r
+        return builder;\r
+    }\r
+\r
+    @Override\r
+    public boolean containsProperty(String name) {\r
+        if (name == null) {\r
+            throw new IllegalArgumentException("Parameter name can't be null");\r
+        }\r
+        for (GeneratedPropertyBuilder property : properties) {\r
+            if (name.equals(property.getName())) {\r
+                return true;\r
+            }\r
+        }\r
+        return false;\r
+    }\r
+\r
+    @Override\r
+    public int hashCode() {\r
+        final int prime = 31;\r
+        int result = 1;\r
+        result = prime * result + ((getName() == null) ? 0 : getName().hashCode());\r
+        result = prime * result + ((getPackageName() == null) ? 0 : getPackageName().hashCode());\r
+        return result;\r
+    }\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
+        AbstractGeneratedTypeBuilder other = (AbstractGeneratedTypeBuilder) obj;\r
+        if (getName() == null) {\r
+            if (other.getName() != null) {\r
+                return false;\r
+            }\r
+        } else if (!getName().equals(other.getName())) {\r
+            return false;\r
+        }\r
+        if (getPackageName() == null) {\r
+            if (other.getPackageName() != null) {\r
+                return false;\r
+            }\r
+        } else if (!getPackageName().equals(other.getPackageName())) {\r
+            return false;\r
+        }\r
+        return true;\r
+    }\r
+\r
+    public Type getParent() {\r
+        return null;\r
+    }\r
+\r
+    protected List<GeneratedPropertyBuilder> getProperties() {\r
+        return properties;\r
+    }\r
+}\r
index 5291f67c82121dfbe6712dfd1b3dc6d0f940e12c..ea7550f98db99f3e93902a859d4cef9c6d913878 100644 (file)
@@ -17,6 +17,7 @@ import org.opendaylight.yangtools.binding.generator.util.AbstractBaseType;
 import org.opendaylight.yangtools.sal.binding.model.api.AnnotationType;\r
 import org.opendaylight.yangtools.sal.binding.model.api.Constant;\r
 import org.opendaylight.yangtools.sal.binding.model.api.Enumeration;\r
+import org.opendaylight.yangtools.sal.binding.model.api.GeneratedProperty;\r
 import org.opendaylight.yangtools.sal.binding.model.api.GeneratedType;\r
 import org.opendaylight.yangtools.sal.binding.model.api.MethodSignature;\r
 import org.opendaylight.yangtools.sal.binding.model.api.Type;\r
@@ -429,5 +430,10 @@ public final class EnumerationBuilderImpl extends AbstractBaseType implements En
             // TODO Auto-generated method stub\r
             return Collections.emptyList();\r
         }\r
+        \r
+        @Override\r
+        public List<GeneratedProperty> getProperties() {\r
+            return Collections.emptyList();\r
+        }\r
     }\r
 }\r
index 02c0ff64932bee8bcf714fae6c7d8b7a156c499f..3f7ece81ca2b72be839026609d9a6b633d0d1e14 100644 (file)
-/*
- * 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.yangtools.binding.generator.util.generated.type.builder;
-
-import org.opendaylight.yangtools.sal.binding.model.api.*;
-import org.opendaylight.yangtools.sal.binding.model.api.type.builder.*;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-public final class GeneratedTOBuilderImpl extends AbstractGeneratedTypeBuilder implements GeneratedTOBuilder {
-
-    private GeneratedTransferObject extendsType;
-    private final List<GeneratedPropertyBuilder> properties = new ArrayList<>();
-    private final List<GeneratedPropertyBuilder> equalsProperties = new ArrayList<>();
-    private final List<GeneratedPropertyBuilder> hashProperties = new ArrayList<>();
-    private final List<GeneratedPropertyBuilder> toStringProperties = new ArrayList<>();
-    private boolean isUnionType = false;
-
-    public GeneratedTOBuilderImpl(String packageName, String name) {
-        super(packageName, name);
-        setAbstract(false);
-    }
-
-    @Override
-    public void setExtendsType(final GeneratedTransferObject genTransObj) {
-        if (genTransObj == null) {
-            throw new IllegalArgumentException("Generated Transfer Object cannot be null!");
-        }
-        extendsType = genTransObj;
-    }
-
-    @Override
-    public GeneratedPropertyBuilder addProperty(String name) {
-        final GeneratedPropertyBuilder builder = new GeneratedPropertyBuilderImpl(name);
-        builder.setAccessModifier(AccessModifier.PUBLIC);
-        properties.add(builder);
-        return builder;
-    }
-
-    @Override
-    public boolean containsProperty(String name) {
-        if (name == null) {
-            throw new IllegalArgumentException("Parameter name can't be null");
-        }
-        for (GeneratedPropertyBuilder property : properties) {
-            if (name.equals(property.getName())) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    /**
-     * Add new Method Signature definition for Generated Type Builder and
-     * returns Method Signature Builder for specifying all Method parameters. <br>
-     * Name of Method cannot be <code>null</code>, if it is <code>null</code>
-     * the method SHOULD throw {@link IllegalArgumentException} <br>
-     * By <i>Default</i> the MethodSignatureBuilder SHOULD be pre-set as
-     * {@link MethodSignatureBuilder#setAbstract(false)},
-     * {@link MethodSignatureBuilder#setFinal(false)} and
-     * {@link MethodSignatureBuilder#setAccessModifier(PUBLIC)}
-     * 
-     * @param name
-     *            Name of Method
-     * @return <code>new</code> instance of Method Signature Builder.
-     */
-    @Override
-    public MethodSignatureBuilder addMethod(String name) {
-        final MethodSignatureBuilder builder = super.addMethod(name);
-        builder.setAbstract(false);
-        return builder;
-    }
-
-    @Override
-    public boolean addEqualsIdentity(GeneratedPropertyBuilder property) {
-        return equalsProperties.add(property);
-    }
-
-    @Override
-    public boolean addHashIdentity(GeneratedPropertyBuilder property) {
-        return hashProperties.add(property);
-    }
-
-    @Override
-    public boolean addToStringProperty(GeneratedPropertyBuilder property) {
-        return toStringProperties.add(property);
-    }
-
-    @Override
-    public GeneratedTransferObject toInstance() {
-        return new GeneratedTransferObjectImpl(null, getPackageName(), getName(), getComment(), getAnnotations(),
-                isAbstract(), extendsType, getImplementsTypes(), getEnclosedTypes(), getEnclosedTransferObjects(),
-                getConstants(), getEnumerations(), getMethodDefinitions(), properties, equalsProperties,
-                hashProperties, toStringProperties, isUnionType);
-    }
-
-    @Override
-    public String toString() {
-        StringBuilder builder = new StringBuilder();
-        builder.append("GeneratedTransferObject [packageName=");
-        builder.append(getPackageName());
-        builder.append(", name=");
-        builder.append(getName());
-        builder.append(", comment=");
-        builder.append(getComment());
-        builder.append(", constants=");
-        builder.append(getConstants());
-        builder.append(", enumerations=");
-        builder.append(getEnumerations());
-        builder.append(", properties=");
-        builder.append(properties);
-        builder.append(", equalsProperties=");
-        builder.append(equalsProperties);
-        builder.append(", hashCodeProperties=");
-        builder.append(hashProperties);
-        builder.append(", stringProperties=");
-        builder.append(toStringProperties);
-        builder.append(", annotations=");
-        builder.append(getAnnotations());
-        builder.append(", methods=");
-        builder.append(getMethodDefinitions());
-        builder.append("]");
-        return builder.toString();
-    }
-
-    @Override
-    public void setIsUnion(boolean isUnion) {
-        this.isUnionType = isUnion;
-    }
-
-    private static final class GeneratedTransferObjectImpl extends AbstractGeneratedType implements
-            GeneratedTransferObject {
-
-        private final List<GeneratedProperty> properties;
-        private final List<GeneratedProperty> equalsProperties;
-        private final List<GeneratedProperty> hashCodeProperties;
-        private final List<GeneratedProperty> stringProperties;
-        private final GeneratedTransferObject extendsType;
-        private final boolean isUnionType;
-
-        GeneratedTransferObjectImpl(final Type parent, final String packageName, final String name,
-                final String comment, final List<AnnotationTypeBuilder> annotationBuilders, final boolean isAbstract,
-                final GeneratedTransferObject extendsType, final List<Type> implementsTypes,
-                final List<GeneratedTypeBuilder> enclosedGenTypeBuilders,
-                final List<GeneratedTOBuilder> enclosedGenTOBuilders, final List<Constant> constants,
-                final List<EnumBuilder> enumBuilders, final List<MethodSignatureBuilder> methodBuilders,
-                final List<GeneratedPropertyBuilder> propBuilders, final List<GeneratedPropertyBuilder> equalsBuilders,
-                final List<GeneratedPropertyBuilder> hashCodeBuilders,
-                final List<GeneratedPropertyBuilder> stringBuilders, final boolean isUnionType) {
-            super(parent, packageName, name, comment, annotationBuilders, isAbstract, implementsTypes,
-                    enclosedGenTypeBuilders, enclosedGenTOBuilders, enumBuilders, constants, methodBuilders);
-            this.extendsType = extendsType;
-            this.properties = toUnmodifiableProperties(propBuilders);
-            this.equalsProperties = toUnmodifiableProperties(equalsBuilders);
-            this.hashCodeProperties = toUnmodifiableProperties(hashCodeBuilders);
-            this.stringProperties = toUnmodifiableProperties(stringBuilders);
-            this.isUnionType = isUnionType;
-        }
-
-        @Override
-        public boolean isUnionType() {
-            return isUnionType;
-        }
-
-        private List<GeneratedProperty> toUnmodifiableProperties(final List<GeneratedPropertyBuilder> propBuilders) {
-            final List<GeneratedProperty> properties = new ArrayList<>();
-            for (final GeneratedPropertyBuilder builder : propBuilders) {
-                properties.add(builder.toInstance(this));
-            }
-            return Collections.unmodifiableList(properties);
-        }
-
-        @Override
-        public GeneratedTransferObject getExtends() {
-            return extendsType;
-        }
-
-        @Override
-        public List<GeneratedProperty> getProperties() {
-            return properties;
-        }
-
-        @Override
-        public List<GeneratedProperty> getEqualsIdentifiers() {
-            return equalsProperties;
-        }
-
-        @Override
-        public List<GeneratedProperty> getHashCodeIdentifiers() {
-            return hashCodeProperties;
-        }
-
-        @Override
-        public List<GeneratedProperty> getToStringIdentifiers() {
-            return stringProperties;
-        }
-
-        @Override
-        public String toString() {
-            StringBuilder builder = new StringBuilder();
-            builder.append("GeneratedTransferObject [packageName=");
-            builder.append(getPackageName());
-            builder.append(", name=");
-            builder.append(getName());
-            builder.append(", comment=");
-            builder.append(", annotations=");
-            builder.append(getAnnotations());
-            builder.append(getComment());
-            builder.append(", extends=");
-            builder.append(getExtends());
-            builder.append(", implements=");
-            builder.append(getImplements());
-            builder.append(", enclosedTypes=");
-            builder.append(getEnclosedTypes());
-            builder.append(", constants=");
-            builder.append(getConstantDefinitions());
-            builder.append(", enumerations=");
-            builder.append(getEnumerations());
-            builder.append(", properties=");
-            builder.append(properties);
-            builder.append(", equalsProperties=");
-            builder.append(equalsProperties);
-            builder.append(", hashCodeProperties=");
-            builder.append(hashCodeProperties);
-            builder.append(", stringProperties=");
-            builder.append(stringProperties);
-            builder.append(", methods=");
-            builder.append(getMethodDefinitions());
-            builder.append("]");
-            return builder.toString();
-        }
-    }
-}
+/*\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.yangtools.binding.generator.util.generated.type.builder;\r
+\r
+import org.opendaylight.yangtools.sal.binding.model.api.*;\r
+import org.opendaylight.yangtools.sal.binding.model.api.type.builder.*;\r
+\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+\r
+public final class GeneratedTOBuilderImpl extends AbstractGeneratedTypeBuilder implements GeneratedTOBuilder {\r
+\r
+    private GeneratedTransferObject extendsType;\r
+    private final List<GeneratedPropertyBuilder> properties = new ArrayList<>();\r
+    private final List<GeneratedPropertyBuilder> equalsProperties = new ArrayList<>();\r
+    private final List<GeneratedPropertyBuilder> hashProperties = new ArrayList<>();\r
+    private final List<GeneratedPropertyBuilder> toStringProperties = new ArrayList<>();\r
+    private boolean isUnionType = false;\r
+\r
+    public GeneratedTOBuilderImpl(String packageName, String name) {\r
+        super(packageName, name);\r
+        setAbstract(false);\r
+    }\r
+\r
+    @Override\r
+    public void setExtendsType(final GeneratedTransferObject genTransObj) {\r
+        if (genTransObj == null) {\r
+            throw new IllegalArgumentException("Generated Transfer Object cannot be null!");\r
+        }\r
+        extendsType = genTransObj;\r
+    }\r
+\r
+\r
+\r
+    /**\r
+     * Add new Method Signature definition for Generated Type Builder and\r
+     * returns Method Signature Builder for specifying all Method parameters. <br>\r
+     * Name of Method cannot be <code>null</code>, if it is <code>null</code>\r
+     * the method SHOULD throw {@link IllegalArgumentException} <br>\r
+     * By <i>Default</i> the MethodSignatureBuilder SHOULD be pre-set as\r
+     * {@link MethodSignatureBuilder#setAbstract(false)},\r
+     * {@link MethodSignatureBuilder#setFinal(false)} and\r
+     * {@link MethodSignatureBuilder#setAccessModifier(PUBLIC)}\r
+     * \r
+     * @param name\r
+     *            Name of Method\r
+     * @return <code>new</code> instance of Method Signature Builder.\r
+     */\r
+    @Override\r
+    public MethodSignatureBuilder addMethod(String name) {\r
+        final MethodSignatureBuilder builder = super.addMethod(name);\r
+        builder.setAbstract(false);\r
+        return builder;\r
+    }\r
+\r
+    @Override\r
+    public boolean addEqualsIdentity(GeneratedPropertyBuilder property) {\r
+        return equalsProperties.add(property);\r
+    }\r
+\r
+    @Override\r
+    public boolean addHashIdentity(GeneratedPropertyBuilder property) {\r
+        return hashProperties.add(property);\r
+    }\r
+\r
+    @Override\r
+    public boolean addToStringProperty(GeneratedPropertyBuilder property) {\r
+        return toStringProperties.add(property);\r
+    }\r
+\r
+    @Override\r
+    public GeneratedTransferObject toInstance() {\r
+        return new GeneratedTransferObjectImpl(this);\r
+    }\r
+\r
+    @Override\r
+    public String toString() {\r
+        StringBuilder builder = new StringBuilder();\r
+        builder.append("GeneratedTransferObject [packageName=");\r
+        builder.append(getPackageName());\r
+        builder.append(", name=");\r
+        builder.append(getName());\r
+        builder.append(", comment=");\r
+        builder.append(getComment());\r
+        builder.append(", constants=");\r
+        builder.append(getConstants());\r
+        builder.append(", enumerations=");\r
+        builder.append(getEnumerations());\r
+        builder.append(", properties=");\r
+        builder.append(properties);\r
+        builder.append(", equalsProperties=");\r
+        builder.append(equalsProperties);\r
+        builder.append(", hashCodeProperties=");\r
+        builder.append(hashProperties);\r
+        builder.append(", stringProperties=");\r
+        builder.append(toStringProperties);\r
+        builder.append(", annotations=");\r
+        builder.append(getAnnotations());\r
+        builder.append(", methods=");\r
+        builder.append(getMethodDefinitions());\r
+        builder.append("]");\r
+        return builder.toString();\r
+    }\r
+\r
+    @Override\r
+    public void setIsUnion(boolean isUnion) {\r
+        this.isUnionType = isUnion;\r
+    }\r
+\r
+    private static final class GeneratedTransferObjectImpl extends AbstractGeneratedType implements\r
+            GeneratedTransferObject {\r
+\r
+        private final List<GeneratedProperty> equalsProperties;\r
+        private final List<GeneratedProperty> hashCodeProperties;\r
+        private final List<GeneratedProperty> stringProperties;\r
+        private final GeneratedTransferObject extendsType;\r
+        private final boolean isUnionType;\r
+\r
+        public GeneratedTransferObjectImpl(GeneratedTOBuilderImpl builder) {\r
+            super(builder);\r
+            this.extendsType = builder.extendsType;\r
+            this.equalsProperties = toUnmodifiableProperties(builder.equalsProperties);\r
+            this.hashCodeProperties = toUnmodifiableProperties(builder.hashProperties);\r
+            this.stringProperties = toUnmodifiableProperties(builder.toStringProperties);\r
+            this.isUnionType = builder.isUnionType;\r
+        }\r
+\r
+        @Override\r
+        public boolean isUnionType() {\r
+            return isUnionType;\r
+        }\r
+        @Override\r
+        public GeneratedTransferObject getSuperType() {\r
+            return extendsType;\r
+        }\r
+\r
+        @Override\r
+        public List<GeneratedProperty> getEqualsIdentifiers() {\r
+            return equalsProperties;\r
+        }\r
+\r
+        @Override\r
+        public List<GeneratedProperty> getHashCodeIdentifiers() {\r
+            return hashCodeProperties;\r
+        }\r
+\r
+        @Override\r
+        public List<GeneratedProperty> getToStringIdentifiers() {\r
+            return stringProperties;\r
+        }\r
+\r
+        @Override\r
+        public String toString() {\r
+            StringBuilder builder = new StringBuilder();\r
+            builder.append("GeneratedTransferObject [packageName=");\r
+            builder.append(getPackageName());\r
+            builder.append(", name=");\r
+            builder.append(getName());\r
+            builder.append(", comment=");\r
+            builder.append(", annotations=");\r
+            builder.append(getAnnotations());\r
+            builder.append(getComment());\r
+            builder.append(", extends=");\r
+            builder.append(getSuperType());\r
+            builder.append(", implements=");\r
+            builder.append(getImplements());\r
+            builder.append(", enclosedTypes=");\r
+            builder.append(getEnclosedTypes());\r
+            builder.append(", constants=");\r
+            builder.append(getConstantDefinitions());\r
+            builder.append(", enumerations=");\r
+            builder.append(getEnumerations());\r
+            builder.append(", properties=");\r
+            builder.append(getProperties());\r
+            builder.append(", equalsProperties=");\r
+            builder.append(equalsProperties);\r
+            builder.append(", hashCodeProperties=");\r
+            builder.append(hashCodeProperties);\r
+            builder.append(", stringProperties=");\r
+            builder.append(stringProperties);\r
+            builder.append(", methods=");\r
+            builder.append(getMethodDefinitions());\r
+            builder.append("]");\r
+            return builder.toString();\r
+        }\r
+    }\r
+}\r
index 1bc0b05103e1a94aae7751ad37606633919cf0e3..ae7d3320248c2aea2f27fd2c2d8d0cc8f6fd3068 100644 (file)
@@ -1,70 +1,57 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.yangtools.binding.generator.util.generated.type.builder;
-
-import org.opendaylight.yangtools.sal.binding.model.api.Constant;
-import org.opendaylight.yangtools.sal.binding.model.api.GeneratedType;
-import org.opendaylight.yangtools.sal.binding.model.api.Type;
-import org.opendaylight.yangtools.sal.binding.model.api.type.builder.*;
-
-import java.util.List;
-
-public final class GeneratedTypeBuilderImpl extends AbstractGeneratedTypeBuilder {
-
-    public GeneratedTypeBuilderImpl(String packageName, String name) {
-        super(packageName, name);
-        setAbstract(true);
-    }
-
-    @Override
-    public GeneratedType toInstance() {
-        return new GeneratedTypeImpl(null, getPackageName(), getName(), getComment(), getAnnotations(), isAbstract(),
-                getImplementsTypes(), getEnclosedTypes(), getEnclosedTransferObjects(), getEnumerations(),
-                getConstants(), getMethodDefinitions());
-    }
-
-    @Override
-    public String toString() {
-        StringBuilder builder = new StringBuilder();
-        builder.append("GeneratedTransferObject [packageName=");
-        builder.append(getPackageName());
-        builder.append(", name=");
-        builder.append(getName());
-        builder.append(", comment=");
-        builder.append(", annotations=");
-        builder.append(getAnnotations());
-        builder.append(getComment());
-        builder.append(", implements=");
-        builder.append(getImplementsTypes());
-        builder.append(", enclosedTypes=");
-        builder.append(getEnclosedTypes());
-        builder.append(", constants=");
-        builder.append(getConstants());
-        builder.append(", enumerations=");
-        builder.append(getEnumerations());
-        builder.append(", properties=");
-        builder.append(", methods=");
-        builder.append(getMethodDefinitions());
-        builder.append("]");
-        return builder.toString();
-    }
-
-    private static final class GeneratedTypeImpl extends AbstractGeneratedType {
-
-        public GeneratedTypeImpl(final Type parent, final String packageName, final String name, final String comment,
-                                 final List<AnnotationTypeBuilder> annotationBuilders, final boolean isAbstract,
-                                 final List<Type> implementsTypes,
-                                 final List<GeneratedTypeBuilder> enclosedGenTypeBuilders,
-                                 final List<GeneratedTOBuilder> enclosedGenTOBuilders,
-                                 final List<EnumBuilder> enumBuilders, final List<Constant> constants,
-                                 final List<MethodSignatureBuilder> methodBuilders) {
-            super(parent, packageName, name, comment, annotationBuilders, isAbstract, implementsTypes,
-                    enclosedGenTypeBuilders, enclosedGenTOBuilders, enumBuilders, constants, methodBuilders);
-        }
-    }
-}
+/*\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.yangtools.binding.generator.util.generated.type.builder;\r
+\r
+\r
+import org.opendaylight.yangtools.sal.binding.model.api.GeneratedType;\r
+\r
+public final class GeneratedTypeBuilderImpl extends AbstractGeneratedTypeBuilder {\r
+\r
+    public GeneratedTypeBuilderImpl(String packageName, String name) {\r
+        super(packageName, name);\r
+        setAbstract(true);\r
+    }\r
+\r
+    @Override\r
+    public GeneratedType toInstance() {\r
+        return new GeneratedTypeImpl(this);\r
+    }\r
+\r
+    @Override\r
+    public String toString() {\r
+        StringBuilder builder = new StringBuilder();\r
+        builder.append("GeneratedTransferObject [packageName=");\r
+        builder.append(getPackageName());\r
+        builder.append(", name=");\r
+        builder.append(getName());\r
+        builder.append(", comment=");\r
+        builder.append(", annotations=");\r
+        builder.append(getAnnotations());\r
+        builder.append(getComment());\r
+        builder.append(", implements=");\r
+        builder.append(getImplementsTypes());\r
+        builder.append(", enclosedTypes=");\r
+        builder.append(getEnclosedTypes());\r
+        builder.append(", constants=");\r
+        builder.append(getConstants());\r
+        builder.append(", enumerations=");\r
+        builder.append(getEnumerations());\r
+        builder.append(", properties=");\r
+        builder.append(", methods=");\r
+        builder.append(getMethodDefinitions());\r
+        builder.append("]");\r
+        return builder.toString();\r
+    }\r
+\r
+    private static final class GeneratedTypeImpl extends AbstractGeneratedType {\r
+\r
+        public GeneratedTypeImpl(GeneratedTypeBuilderImpl builder) {\r
+            super(builder);\r
+        }\r
+    }\r
+}\r
index ed1e97bc239b6e1041b2befd1aadc20dbf595455..6f1c3c95380427458a42f24ff87697228c1f9224 100644 (file)
@@ -86,27 +86,18 @@ class ClassTemplate extends BaseTemplate {
         Â«type.comment.generateComment»\r
         Â«generateClassDeclaration(isInnerClass)» {\r
                Â«innerClassesDeclarations»\r
-\r
             Â«enumDeclarations»\r
-        \r
             Â«constantsDeclarations»\r
-        \r
             Â«generateFields»\r
-        \r
             Â«constructors»\r
-        \r
             Â«FOR field : properties SEPARATOR "\n"»\r
                 Â«field.getterMethod»\r
                 Â«IF !field.readOnly»\r
-                \r
                     Â«field.setterMethod»\r
                 Â«ENDIF»\r
             Â«ENDFOR»\r
-        \r
             Â«generateHashCode»\r
-        \r
             Â«generateEquals»\r
-        \r
             Â«generateToString»\r
         \r
         }\r
@@ -171,11 +162,11 @@ class ClassTemplate extends BaseTemplate {
     \r
     def protected parentConstructor() '''\r
     /**\r
-     * Creates a new instance from Â«genTO.extends.importedName»\r
+     * Creates a new instance from Â«genTO.superType.importedName»\r
      *\r
      * @param source Source object\r
      */\r
-    public Â«type.name»(«genTO.extends.importedName» source) {\r
+    public Â«type.name»(«genTO.superType.importedName» source) {\r
             super(source);\r
     }\r
     '''\r
@@ -209,8 +200,8 @@ class ClassTemplate extends BaseTemplate {
         ELSE»«\r
             " "»«\r
         ENDIF»class Â«type.name»«\r
-        IF (genTO.extends != null)»«\r
-            " extends "»«genTO.extends.importedName»«\r
+        IF (genTO.superType != null)»«\r
+            " extends "»«genTO.superType.importedName»«\r
         ENDIF»«\r
         IF (!type.implements.empty)»«\r
             " implements "»«\r
index 2182f3d3e9cb0825dd7215cc09e8074bff5ed07e..6204ef1b97035da5fbabf4402013b9e7a147fe13 100644 (file)
@@ -372,10 +372,10 @@ public final class GeneratorUtil {
         if (childTransportObject == null) {\r
             throw new IllegalArgumentException("Parameter childTransportObject can't be null.");\r
         }\r
-        if (childTransportObject.getExtends() == null) {\r
+        if (childTransportObject.getSuperType() == null) {\r
             return childTransportObject;\r
         } else {\r
-            return getTopParrentTransportObject(childTransportObject.getExtends());\r
+            return getTopParrentTransportObject(childTransportObject.getSuperType());\r
         }\r
     }\r
 \r
@@ -414,11 +414,11 @@ public final class GeneratorUtil {
      */\r
     public static List<GeneratedProperty> getPropertiesOfAllParents(GeneratedTransferObject genTO) {\r
         List<GeneratedProperty> propertiesOfAllParents = new ArrayList<GeneratedProperty>();\r
-        if (genTO.getExtends() != null) {\r
-            final List<GeneratedProperty> allPropertiesOfTO = genTO.getExtends().getProperties();\r
+        if (genTO.getSuperType() != null) {\r
+            final List<GeneratedProperty> allPropertiesOfTO = genTO.getSuperType().getProperties();\r
             List<GeneratedProperty> readOnlyPropertiesOfTO = resolveReadOnlyPropertiesFromTO(allPropertiesOfTO);\r
             propertiesOfAllParents.addAll(readOnlyPropertiesOfTO);\r
-            propertiesOfAllParents.addAll(getPropertiesOfAllParents(genTO.getExtends()));\r
+            propertiesOfAllParents.addAll(getPropertiesOfAllParents(genTO.getSuperType()));\r
         }\r
         return propertiesOfAllParents;\r
     }\r
index c68a993b438f898d6d1de8cfa5d423dcb46041ce..df7ba966cbda71967e192bc2c50f40cf64cbec52 100644 (file)
@@ -1,81 +1,72 @@
-/*
- * 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.yangtools.sal.binding.model.api;
-
-import java.util.List;
-
-/**
- * Generated Transfer Object extends {@link GeneratedType} and is designed to
- * represent Java Class. The Generated Transfer Object contains declarations of
- * member fields stored in List of Properties. The Generated Transfer Object can
- * be extended by exactly ONE Generated Transfer Object as Java don't allow
- * multiple inheritance. For retrieval of implementing Generated Types use
- * {@link #getImplements()} method. <br>
- * Every transfer object SHOULD contain equals, hashCode and toString
- * definitions. For this purpose retrieve definitions through
- * {@link #getEqualsIdentifiers ()}, {@link #getHashCodeIdentifiers()} and
- * {@link #getToStringIdentifiers ()}.
- * 
- */
-public interface GeneratedTransferObject extends GeneratedType {
-
-    /**
-     * Returns the extending Generated Transfer Object or <code>null</code> if
-     * there is no extending Generated Transfer Object.
-     * 
-     * @return the extending Generated Transfer Object or <code>null</code> if
-     *         there is no extending Generated Transfer Object.
-     */
-    public GeneratedTransferObject getExtends();
-
-    /**
-     * Returns List of Properties that are declared for Generated Transfer
-     * Object.
-     * 
-     * @return List of Properties that are declared for Generated Transfer
-     *         Object.
-     */
-    public List<GeneratedProperty> getProperties();
-
-    /**
-     * Returns List of Properties that are designated to define equality for
-     * Generated Transfer Object.
-     * 
-     * @return List of Properties that are designated to define equality for
-     *         Generated Transfer Object.
-     */
-    public List<GeneratedProperty> getEqualsIdentifiers();
-
-    /**
-     * Returns List of Properties that are designated to define identity for
-     * Generated Transfer Object.
-     * 
-     * @return List of Properties that are designated to define identity for
-     *         Generated Transfer Object.
-     */
-    public List<GeneratedProperty> getHashCodeIdentifiers();
-
-    /**
-     * Returns List of Properties that will be members of toString definition
-     * for Generated Transfer Object.
-     * 
-     * @return List of Properties that will be members of toString definition
-     *         for Generated Transfer Object.
-     */
-    public List<GeneratedProperty> getToStringIdentifiers();
-
-    /**
-     * Return boolean value which describe whether Generated Transfer Object
-     * was/wasn't created from union YANG type.
-     * 
-     * @return true value if Generated Transfer Object was created from union
-     *         YANG type.
-     */
-    @Deprecated
-    public boolean isUnionType();
-}
+/*\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.yangtools.sal.binding.model.api;\r
+\r
+import java.util.List;\r
+\r
+/**\r
+ * Generated Transfer Object extends {@link GeneratedType} and is designed to\r
+ * represent Java Class. The Generated Transfer Object contains declarations of\r
+ * member fields stored in List of Properties. The Generated Transfer Object can\r
+ * be extended by exactly ONE Generated Transfer Object as Java don't allow\r
+ * multiple inheritance. For retrieval of implementing Generated Types use\r
+ * {@link #getImplements()} method. <br>\r
+ * Every transfer object SHOULD contain equals, hashCode and toString\r
+ * definitions. For this purpose retrieve definitions through\r
+ * {@link #getEqualsIdentifiers ()}, {@link #getHashCodeIdentifiers()} and\r
+ * {@link #getToStringIdentifiers ()}.\r
+ * \r
+ */\r
+public interface GeneratedTransferObject extends GeneratedType {\r
+\r
+    /**\r
+     * Returns the extending Generated Transfer Object or <code>null</code> if\r
+     * there is no extending Generated Transfer Object.\r
+     * \r
+     * @return the extending Generated Transfer Object or <code>null</code> if\r
+     *         there is no extending Generated Transfer Object.\r
+     */\r
+    public GeneratedTransferObject getSuperType();\r
+\r
+    /**\r
+     * Returns List of Properties that are designated to define equality for\r
+     * Generated Transfer Object.\r
+     * \r
+     * @return List of Properties that are designated to define equality for\r
+     *         Generated Transfer Object.\r
+     */\r
+    public List<GeneratedProperty> getEqualsIdentifiers();\r
+\r
+    /**\r
+     * Returns List of Properties that are designated to define identity for\r
+     * Generated Transfer Object.\r
+     * \r
+     * @return List of Properties that are designated to define identity for\r
+     *         Generated Transfer Object.\r
+     */\r
+    public List<GeneratedProperty> getHashCodeIdentifiers();\r
+\r
+    /**\r
+     * Returns List of Properties that will be members of toString definition\r
+     * for Generated Transfer Object.\r
+     * \r
+     * @return List of Properties that will be members of toString definition\r
+     *         for Generated Transfer Object.\r
+     */\r
+    public List<GeneratedProperty> getToStringIdentifiers();\r
+\r
+    /**\r
+     * Return boolean value which describe whether Generated Transfer Object\r
+     * was/wasn't created from union YANG type.\r
+     * \r
+     * @return true value if Generated Transfer Object was created from union\r
+     *         YANG type.\r
+     */\r
+    @Deprecated\r
+    public boolean isUnionType();\r
+}\r
index e2159940487f3828b5a313585f648c26e993287c..f9a90945ec9df165145133e11fa43c2d987dcace 100644 (file)
-/*
- * 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.yangtools.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>Each Generated Type can define list of types that Generated Type
- * can implement to extend it's definition (i.e. interface extends list of
- * interfaces or java class implements list of interfaces)</li>
- * <li>Each Generated Type can contain multiple enclosed definitions of
- * Generated Types (i.e. interface can contain N enclosed interface
- * definitions or enclosed classes)</li>
- * <li><code>enum</code> and <code>constant</code> definitions (i.e. each
- * constant definition is by default defined as <code>public static final</code>
- * + type (either primitive or object) and constant name</li>
- * <li><code>method definitions</code> with specified input parameters (with
- * types) and return values</li>
- * </ul>
- *
- * By the definition of the interface constant, enum,
- * enclosed types and method definitions MUST
- * be public, so there is no need to specify the scope of visibility.
- */
-public interface GeneratedType extends Type {
-
-    /**
-     * Returns the parent type if Generated Type is defined as enclosing type,
-     * otherwise returns <code>null</code>
-     *
-     * @return the parent type if Generated Type is defined as enclosing type,
-     * otherwise returns <code>null</code>
-     */
-    public Type getParentType();
-
-    /**
-     * Returns comment string associated with Generated Type.
-     *
-     * @return comment string associated with Generated Type.
-     */
-    public String getComment();
-
-    /**
-     * Returns List of annotation definitions associated with generated type.
-     *
-     * @return List of annotation definitions associated with generated type.
-     */
-    public List<AnnotationType> getAnnotations();
-
-    /**
-     * Returns <code>true</code> if The Generated Type is defined as abstract.
-     *
-     * @return <code>true</code> if The Generated Type is defined as abstract.
-     */
-    public boolean isAbstract();
-
-    /**
-     * Returns List of Types that Generated Type will implement.
-     *
-     * @return List of Types that Generated Type will implement.
-     */
-    public List<Type> getImplements();
-
-    /**
-     * Returns List of enclosing Generated Types.
-     *
-     * @return List of enclosing Generated Types.
-     */
-    public List<GeneratedType> getEnclosedTypes();
-
-    /**
-     * Returns List of all Enumerator definitions associated with Generated
-     * Type.
-     *
-     * @return List of all Enumerator definitions associated with Generated
-     * Type.
-     */
-    public List<Enumeration> getEnumerations();
-
-    /**
-     * Returns List of Constant definitions associated with Generated Type.
-     *
-     * @return List of Constant definitions associated with Generated Type.
-     */
-    public List<Constant> getConstantDefinitions();
-
-    /**
-     * Returns List of Method Definitions associated with Generated Type.
-     *
-     * @return List of Method Definitions associated with Generated Type.
-     */
-    public List<MethodSignature> getMethodDefinitions();
-}
+/*\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.yangtools.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>Each Generated Type can define list of types that Generated Type\r
+ * can implement to extend it's definition (i.e. interface extends list of\r
+ * interfaces or java class implements list of interfaces)</li>\r
+ * <li>Each Generated Type can contain multiple enclosed definitions of\r
+ * Generated Types (i.e. interface can contain N enclosed interface\r
+ * definitions or enclosed classes)</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,\r
+ * enclosed types and method definitions MUST\r
+ * be public, so there is no need to specify the scope of visibility.\r
+ */\r
+public interface GeneratedType extends Type {\r
+\r
+    /**\r
+     * Returns the parent type if Generated Type is defined as enclosing type,\r
+     * otherwise returns <code>null</code>\r
+     *\r
+     * @return the parent type if Generated Type is defined as enclosing type,\r
+     * otherwise returns <code>null</code>\r
+     */\r
+    public Type getParentType();\r
+\r
+    /**\r
+     * Returns comment string associated with Generated Type.\r
+     *\r
+     * @return comment string associated with Generated Type.\r
+     */\r
+    public String getComment();\r
+\r
+    /**\r
+     * Returns List of annotation definitions associated with generated type.\r
+     *\r
+     * @return List of annotation definitions associated with generated type.\r
+     */\r
+    public List<AnnotationType> getAnnotations();\r
+\r
+    /**\r
+     * Returns <code>true</code> if The Generated Type is defined as abstract.\r
+     *\r
+     * @return <code>true</code> if The Generated Type is defined as abstract.\r
+     */\r
+    public boolean isAbstract();\r
+\r
+    /**\r
+     * Returns List of Types that Generated Type will implement.\r
+     *\r
+     * @return List of Types that Generated Type will implement.\r
+     */\r
+    public List<Type> getImplements();\r
+\r
+    /**\r
+     * Returns List of enclosing Generated Types.\r
+     *\r
+     * @return List of enclosing Generated Types.\r
+     */\r
+    public List<GeneratedType> getEnclosedTypes();\r
+\r
+    /**\r
+     * Returns List of all Enumerator definitions associated with Generated\r
+     * Type.\r
+     *\r
+     * @return List of all Enumerator definitions associated with Generated\r
+     * Type.\r
+     */\r
+    public List<Enumeration> getEnumerations();\r
+\r
+    /**\r
+     * Returns List of Constant definitions associated with Generated Type.\r
+     *\r
+     * @return List of Constant definitions associated with Generated Type.\r
+     */\r
+    public List<Constant> getConstantDefinitions();\r
+\r
+    /**\r
+     * Returns List of Method Definitions associated with Generated Type.\r
+     * \r
+     * List does not contains getters and setters for properties.\r
+     *\r
+     * @return List of Method Definitions associated with Generated Type.\r
+     */\r
+    public List<MethodSignature> getMethodDefinitions();\r
+    \r
+    /**\r
+     * Returns List of Properties that are declared for Generated Transfer\r
+     * Object.\r
+     * \r
+     * @return List of Properties that are declared for Generated Transfer\r
+     *         Object.\r
+     */\r
+    public List<GeneratedProperty> getProperties();\r
+    \r
+}\r
index c693232d2420fea8239c20b911239376a1655ac8..b4fafbf84b60d46770043a88888b91f2381085bd 100644 (file)
-/*
- * 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.yangtools.sal.binding.model.api.type.builder;
-
-import org.opendaylight.yangtools.sal.binding.model.api.GeneratedTransferObject;
-
-/**
- * Generated Transfer Object Builder is interface that contains methods to build
- * and instantiate Generated Transfer Object definition.
- * 
- * @see GeneratedTransferObject
- */
-public interface GeneratedTOBuilder extends GeneratedTypeBuilder {
-
-    /**
-     * Add Generated Transfer Object from which will be extended current
-     * Generated Transfer Object. <br>
-     * By definition Java does not allow multiple inheritance, hence if there is
-     * already definition of Generated Transfer Object the extending object will
-     * be overwritten by lastly added Generated Transfer Object. <br>
-     * If Generated Transfer Object is <code>null</code> the method SHOULD throw
-     * {@link IllegalArgumentException}
-     * 
-     * @param genTransObj
-     *            Generated Transfer Object
-     */
-    public void setExtendsType(final GeneratedTransferObject genTransObj);
-
-    /**
-     * Add new Generated Property definition for Generated Transfer Object
-     * Builder and returns Generated Property Builder for specifying Property. <br>
-     * Name of Property cannot be <code>null</code>, if it is <code>null</code>
-     * the method SHOULD throw {@link IllegalArgumentException}
-     * 
-     * @param name
-     *            Name of Property
-     * @return <code>new</code> instance of Generated Property Builder.
-     */
-    public GeneratedPropertyBuilder addProperty(final String name);
-
-    /**
-     * Check whether GeneratedTOBuilder contains property with name
-     * <code>name</code>
-     * 
-     * @param name
-     *            of property which existance is checked
-     * @return true if property <code>name</code> exists in list of properties.
-     */
-    public boolean containsProperty(final String name);
-
-    /**
-     * Add Property that will be part of <code>equals</code> definition. <br>
-     * If Generated Property Builder is <code>null</code> the method SHOULD
-     * throw {@link IllegalArgumentException}
-     * 
-     * @param property
-     *            Generated Property Builder
-     * @return <code>true</code> if addition of Generated Property into list of
-     *         <code>equals</code> properties is successful.
-     */
-    public boolean addEqualsIdentity(final GeneratedPropertyBuilder property);
-
-    /**
-     * Add Property that will be part of <code>hashCode</code> definition. <br>
-     * If Generated Property Builder is <code>null</code> the method SHOULD
-     * throw {@link IllegalArgumentException}
-     * 
-     * @param property
-     *            Generated Property Builder
-     * @return <code>true</code> if addition of Generated Property into list of
-     *         <code>hashCode</code> properties is successful.
-     */
-    public boolean addHashIdentity(final GeneratedPropertyBuilder property);
-
-    /**
-     * Add Property that will be part of <code>toString</code> definition. <br>
-     * If Generated Property Builder is <code>null</code> the method SHOULD
-     * throw {@link IllegalArgumentException}
-     * 
-     * @param property
-     *            Generated Property Builder
-     * @return <code>true</code> if addition of Generated Property into list of
-     *         <code>toString</code> properties is successful.
-     */
-    public boolean addToStringProperty(final GeneratedPropertyBuilder property);
-
-    @Override
-    public GeneratedTransferObject toInstance();
-
-    /**
-     * Set original YANG type for GeneratedTOBuilder. It is YANG type from which
-     * is this transport object created.
-     * 
-     * @param yangType
-     *            YangType enum value of original YANG type
-     */
-    public void setIsUnion(boolean isUnion);
-}
+/*\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.yangtools.sal.binding.model.api.type.builder;\r
+\r
+import org.opendaylight.yangtools.sal.binding.model.api.GeneratedTransferObject;\r
+\r
+/**\r
+ * Generated Transfer Object Builder is interface that contains methods to build\r
+ * and instantiate Generated Transfer Object definition.\r
+ * \r
+ * @see GeneratedTransferObject\r
+ */\r
+public interface GeneratedTOBuilder extends GeneratedTypeBuilder {\r
+\r
+    /**\r
+     * Add Generated Transfer Object from which will be extended current\r
+     * Generated Transfer Object. <br>\r
+     * By definition Java does not allow multiple inheritance, hence if there is\r
+     * already definition of Generated Transfer Object the extending object will\r
+     * be overwritten by lastly added Generated Transfer Object. <br>\r
+     * If Generated Transfer Object is <code>null</code> the method SHOULD throw\r
+     * {@link IllegalArgumentException}\r
+     * \r
+     * @param genTransObj\r
+     *            Generated Transfer Object\r
+     */\r
+    public void setExtendsType(final GeneratedTransferObject genTransObj);\r
+\r
+    /**\r
+     * Add Property that will be part of <code>equals</code> definition. <br>\r
+     * If Generated Property Builder is <code>null</code> the method SHOULD\r
+     * throw {@link IllegalArgumentException}\r
+     * \r
+     * @param property\r
+     *            Generated Property Builder\r
+     * @return <code>true</code> if addition of Generated Property into list of\r
+     *         <code>equals</code> properties is successful.\r
+     */\r
+    public boolean addEqualsIdentity(final GeneratedPropertyBuilder property);\r
+\r
+    /**\r
+     * Add Property that will be part of <code>hashCode</code> definition. <br>\r
+     * If Generated Property Builder is <code>null</code> the method SHOULD\r
+     * throw {@link IllegalArgumentException}\r
+     * \r
+     * @param property\r
+     *            Generated Property Builder\r
+     * @return <code>true</code> if addition of Generated Property into list of\r
+     *         <code>hashCode</code> properties is successful.\r
+     */\r
+    public boolean addHashIdentity(final GeneratedPropertyBuilder property);\r
+\r
+    /**\r
+     * Add Property that will be part of <code>toString</code> definition. <br>\r
+     * If Generated Property Builder is <code>null</code> the method SHOULD\r
+     * throw {@link IllegalArgumentException}\r
+     * \r
+     * @param property\r
+     *            Generated Property Builder\r
+     * @return <code>true</code> if addition of Generated Property into list of\r
+     *         <code>toString</code> properties is successful.\r
+     */\r
+    public boolean addToStringProperty(final GeneratedPropertyBuilder property);\r
+\r
+    @Override\r
+    public GeneratedTransferObject toInstance();\r
+\r
+    /**\r
+     * Set original YANG type for GeneratedTOBuilder. It is YANG type from which\r
+     * is this transport object created.\r
+     * \r
+     * @param yangType\r
+     *            YangType enum value of original YANG type\r
+     */\r
+    public void setIsUnion(boolean isUnion);\r
+}\r
index acf8043a350b9b4a09d4a1f4ffadf71ed38c9a9e..d7d78f466c0bfcff6d7e1d229901b0744428d9fb 100644 (file)
-/*
- * 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.yangtools.sal.binding.model.api.type.builder;
-
-import org.opendaylight.yangtools.sal.binding.model.api.Constant;
-import org.opendaylight.yangtools.sal.binding.model.api.GeneratedType;
-import org.opendaylight.yangtools.sal.binding.model.api.Type;
-
-/**
- * Generated Type Builder interface is helper interface for building and
- * defining the GeneratedType.
- * 
- * @see GeneratedType
- */
-public interface GeneratedTypeBuilder extends Type {
-
-    /**
-     * Adds new Enclosing Type into definition of Generated Type and returns
-     * <code>new</code> Instance of Generated Type Builder. <br>
-     * There is no need of specifying of Package Name because enclosing Type is
-     * already defined inside Generated Type with specific package name. <br>
-     * The name of enclosing Type cannot be same as Name of parent type and if
-     * there is already defined enclosing type with the same name, the new
-     * enclosing type will simply overwrite the older definition. <br>
-     * If the name of enclosing type is <code>null</code> the method SHOULD
-     * throw {@link IllegalArgumentException}
-     * 
-     * @param name
-     *            Name of Enclosing Type
-     * @return <code>new</code> Instance of Generated Type Builder.
-     */
-    public GeneratedTypeBuilder addEnclosingType(final String name);
-
-    /**
-     * Adds new Enclosing Transfer Object into definition of Generated Type and
-     * returns <code>new</code> Instance of Generated TO Builder. <br>
-     * There is no need of specifying of Package Name because enclosing Type is
-     * already defined inside Generated Type with specific package name. <br>
-     * The name of enclosing Type cannot be same as Name of parent type and if
-     * there is already defined enclosing type with the same name, the new
-     * enclosing type will simply overwrite the older definition. <br>
-     * If the name of enclosing type is <code>null</code> the method SHOULD
-     * throw {@link IllegalArgumentException}
-     * 
-     * @param name
-     *            Name of Enclosing Type
-     * @return <code>new</code> Instance of Generated Type Builder.
-     */
-    public GeneratedTOBuilder addEnclosingTransferObject(final String name);
-
-    /**
-     * Adds new Enclosing Transfer Object <code>genTOBuilder</code> into
-     * definition of Generated Type
-     * 
-     * <br>
-     * There is no need of specifying of Package Name because enclosing Type is
-     * already defined inside Generated Type with specific package name. <br>
-     * The name of enclosing Type cannot be same as Name of parent type and if
-     * there is already defined enclosing type with the same name, the new
-     * enclosing type will simply overwrite the older definition. <br>
-     * If the parameter <code>genTOBuilder</code> of enclosing type is
-     * <code>null</code> the method SHOULD throw
-     * {@link IllegalArgumentException}
-     * 
-     * @param <code>genTOBuilder</code> Name of Enclosing Type
-     */
-    public void addEnclosingTransferObject(final GeneratedTOBuilder genTOBuilder);
-
-    /**
-     * Adds String definition of comment into Method Signature definition. <br>
-     * The comment String MUST NOT contain anny comment specific chars (i.e.
-     * "/**" or "//") just plain String text description.
-     * 
-     * @param comment
-     *            Comment String.
-     */
-    public void addComment(final String comment);
-
-    /**
-     * The method creates new AnnotationTypeBuilder containing specified package
-     * name an annotation name. <br>
-     * Neither the package name or annotation name can contain <code>null</code>
-     * references. In case that any of parameters contains <code>null</code> the
-     * method SHOULD thrown {@link IllegalArgumentException}
-     * 
-     * @param packageName
-     *            Package Name of Annotation Type
-     * @param name
-     *            Name of Annotation Type
-     * @return <code>new</code> instance of Annotation Type Builder.
-     */
-    public AnnotationTypeBuilder addAnnotation(final String packageName, final String name);
-
-    /**
-     * Sets the <code>abstract</code> flag to define Generated Type as
-     * <i>abstract</i> type.
-     * 
-     * @param isAbstract
-     *            abstract flag
-     */
-    public void setAbstract(boolean isAbstract);
-
-    /**
-     * Add Type to implements.
-     * 
-     * @param genType
-     *            Type to implement
-     * @return <code>true</code> if the addition of type is successful.
-     */
-    public boolean addImplementsType(final Type genType);
-
-    /**
-     * Adds Constant definition and returns <code>new</code> Constant instance. <br>
-     * By definition Constant MUST be defined by return Type, Name and assigned
-     * value. The name SHOULD be defined with cpaital letters. Neither of method
-     * parameters can be <code>null</code> and the method SHOULD throw
-     * {@link IllegalArgumentException} if the contract is broken.
-     * 
-     * @param type
-     *            Constant Type
-     * @param name
-     *            Name of Constant
-     * @param value
-     *            Assigned Value
-     * @return <code>new</code> Constant instance.
-     */
-    public Constant addConstant(final Type type, final String name, final Object value);
-
-    /**
-     * Adds new Enumeration definition for Generated Type Builder and returns
-     * Enum Builder for specifying all Enum parameters. <br>
-     * If there is already Enumeration stored with the same name, the old enum
-     * will be simply overwritten byt new enum definition. <br>
-     * Name of Enumeration cannot be <code>null</code>, if it is
-     * <code>null</code> the method SHOULD throw
-     * {@link IllegalArgumentException}
-     * 
-     * @param name
-     *            Enumeration Name
-     * @return <code>new</code> instance of Enumeration Builder.
-     */
-    public EnumBuilder addEnumeration(final String name);
-
-    /**
-     * Add new Method Signature definition for Generated Type Builder and
-     * returns Method Signature Builder for specifying all Method parameters. <br>
-     * Name of Method cannot be <code>null</code>, if it is <code>null</code>
-     * the method SHOULD throw {@link IllegalArgumentException} <br>
-     * By <i>Default</i> the MethodSignatureBuilder SHOULD be pre-set as
-     * {@link MethodSignatureBuilder#setAbstract(true)},
-     * {@link MethodSignatureBuilder#setFinal(false)} and
-     * {@link MethodSignatureBuilder#setAccessModifier(PUBLIC)}
-     * 
-     * @param name
-     *            Name of Method
-     * @return <code>new</code> instance of Method Signature Builder.
-     */
-    public MethodSignatureBuilder addMethod(final String name);
-
-    /**
-     * Checks if GeneratedTypeBuilder contains method with name
-     * <code>methodName</code>
-     * 
-     * @param methodName
-     *            is method name
-     */
-    public boolean containsMethod(final String methodName);
-
-    /**
-     * Returns the <code>new</code> <i>immutable</i> instance of Generated Type.
-     * 
-     * @return the <code>new</code> <i>immutable</i> instance of Generated Type.
-     */
-    public GeneratedType toInstance();
-}
+/*\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.yangtools.sal.binding.model.api.type.builder;\r
+\r
+import org.opendaylight.yangtools.sal.binding.model.api.Constant;\r
+import org.opendaylight.yangtools.sal.binding.model.api.GeneratedType;\r
+import org.opendaylight.yangtools.sal.binding.model.api.Type;\r
+\r
+/**\r
+ * Generated Type Builder interface is helper interface for building and\r
+ * defining the GeneratedType.\r
+ * \r
+ * @see GeneratedType\r
+ */\r
+public interface GeneratedTypeBuilder extends Type {\r
+\r
+    /**\r
+     * Adds new Enclosing Type into definition of Generated Type and returns\r
+     * <code>new</code> Instance of Generated Type Builder. <br>\r
+     * There is no need of specifying of Package Name because enclosing Type is\r
+     * already defined inside Generated Type with specific package name. <br>\r
+     * The name of enclosing Type cannot be same as Name of parent type and if\r
+     * there is already defined enclosing type with the same name, the new\r
+     * enclosing type will simply overwrite the older definition. <br>\r
+     * If the name of enclosing type is <code>null</code> the method SHOULD\r
+     * throw {@link IllegalArgumentException}\r
+     * \r
+     * @param name\r
+     *            Name of Enclosing Type\r
+     * @return <code>new</code> Instance of Generated Type Builder.\r
+     */\r
+    public GeneratedTypeBuilder addEnclosingType(final String name);\r
+\r
+    /**\r
+     * Adds new Enclosing Transfer Object into definition of Generated Type and\r
+     * returns <code>new</code> Instance of Generated TO Builder. <br>\r
+     * There is no need of specifying of Package Name because enclosing Type is\r
+     * already defined inside Generated Type with specific package name. <br>\r
+     * The name of enclosing Type cannot be same as Name of parent type and if\r
+     * there is already defined enclosing type with the same name, the new\r
+     * enclosing type will simply overwrite the older definition. <br>\r
+     * If the name of enclosing type is <code>null</code> the method SHOULD\r
+     * throw {@link IllegalArgumentException}\r
+     * \r
+     * @param name\r
+     *            Name of Enclosing Type\r
+     * @return <code>new</code> Instance of Generated Type Builder.\r
+     */\r
+    public GeneratedTOBuilder addEnclosingTransferObject(final String name);\r
+\r
+    /**\r
+     * Adds new Enclosing Transfer Object <code>genTOBuilder</code> into\r
+     * definition of Generated Type\r
+     * \r
+     * <br>\r
+     * There is no need of specifying of Package Name because enclosing Type is\r
+     * already defined inside Generated Type with specific package name. <br>\r
+     * The name of enclosing Type cannot be same as Name of parent type and if\r
+     * there is already defined enclosing type with the same name, the new\r
+     * enclosing type will simply overwrite the older definition. <br>\r
+     * If the parameter <code>genTOBuilder</code> of enclosing type is\r
+     * <code>null</code> the method SHOULD throw\r
+     * {@link IllegalArgumentException}\r
+     * \r
+     * @param <code>genTOBuilder</code> Name of Enclosing Type\r
+     */\r
+    public void addEnclosingTransferObject(final GeneratedTOBuilder genTOBuilder);\r
+\r
+    /**\r
+     * Adds String definition of comment into Method Signature definition. <br>\r
+     * The comment String MUST NOT contain anny comment specific chars (i.e.\r
+     * "/**" or "//") just plain String text description.\r
+     * \r
+     * @param comment\r
+     *            Comment String.\r
+     */\r
+    public void addComment(final String comment);\r
+\r
+    /**\r
+     * The method creates new AnnotationTypeBuilder containing specified package\r
+     * name an annotation name. <br>\r
+     * Neither the package name or annotation name can contain <code>null</code>\r
+     * references. In case that any of parameters contains <code>null</code> the\r
+     * method SHOULD thrown {@link IllegalArgumentException}\r
+     * \r
+     * @param packageName\r
+     *            Package Name of Annotation Type\r
+     * @param name\r
+     *            Name of Annotation Type\r
+     * @return <code>new</code> instance of Annotation Type Builder.\r
+     */\r
+    public AnnotationTypeBuilder addAnnotation(final String packageName, final String name);\r
+\r
+    /**\r
+     * Sets the <code>abstract</code> flag to define Generated Type as\r
+     * <i>abstract</i> type.\r
+     * \r
+     * @param isAbstract\r
+     *            abstract flag\r
+     */\r
+    public void setAbstract(boolean isAbstract);\r
+\r
+    /**\r
+     * Add Type to implements.\r
+     * \r
+     * @param genType\r
+     *            Type to implement\r
+     * @return <code>true</code> if the addition of type is successful.\r
+     */\r
+    public boolean addImplementsType(final Type genType);\r
+\r
+    /**\r
+     * Adds Constant definition and returns <code>new</code> Constant instance. <br>\r
+     * By definition Constant MUST be defined by return Type, Name and assigned\r
+     * value. The name SHOULD be defined with cpaital letters. Neither of method\r
+     * parameters can be <code>null</code> and the method SHOULD throw\r
+     * {@link IllegalArgumentException} if the contract is broken.\r
+     * \r
+     * @param type\r
+     *            Constant Type\r
+     * @param name\r
+     *            Name of Constant\r
+     * @param value\r
+     *            Assigned Value\r
+     * @return <code>new</code> Constant instance.\r
+     */\r
+    public Constant addConstant(final Type type, final String name, final Object value);\r
+\r
+    /**\r
+     * Adds new Enumeration definition for Generated Type Builder and returns\r
+     * Enum Builder for specifying all Enum parameters. <br>\r
+     * If there is already Enumeration stored with the same name, the old enum\r
+     * will be simply overwritten byt new enum definition. <br>\r
+     * Name of Enumeration cannot be <code>null</code>, if it is\r
+     * <code>null</code> the method SHOULD throw\r
+     * {@link IllegalArgumentException}\r
+     * \r
+     * @param name\r
+     *            Enumeration Name\r
+     * @return <code>new</code> instance of Enumeration Builder.\r
+     */\r
+    public EnumBuilder addEnumeration(final String name);\r
+\r
+    /**\r
+     * Add new Method Signature definition for Generated Type Builder and\r
+     * returns Method Signature Builder for specifying all Method parameters. <br>\r
+     * Name of Method cannot be <code>null</code>, if it is <code>null</code>\r
+     * the method SHOULD throw {@link IllegalArgumentException} <br>\r
+     * By <i>Default</i> the MethodSignatureBuilder SHOULD be pre-set as\r
+     * {@link MethodSignatureBuilder#setAbstract(true)},\r
+     * {@link MethodSignatureBuilder#setFinal(false)} and\r
+     * {@link MethodSignatureBuilder#setAccessModifier(PUBLIC)}\r
+     * \r
+     * @param name\r
+     *            Name of Method\r
+     * @return <code>new</code> instance of Method Signature Builder.\r
+     */\r
+    public MethodSignatureBuilder addMethod(final String name);\r
+\r
+    /**\r
+     * Checks if GeneratedTypeBuilder contains method with name\r
+     * <code>methodName</code>\r
+     * \r
+     * @param methodName\r
+     *            is method name\r
+     */\r
+    public boolean containsMethod(final String methodName);\r
+    \r
+    /**\r
+     * Add new Generated Property definition for Generated Transfer Object\r
+     * Builder and returns Generated Property Builder for specifying Property. <br>\r
+     * Name of Property cannot be <code>null</code>, if it is <code>null</code>\r
+     * the method SHOULD throw {@link IllegalArgumentException}\r
+     * \r
+     * @param name\r
+     *            Name of Property\r
+     * @return <code>new</code> instance of Generated Property Builder.\r
+     */\r
+    public GeneratedPropertyBuilder addProperty(final String name);\r
+\r
+    /**\r
+     * Check whether GeneratedTOBuilder contains property with name\r
+     * <code>name</code>\r
+     * \r
+     * @param name\r
+     *            of property which existance is checked\r
+     * @return true if property <code>name</code> exists in list of properties.\r
+     */\r
+    public boolean containsProperty(final String name);\r
+\r
+    /**\r
+     * Returns the <code>new</code> <i>immutable</i> instance of Generated Type.\r
+     * \r
+     * @return the <code>new</code> <i>immutable</i> instance of Generated Type.\r
+     */\r
+    public GeneratedType toInstance();\r
+}\r