Bug 6859: Cleanup package names for mdsal-binding-generator-util module 80/46780/6
authorRashmi Pujar <rpujar@inocybe.com>
Tue, 11 Oct 2016 16:42:48 +0000 (12:42 -0400)
committerTom Pantelis <tpanteli@brocade.com>
Wed, 2 Nov 2016 00:15:48 +0000 (00:15 +0000)
The APIs are copied to new package.
Added deprecated annotation to the old api.

Change-Id: I4a9d6dd6ea78e16bdb1b86c9f9235b3db00db836
Signed-off-by: Rashmi Pujar <rpujar@inocybe.com>
41 files changed:
binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/AbstractBaseType.java [new file with mode: 0644]
binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/BindingGeneratorUtil.java [new file with mode: 0644]
binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/BindingTypes.java [new file with mode: 0644]
binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/ReferencedTypeImpl.java [new file with mode: 0644]
binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/TypeConstants.java [new file with mode: 0644]
binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/Types.java [new file with mode: 0644]
binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/AbstractGeneratedType.java [new file with mode: 0644]
binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/AbstractGeneratedTypeBuilder.java [new file with mode: 0644]
binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/AbstractTypeMember.java [new file with mode: 0644]
binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/AbstractTypeMemberBuilder.java [new file with mode: 0644]
binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/AnnotationTypeBuilderImpl.java [new file with mode: 0644]
binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/ConstantImpl.java [new file with mode: 0644]
binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/EnumerationBuilderImpl.java [new file with mode: 0644]
binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/GeneratedPropertyBuilderImpl.java [new file with mode: 0644]
binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/GeneratedPropertyImpl.java [new file with mode: 0644]
binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/GeneratedTOBuilderImpl.java [new file with mode: 0644]
binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/GeneratedTypeBuilderImpl.java [new file with mode: 0644]
binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/MethodParameterImpl.java [new file with mode: 0644]
binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/MethodSignatureBuilderImpl.java [new file with mode: 0644]
binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/MethodSignatureImpl.java [new file with mode: 0644]
binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/package-info.java [new file with mode: 0644]
binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/AbstractBaseType.java
binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/BindingGeneratorUtil.java
binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/BindingTypes.java
binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/ReferencedTypeImpl.java
binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/TypeConstants.java
binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/Types.java
binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/AbstractGeneratedType.java
binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/AbstractGeneratedTypeBuilder.java
binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/AbstractTypeMember.java
binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/AbstractTypeMemberBuilder.java
binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/AnnotationTypeBuilderImpl.java
binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/ConstantImpl.java
binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/EnumerationBuilderImpl.java
binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/GeneratedPropertyBuilderImpl.java
binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/GeneratedPropertyImpl.java
binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/GeneratedTOBuilderImpl.java
binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/GeneratedTypeBuilderImpl.java
binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/MethodParameterImpl.java
binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/MethodSignatureBuilderImpl.java
binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/MethodSignatureImpl.java

diff --git a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/AbstractBaseType.java b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/AbstractBaseType.java
new file mode 100644 (file)
index 0000000..c93e8da
--- /dev/null
@@ -0,0 +1,100 @@
+/*
+ * 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.mdsal.binding.generator.util;
+
+import java.util.Objects;
+import org.opendaylight.mdsal.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(final String pkName, final String name) {
+        if (pkName == 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 = pkName;
+        this.name = name;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + Objects.hashCode(name);
+        result = prime * result + Objects.hashCode(packageName);
+        return result;
+    }
+
+    @Override
+    public boolean equals(final Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null) {
+            return false;
+        }
+        if (!(obj instanceof Type)) {
+            return false;
+        }
+        Type other = (Type) obj;
+        return Objects.equals(name, other.getName()) && Objects.equals(packageName, other.getPackageName());
+    }
+
+    @Override
+    public String toString() {
+        if (packageName.isEmpty()) {
+            return "Type (" + name + ")";
+        }
+        return "Type (" + packageName + "." + name + ")";
+    }
+}
diff --git a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/BindingGeneratorUtil.java b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/BindingGeneratorUtil.java
new file mode 100644 (file)
index 0000000..f79ae30
--- /dev/null
@@ -0,0 +1,644 @@
+/*
+ * Copyright (c) 2014 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.mdsal.binding.generator.util;
+
+import com.google.common.base.CharMatcher;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableList.Builder;
+import com.google.common.collect.Iterables;
+import java.io.ByteArrayOutputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.List;
+import org.opendaylight.mdsal.binding.model.api.AccessModifier;
+import org.opendaylight.mdsal.binding.model.api.Restrictions;
+import org.opendaylight.mdsal.binding.model.api.Type;
+import org.opendaylight.mdsal.binding.model.api.type.builder.GeneratedPropertyBuilder;
+import org.opendaylight.mdsal.binding.model.api.type.builder.GeneratedTypeBuilderBase;
+import org.opendaylight.mdsal.binding.model.api.type.builder.MethodSignatureBuilder;
+import org.opendaylight.mdsal.binding.model.api.type.builder.TypeMemberBuilder;
+import org.opendaylight.yangtools.yang.binding.BindingMapping;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.QNameModule;
+import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.BinaryTypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.DecimalTypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.IntegerTypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.LengthConstraint;
+import org.opendaylight.yangtools.yang.model.api.type.PatternConstraint;
+import org.opendaylight.yangtools.yang.model.api.type.RangeConstraint;
+import org.opendaylight.yangtools.yang.model.api.type.StringTypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinition;
+import org.opendaylight.yangtools.yang.model.util.type.BaseTypes;
+import org.opendaylight.yangtools.yang.model.util.type.DecimalTypeBuilder;
+
+/**
+ * Contains the methods for converting strings to valid JAVA language strings
+ * (package names, class names, attribute names) and to valid javadoc comments.
+ *
+ *
+ */
+public final class BindingGeneratorUtil {
+
+    /**
+     * Impossible to instantiate this class. All of the methods or attributes
+     * are static.
+     */
+    private BindingGeneratorUtil() {
+    }
+
+    /**
+     * Pre-compiled replacement pattern.
+     */
+    private static final CharMatcher DOT_MATCHER = CharMatcher.is('.');
+    private static final CharMatcher DASH_COLON_MATCHER = CharMatcher.anyOf("-:");
+    private static final CharMatcher GT_MATCHER = CharMatcher.is('>');
+    private static final CharMatcher LT_MATCHER = CharMatcher.is('<');
+
+    private static final Restrictions EMPTY_RESTRICTIONS = new Restrictions() {
+        @Override
+        public List<LengthConstraint> getLengthConstraints() {
+            return Collections.emptyList();
+        }
+
+        @Override
+        public List<PatternConstraint> getPatternConstraints() {
+            return Collections.emptyList();
+        }
+
+        @Override
+        public List<RangeConstraint> getRangeConstraints() {
+            return Collections.emptyList();
+        }
+
+        @Override
+        public boolean isEmpty() {
+            return true;
+        }
+    };
+
+    private static final Comparator<TypeMemberBuilder<?>> SUID_MEMBER_COMPARATOR =
+        (o1, o2) -> o1.getName().compareTo(o2.getName());
+
+    private static final Comparator<Type> SUID_NAME_COMPARATOR =
+        (o1, o2) -> o1.getFullyQualifiedName().compareTo(o2.getFullyQualifiedName());
+
+    /**
+     * Converts <code>parameterName</code> to valid JAVA parameter name.
+     *
+     * If the <code>parameterName</code> is one of the JAVA reserved words then
+     * it is prefixed with underscore character.
+     *
+     * @param parameterName
+     *            string with the parameter name
+     * @return string with the admissible parameter name
+     */
+    public static String resolveJavaReservedWordEquivalency(final String parameterName) {
+        if (parameterName != null && BindingMapping.JAVA_RESERVED_WORDS.contains(parameterName)) {
+            return "_" + parameterName;
+        }
+        return parameterName;
+    }
+
+    /**
+     * Converts module name to valid JAVA package name.
+     *
+     * The package name consists of:
+     * <ul>
+     * <li>prefix - <i>org.opendaylight.yang.gen.v</i></li>
+     * <li>module YANG version - <i>org.opendaylight.yang.gen.v</i></li>
+     * <li>module namespace - invalid characters are replaced with dots</li>
+     * <li>revision prefix - <i>.rev</i></li>
+     * <li>revision - YYYYMMDD (MM and DD aren't spread to the whole length)</li>
+     * </ul>
+     *
+     * @param module
+     *            module which contains data about namespace and revision date
+     * @return string with the valid JAVA package name
+     * @throws IllegalArgumentException
+     *             if the revision date of the <code>module</code> equals
+     *             <code>null</code>
+     * @deprecated USe {@link BindingMapping#getRootPackageName(QNameModule)} with {@link Module#getQNameModule()}.
+     */
+    @Deprecated
+    public static String moduleNamespaceToPackageName(final Module module) {
+        return BindingMapping.getRootPackageName(module.getQNameModule());
+    }
+
+    /**
+     * Creates package name from specified <code>basePackageName</code> (package
+     * name for module) and <code>schemaPath</code>.
+     *
+     * Resulting package name is concatenation of <code>basePackageName</code>
+     * and all local names of YANG nodes which are parents of some node for
+     * which <code>schemaPath</code> is specified.
+     *
+     * @param basePackageName
+     *            string with package name of the module, MUST be normalized,
+     *            otherwise this method may return an invalid string.
+     * @param schemaPath
+     *            list of names of YANG nodes which are parents of some node +
+     *            name of this node
+     * @return string with valid JAVA package name
+     * @throws NullPointerException if any of the arguments are null
+     */
+    public static String packageNameForGeneratedType(final String basePackageName, final SchemaPath schemaPath) {
+        final int size = Iterables.size(schemaPath.getPathTowardsRoot()) - 1;
+        if (size <= 0) {
+            return basePackageName;
+        }
+
+        return generateNormalizedPackageName(basePackageName, schemaPath.getPathFromRoot(), size);
+    }
+
+    /**
+     * Creates package name from specified <code>basePackageName</code> (package
+     * name for module) and <code>schemaPath</code> which crosses an augmentation.
+     *
+     * Resulting package name is concatenation of <code>basePackageName</code>
+     * and all local names of YANG nodes which are parents of some node for
+     * which <code>schemaPath</code> is specified.
+     *
+     * @param basePackageName
+     *            string with package name of the module, MUST be normalized,
+     *            otherwise this method may return an invalid string.
+     * @param schemaPath
+     *            list of names of YANG nodes which are parents of some node +
+     *            name of this node
+     * @return string with valid JAVA package name
+     * @throws NullPointerException if any of the arguments are null
+     */
+    public static String packageNameForAugmentedGeneratedType(final String basePackageName, final SchemaPath schemaPath) {
+        final int size = Iterables.size(schemaPath.getPathTowardsRoot());
+        if (size == 0) {
+            return basePackageName;
+        }
+
+        return generateNormalizedPackageName(basePackageName, schemaPath.getPathFromRoot(), size);
+    }
+
+    private static String generateNormalizedPackageName(final String base, final Iterable<QName> path, final int size) {
+        final StringBuilder builder = new StringBuilder(base);
+        final Iterator<QName> iterator = path.iterator();
+        for (int i = 0; i < size; ++i) {
+            builder.append('.');
+            String nodeLocalName = iterator.next().getLocalName();
+            // FIXME: Collon ":" is invalid in node local name as per RFC6020, identifier statement.
+            builder.append(DASH_COLON_MATCHER.replaceFrom(nodeLocalName, '.'));
+        }
+        return BindingMapping.normalizePackageName(builder.toString());
+    }
+
+    /**
+     * Creates package name from specified <code>basePackageName</code> (package
+     * name for module) and <code>schemaPath</code>.
+     *
+     * Resulting package name is concatenation of <code>basePackageName</code>
+     * and all local names of YANG nodes which are parents of some node for
+     * which <code>schemaPath</code> is specified.
+     *
+     * @param basePackageName
+     *            string with package name of the module
+     * @param schemaPath
+     *            list of names of YANG nodes which are parents of some node +
+     *            name of this node
+     * @param isUsesAugment
+     *            boolean true if using augment
+     * @return string with valid JAVA package name
+     *
+     * @deprecated Use {@link #packageNameForGeneratedType(String, SchemaPath)} or
+     *             {@link #packageNameForAugmentedGeneratedType(String, SchemaPath)} instead.
+     */
+    @Deprecated
+    public static String packageNameForGeneratedType(final String basePackageName, final SchemaPath schemaPath,
+            final boolean isUsesAugment) {
+        if (basePackageName == null) {
+            throw new IllegalArgumentException("Base Package Name cannot be NULL!");
+        }
+        if (schemaPath == null) {
+            throw new IllegalArgumentException("Schema Path cannot be NULL!");
+        }
+
+        final Iterable<QName> iterable = schemaPath.getPathFromRoot();
+        final int size = Iterables.size(iterable);
+        final int traversalSteps;
+        if (isUsesAugment) {
+            traversalSteps = size;
+        } else {
+            traversalSteps = size - 1;
+        }
+
+        if (traversalSteps == 0) {
+            return BindingMapping.normalizePackageName(basePackageName);
+        }
+
+        return generateNormalizedPackageName(basePackageName, iterable, traversalSteps);
+    }
+
+    /**
+     * Generates the package name for type definition from
+     * <code>typeDefinition</code> and <code>basePackageName</code>.
+     *
+     * @param basePackageName
+     *            string with the package name of the module
+     * @param typeDefinition
+     *            type definition for which the package name will be generated *
+     * @return string with valid JAVA package name
+     * @throws IllegalArgumentException
+     *             <ul>
+     *             <li>if <code>basePackageName</code> equals <code>null</code></li>
+     *             <li>if <code>typeDefinition</code> equals <code>null</code></li>
+     *             </ul>
+     * @deprecated This method ignores typeDefinition argument and its result is only
+     *             <code>BindingMapping.normalizePackageName(basePackageName)</code>.
+     *             Aside from tests, there is not a single user in OpenDaylight codebase,
+     *             hence it can be considered buggy and defunct. It is scheduled for removal
+     *             in Boron release.
+     */
+    @Deprecated
+    public static String packageNameForTypeDefinition(final String basePackageName,
+            final TypeDefinition<?> typeDefinition) {
+        if (basePackageName == null) {
+            throw new IllegalArgumentException("Base Package Name cannot be NULL!");
+        }
+        if (typeDefinition == null) {
+            throw new IllegalArgumentException("Type Definition reference cannot be NULL!");
+        }
+
+        return BindingMapping.normalizePackageName(basePackageName);
+    }
+
+    /**
+     * Converts <code>token</code> to string which is in accordance with best
+     * practices for JAVA class names.
+     *
+     * @param token
+     *            string which contains characters which should be converted to
+     *            JAVA class name
+     * @return string which is in accordance with best practices for JAVA class
+     *         name.
+     *
+     * @deprecated Use {@link BindingMapping#getClassName(QName)} instead.
+     */
+    @Deprecated
+    public static String parseToClassName(final String token) {
+        return parseToCamelCase(token, true);
+    }
+
+    /**
+     * Converts <code>token</code> to string which is in accordance with best
+     * practices for JAVA parameter names.
+     *
+     * @param token
+     *            string which contains characters which should be converted to
+     *            JAVA parameter name
+     * @return string which is in accordance with best practices for JAVA
+     *         parameter name.
+     *
+     * @deprecated Use {@link BindingMapping#getPropertyName(String)} instead.
+     */
+    @Deprecated public static String parseToValidParamName(final String token) {
+        return resolveJavaReservedWordEquivalency(parseToCamelCase(token, false));
+    }
+
+    /**
+     *
+     * Converts string <code>token</code> to the cammel case format.
+     *
+     * @param token
+     *            string which should be converted to the cammel case format
+     * @param uppercase
+     *            boolean value which says whether the first character of the
+     *            <code>token</code> should|shuldn't be uppercased
+     * @return string in the cammel case format
+     * @throws IllegalArgumentException
+     *             <ul>
+     *             <li>if <code>token</code> without white spaces is empty</li>
+     *             <li>if <code>token</code> equals null</li>
+     *             </ul>
+     */
+    private static String parseToCamelCase(final String token, final boolean uppercase) {
+        if (token == null) {
+            throw new IllegalArgumentException("Name can not be null");
+        }
+
+        String correctStr = DOT_MATCHER.removeFrom(token.trim());
+        if (correctStr.isEmpty()) {
+            throw new IllegalArgumentException("Name can not be empty");
+        }
+
+        correctStr = replaceWithCamelCase(correctStr, ' ');
+        correctStr = replaceWithCamelCase(correctStr, '-');
+        correctStr = replaceWithCamelCase(correctStr, '_');
+
+        char firstChar = correctStr.charAt(0);
+        firstChar = uppercase ? Character.toUpperCase(firstChar) : Character.toLowerCase(firstChar);
+
+        if (firstChar >= '0' && firstChar <= '9') {
+            return '_' + correctStr;
+        } else {
+            return firstChar + correctStr.substring(1);
+        }
+    }
+
+    /**
+     * Replaces all the occurrences of the <code>removalChar</code> in the
+     * <code>text</code> with empty string and converts following character to
+     * upper case.
+     *
+     * @param text
+     *            string with source text which should be converted
+     * @param removalChar
+     *            character which is sought in the <code>text</code>
+     * @return string which doesn't contain <code>removalChar</code> and has
+     *         following characters converted to upper case
+     * @throws IllegalArgumentException
+     *             if the length of the returning string has length 0
+     */
+    private static String replaceWithCamelCase(final String text, final char removalChar) {
+        int toBeRemovedPos = text.indexOf(removalChar);
+        if (toBeRemovedPos == -1) {
+            return text;
+        }
+
+        StringBuilder sb = new StringBuilder(text);
+        String toBeRemoved = String.valueOf(removalChar);
+        do {
+            sb.replace(toBeRemovedPos, toBeRemovedPos + 1, "");
+            // check if 'toBeRemoved' character is not the only character in
+            // 'text'
+            if (sb.length() == 0) {
+                throw new IllegalArgumentException("The resulting string can not be empty");
+            }
+            char replacement = Character.toUpperCase(sb.charAt(toBeRemovedPos));
+            sb.setCharAt(toBeRemovedPos, replacement);
+            toBeRemovedPos = sb.indexOf(toBeRemoved);
+        } while (toBeRemovedPos != -1);
+
+        return sb.toString();
+    }
+
+    private static <T> Iterable<T> sortedCollection(final Comparator<? super T> comparator, final Collection<T> input) {
+        if (input.size() > 1) {
+            final List<T> ret = new ArrayList<>(input);
+            Collections.sort(ret, comparator);
+            return ret;
+        } else {
+            return input;
+        }
+    }
+
+    private static final ThreadLocal<MessageDigest> SHA1_MD = new ThreadLocal<MessageDigest>() {
+        @Override
+        protected MessageDigest initialValue() {
+            try {
+                return MessageDigest.getInstance("SHA");
+            } catch (NoSuchAlgorithmException e) {
+                throw new IllegalStateException("Failed to get a SHA digest provider", e);
+            }
+        }
+    };
+
+    public static long computeDefaultSUID(final GeneratedTypeBuilderBase<?> to) {
+        final ByteArrayOutputStream bout = new ByteArrayOutputStream();
+        try (final DataOutputStream dout = new DataOutputStream(bout)) {
+            dout.writeUTF(to.getName());
+            dout.writeInt(to.isAbstract() ? 3 : 7);
+
+            for (Type ifc : sortedCollection(SUID_NAME_COMPARATOR, to.getImplementsTypes())) {
+                dout.writeUTF(ifc.getFullyQualifiedName());
+            }
+
+            for (GeneratedPropertyBuilder gp : sortedCollection(SUID_MEMBER_COMPARATOR, to.getProperties())) {
+                dout.writeUTF(gp.getName());
+            }
+
+            for (MethodSignatureBuilder m : sortedCollection(SUID_MEMBER_COMPARATOR, to.getMethodDefinitions())) {
+                if (!(m.getAccessModifier().equals(AccessModifier.PRIVATE))) {
+                    dout.writeUTF(m.getName());
+                    dout.write(m.getAccessModifier().ordinal());
+                }
+            }
+
+            dout.flush();
+        } catch (IOException e) {
+            throw new IllegalStateException("Failed to hash object " + to, e);
+        }
+
+        final byte[] hashBytes = SHA1_MD.get().digest(bout.toByteArray());
+        long hash = 0;
+        for (int i = Math.min(hashBytes.length, 8) - 1; i >= 0; i--) {
+            hash = (hash << 8) | (hashBytes[i] & 0xFF);
+        }
+        return hash;
+    }
+
+    private static <T> List<T> currentOrEmpty(final List<T> current, final List<T> base) {
+        return current.equals(base) ? ImmutableList.<T>of() : current;
+    }
+
+    private static boolean containsConstraint(final StringTypeDefinition type, final PatternConstraint constraint) {
+        for (StringTypeDefinition wlk = type; wlk != null; wlk = wlk.getBaseType()) {
+            if (wlk.getPatternConstraints().contains(constraint)) {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
+    private static List<PatternConstraint> uniquePatterns(final StringTypeDefinition type) {
+        final List<PatternConstraint> constraints = type.getPatternConstraints();
+        if (constraints.isEmpty()) {
+            return constraints;
+        }
+
+        final Builder<PatternConstraint> builder = ImmutableList.builder();
+        boolean filtered = false;
+        for (PatternConstraint c : constraints) {
+            if (containsConstraint(type.getBaseType(), c)) {
+                filtered = true;
+            } else {
+                builder.add(c);
+            }
+        }
+
+        return filtered ? builder.build() : constraints;
+    }
+
+    public static Restrictions getRestrictions(final TypeDefinition<?> type) {
+        // Old parser generated types which actually contained based restrictions, but our code deals with that when
+        // binding to core Java types. Hence we'll emit empty restrictions for base types.
+        if (type == null || type.getBaseType() == null) {
+            // Handling of decimal64 has changed in the new parser. It contains range restrictions applied to the type
+            // directly, without an extended type. We need to capture such constraints. In order to retain behavior we
+            // need to analyze the new semantics and see if the constraints have been overridden. To do that we
+            // instantiate a temporary unconstrained type and compare them.
+            //
+            // FIXME: looking at the generated code it looks as though we need to pass the restrictions without
+            //        comparison
+            if (type instanceof DecimalTypeDefinition) {
+                final DecimalTypeDefinition decimal = (DecimalTypeDefinition) type;
+                final DecimalTypeBuilder tmpBuilder = BaseTypes.decimalTypeBuilder(decimal.getPath());
+                tmpBuilder.setFractionDigits(decimal.getFractionDigits());
+                final DecimalTypeDefinition tmp = tmpBuilder.build();
+
+                if (!tmp.getRangeConstraints().equals(decimal.getRangeConstraints())) {
+                    return new Restrictions() {
+                        @Override
+                        public boolean isEmpty() {
+                            return false;
+                        }
+
+                        @Override
+                        public List<RangeConstraint> getRangeConstraints() {
+                            return decimal.getRangeConstraints();
+                        }
+
+                        @Override
+                        public List<PatternConstraint> getPatternConstraints() {
+                            return ImmutableList.of();
+                        }
+
+                        @Override
+                        public List<LengthConstraint> getLengthConstraints() {
+                            return ImmutableList.of();
+                        }
+                    };
+                }
+            }
+
+            return EMPTY_RESTRICTIONS;
+        }
+
+        final List<LengthConstraint> length;
+        final List<PatternConstraint> pattern;
+        final List<RangeConstraint> range;
+
+        /*
+         * Take care of extended types.
+         *
+         * Other types which support constraints are check afterwards. There is a slight twist with them, as returned
+         * constraints are the effective view, e.g. they are inherited from base type. Since the constraint is already
+         * enforced by the base type, we want to skip them and not perform duplicate checks.
+         *
+         * We end up emitting ConcreteType instances for YANG base types, which leads to their constraints not being
+         * enforced (most notably decimal64). Therefore we need to make sure we do not strip the next-to-last
+         * restrictions.
+         *
+         * FIXME: this probably not the best solution and needs further analysis.
+         */
+        if (type instanceof BinaryTypeDefinition) {
+            final BinaryTypeDefinition binary = (BinaryTypeDefinition)type;
+            final BinaryTypeDefinition base = binary.getBaseType();
+            if (base != null && base.getBaseType() != null) {
+                length = currentOrEmpty(binary.getLengthConstraints(), base.getLengthConstraints());
+            } else {
+                length = binary.getLengthConstraints();
+            }
+
+            pattern = ImmutableList.of();
+            range = ImmutableList.of();
+        } else if (type instanceof DecimalTypeDefinition) {
+            length = ImmutableList.of();
+            pattern = ImmutableList.of();
+
+            final DecimalTypeDefinition decimal = (DecimalTypeDefinition)type;
+            final DecimalTypeDefinition base = decimal.getBaseType();
+            if (base != null && base.getBaseType() != null) {
+                range = currentOrEmpty(decimal.getRangeConstraints(), base.getRangeConstraints());
+            } else {
+                range = decimal.getRangeConstraints();
+            }
+        } else if (type instanceof IntegerTypeDefinition) {
+            length = ImmutableList.of();
+            pattern = ImmutableList.of();
+
+            final IntegerTypeDefinition integer = (IntegerTypeDefinition)type;
+            final IntegerTypeDefinition base = integer.getBaseType();
+            if (base != null && base.getBaseType() != null) {
+                range = currentOrEmpty(integer.getRangeConstraints(), base.getRangeConstraints());
+            } else {
+                range = integer.getRangeConstraints();
+            }
+        } else if (type instanceof StringTypeDefinition) {
+            final StringTypeDefinition string = (StringTypeDefinition)type;
+            final StringTypeDefinition base = string.getBaseType();
+            if (base != null && base.getBaseType() != null) {
+                length = currentOrEmpty(string.getLengthConstraints(), base.getLengthConstraints());
+            } else {
+                length = string.getLengthConstraints();
+            }
+
+            pattern = uniquePatterns(string);
+            range = ImmutableList.of();
+        } else if (type instanceof UnsignedIntegerTypeDefinition) {
+            length = ImmutableList.of();
+            pattern = ImmutableList.of();
+
+            final UnsignedIntegerTypeDefinition unsigned = (UnsignedIntegerTypeDefinition)type;
+            final UnsignedIntegerTypeDefinition base = unsigned.getBaseType();
+            if (base != null && base.getBaseType() != null) {
+                range = currentOrEmpty(unsigned.getRangeConstraints(), base.getRangeConstraints());
+            } else {
+                range = unsigned.getRangeConstraints();
+            }
+        } else {
+            length = ImmutableList.of();
+            pattern = ImmutableList.of();
+            range = ImmutableList.of();
+        }
+
+        // Now, this may have ended up being empty, too...
+        if (length.isEmpty() && pattern.isEmpty() && range.isEmpty()) {
+            return EMPTY_RESTRICTIONS;
+        }
+
+        // Nope, not empty allocate a holder
+        return new Restrictions() {
+            @Override
+            public List<RangeConstraint> getRangeConstraints() {
+                return range;
+            }
+            @Override
+            public List<PatternConstraint> getPatternConstraints() {
+                return pattern;
+            }
+            @Override
+            public List<LengthConstraint> getLengthConstraints() {
+                return length;
+            }
+            @Override
+            public boolean isEmpty() {
+                return false;
+            }
+        };
+    }
+
+    /**
+     * Encodes angle brackets in yang statement description
+     * @param description description of a yang statement which is used to generate javadoc comments
+     * @return string with encoded angle brackets
+     */
+    public static String encodeAngleBrackets(String description) {
+        if (description != null) {
+            description = LT_MATCHER.replaceFrom(description, "&lt;");
+            description = GT_MATCHER.replaceFrom(description, "&gt;");
+        }
+        return description;
+    }
+}
diff --git a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/BindingTypes.java b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/BindingTypes.java
new file mode 100644 (file)
index 0000000..4769234
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.mdsal.binding.generator.util;
+
+import static org.opendaylight.mdsal.binding.generator.util.Types.parameterizedTypeFor;
+import static org.opendaylight.mdsal.binding.generator.util.Types.typeForClass;
+
+import org.opendaylight.mdsal.binding.model.api.ConcreteType;
+import org.opendaylight.mdsal.binding.model.api.ParameterizedType;
+import org.opendaylight.mdsal.binding.model.api.Type;
+import org.opendaylight.yangtools.yang.binding.Augmentable;
+import org.opendaylight.yangtools.yang.binding.Augmentation;
+import org.opendaylight.yangtools.yang.binding.BaseIdentity;
+import org.opendaylight.yangtools.yang.binding.ChildOf;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.DataRoot;
+import org.opendaylight.yangtools.yang.binding.Identifiable;
+import org.opendaylight.yangtools.yang.binding.Identifier;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.Notification;
+import org.opendaylight.yangtools.yang.binding.NotificationListener;
+import org.opendaylight.yangtools.yang.binding.RpcService;
+
+public final class BindingTypes {
+
+    public static final ConcreteType AUGMENTABLE = typeForClass(Augmentable.class);
+    public static final ConcreteType AUGMENTATION = typeForClass(Augmentation.class);
+    public static final ConcreteType BASE_IDENTITY = typeForClass(BaseIdentity.class);
+    public static final ConcreteType DATA_OBJECT = typeForClass(DataObject.class);
+    public static final ConcreteType DATA_ROOT = typeForClass(DataRoot.class);
+    public static final ConcreteType IDENTIFIABLE = typeForClass(Identifiable.class);
+    public static final ConcreteType IDENTIFIER = typeForClass(Identifier.class);
+    public static final ConcreteType INSTANCE_IDENTIFIER = typeForClass(InstanceIdentifier.class);
+    public static final ConcreteType NOTIFICATION = typeForClass(Notification.class);
+    public static final ConcreteType NOTIFICATION_LISTENER = typeForClass(NotificationListener.class);
+    public static final ConcreteType RPC_SERVICE = typeForClass(RpcService.class);
+
+    private static final ConcreteType CHILD_OF = typeForClass(ChildOf.class);
+
+    private BindingTypes() {
+
+    }
+
+    public static ParameterizedType augmentable(Type t) {
+        return parameterizedTypeFor(AUGMENTABLE, t);
+    }
+
+    public static ParameterizedType childOf(Type t) {
+        return parameterizedTypeFor(CHILD_OF, t);
+    }
+
+}
diff --git a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/ReferencedTypeImpl.java b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/ReferencedTypeImpl.java
new file mode 100644 (file)
index 0000000..5c3585b
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * 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.mdsal.binding.generator.util;
+
+/**
+ *
+ * Wraps combination of <code>packageName</code> and <code>name</code> to the
+ * object representation
+ *
+ */
+public final class ReferencedTypeImpl extends AbstractBaseType {
+
+    /**
+     * Creates instance of this class with concrete package name and type name
+     *
+     * @param packageName
+     *            string with the package name
+     * @param name
+     *            string with the name for referenced type
+     */
+    public ReferencedTypeImpl(String packageName, String name) {
+        super(packageName, name);
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder builder = new StringBuilder();
+        builder.append("ReferencedTypeImpl [packageName=");
+        builder.append(getPackageName());
+        builder.append(", name=");
+        builder.append(getName());
+        builder.append("]");
+        return builder.toString();
+    }
+}
diff --git a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/TypeConstants.java b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/TypeConstants.java
new file mode 100644 (file)
index 0000000..c1d1e2d
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2014 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.mdsal.binding.generator.util;
+
+/**
+ *
+ * Contains constants used in relations with <code>Type</code>.
+ */
+public final class TypeConstants {
+
+    /**
+     * Name of the class constant which hold list of the regular expression
+     * strings.
+     */
+    public static final String PATTERN_CONSTANT_NAME = "PATTERN_CONSTANTS";
+
+    /**
+     * Creation of new instance is prohibited.
+     */
+    private TypeConstants() {
+    }
+}
diff --git a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/Types.java b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/Types.java
new file mode 100644 (file)
index 0000000..3e08b42
--- /dev/null
@@ -0,0 +1,390 @@
+/*
+ * 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.mdsal.binding.generator.util;
+
+import com.google.common.base.CharMatcher;
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
+import com.google.common.base.Splitter;
+import com.google.common.cache.CacheBuilder;
+import com.google.common.cache.CacheLoader;
+import com.google.common.cache.LoadingCache;
+import com.google.common.collect.Iterables;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.Future;
+import javax.annotation.Nullable;
+import org.opendaylight.mdsal.binding.model.api.BaseTypeWithRestrictions;
+import org.opendaylight.mdsal.binding.model.api.ConcreteType;
+import org.opendaylight.mdsal.binding.model.api.ParameterizedType;
+import org.opendaylight.mdsal.binding.model.api.Restrictions;
+import org.opendaylight.mdsal.binding.model.api.Type;
+import org.opendaylight.mdsal.binding.model.api.WildcardType;
+import org.opendaylight.yangtools.yang.binding.Augmentable;
+import org.opendaylight.yangtools.yang.binding.Augmentation;
+import org.opendaylight.yangtools.yang.model.api.type.LengthConstraint;
+import org.opendaylight.yangtools.yang.model.api.type.PatternConstraint;
+import org.opendaylight.yangtools.yang.model.api.type.RangeConstraint;
+import org.opendaylight.yangtools.yang.model.util.BaseConstraints;
+
+public final class Types {
+    private static final CacheLoader<Class<?>, ConcreteType> TYPE_LOADER =
+            new CacheLoader<Class<?>, ConcreteType>() {
+                @Override
+                public ConcreteType load(final Class<?> key) {
+                    return new ConcreteTypeImpl(key.getPackage().getName(), key.getSimpleName(), null);
+                }
+    };
+    private static final LoadingCache<Class<?>, ConcreteType> TYPE_CACHE =
+            CacheBuilder.newBuilder().weakKeys().build(TYPE_LOADER);
+
+    private static final Type SET_TYPE = typeForClass(Set.class);
+    private static final Type LIST_TYPE = typeForClass(List.class);
+    private static final Type MAP_TYPE = typeForClass(Map.class);
+
+    public static final ConcreteType BOOLEAN = typeForClass(Boolean.class);
+    public static final ConcreteType FUTURE = typeForClass(Future.class);
+    public static final ConcreteType STRING = typeForClass(String.class);
+    public static final ConcreteType VOID = typeForClass(Void.class);
+    public static final ConcreteType BYTE_ARRAY = primitiveType("byte[]", null);
+    public static final ConcreteType CHAR_ARRAY = primitiveType("char[]", null);
+    private static final Splitter DOT_SPLITTER = Splitter.on('.');
+
+    /**
+     * It is not desirable to create instance of this class
+     */
+    private Types() {
+    }
+
+    /**
+     * Creates the instance of type
+     * {@link org.opendaylight.yangtools.sal.binding.model.api.ConcreteType
+     * ConcreteType} which represents JAVA <code>void</code> type.
+     *
+     * @return <code>ConcreteType</code> instance which represents JAVA
+     *         <code>void</code>
+     */
+    public static ConcreteType voidType() {
+        return VOID;
+    }
+
+    /**
+     * Creates the instance of type
+     * {@link org.opendaylight.yangtools.sal.binding.model.api.ConcreteType
+     * ConcreteType} which represents primitive JAVA type for which package
+     * doesn't exist.
+     *
+     * @param primitiveType
+     *            string containing programmatic construction based on
+     *            primitive type (e.g byte[])
+     * @param restrictions
+     *            restrictions object
+     * @return <code>ConcreteType</code> instance which represents programmatic
+     *         construction with primitive JAVA type
+     */
+    public static ConcreteType primitiveType(final String primitiveType, final Restrictions restrictions) {
+        return new ConcreteTypeImpl("", primitiveType, restrictions);
+    }
+
+    /**
+     * Returns an instance of {@link ConcreteType} describing the class
+     *
+     * @param cls
+     *            Class to describe
+     * @return Description of class
+     */
+    public static ConcreteType typeForClass(final Class<?> cls) {
+        return TYPE_CACHE.getUnchecked(cls);
+    }
+
+    public static ConcreteType typeForClass(final Class<?> cls, final Restrictions restrictions) {
+        if (restrictions != null) {
+            if (restrictions instanceof DefaultRestrictions) {
+                return new ConcreteTypeImpl(cls.getPackage().getName(), cls.getSimpleName(), restrictions);
+            } else {
+                return new BaseTypeWithRestrictionsImpl(cls.getPackage().getName(), cls.getSimpleName(), restrictions);
+            }
+        } else {
+            return typeForClass(cls);
+        }
+    }
+
+    /**
+     * Returns an instance of {@link ParameterizedType} describing the typed
+     * {@link Map}&lt;K,V&gt;
+     *
+     * @param keyType
+     *            Key Type
+     * @param valueType
+     *            Value Type
+     * @return Description of generic type instance
+     */
+    public static ParameterizedType mapTypeFor(final Type keyType, final Type valueType) {
+        return parameterizedTypeFor(MAP_TYPE, keyType, valueType);
+    }
+
+    /**
+     * Returns an instance of {@link ParameterizedType} describing the typed
+     * {@link Set}&lt;V&gt; with concrete type of value.
+     *
+     * @param valueType
+     *            Value Type
+     * @return Description of generic type instance of Set
+     */
+    public static ParameterizedType setTypeFor(final Type valueType) {
+        return parameterizedTypeFor(SET_TYPE, valueType);
+    }
+
+    /**
+     * Returns an instance of {@link ParameterizedType} describing the typed
+     * {@link List}&lt;V&gt; with concrete type of value.
+     *
+     * @param valueType
+     *            Value Type
+     * @return Description of type instance of List
+     */
+    public static ParameterizedType listTypeFor(final Type valueType) {
+        return parameterizedTypeFor(LIST_TYPE, valueType);
+    }
+
+    /**
+     * Creates instance of type
+     * {@link org.opendaylight.yangtools.sal.binding.model.api.ParameterizedType
+     * ParameterizedType}
+     *
+     * @param type
+     *            JAVA <code>Type</code> for raw type
+     * @param parameters
+     *            JAVA <code>Type</code>s for actual parameter types
+     * @return <code>ParametrizedType</code> reprezentation of <code>type</code>
+     *         and its parameters <code>parameters</code>
+     */
+    public static ParameterizedType parameterizedTypeFor(final Type type, final Type... parameters) {
+        return new ParametrizedTypeImpl(type, parameters);
+    }
+
+    /**
+     * Creates instance of type
+     * {@link org.opendaylight.yangtools.sal.binding.model.api.WildcardType
+     * WildcardType}
+     *
+     * @param packageName
+     *            string with the package name
+     * @param typeName
+     *            string with the type name
+     * @return <code>WildcardType</code> representation of
+     *         <code>packageName</code> and <code>typeName</code>
+     */
+    public static WildcardType wildcardTypeFor(final String packageName, final String typeName) {
+        return new WildcardTypeImpl(packageName, typeName);
+    }
+
+    /**
+     * Creates instance of
+     * {@link org.opendaylight.yangtools.sal.binding.model.api.ParameterizedType
+     * ParameterizedType} where raw type is
+     * {@link org.opendaylight.yangtools.yang.binding.Augmentable} and actual
+     * parameter is <code>valueType</code>.
+     *
+     * @param valueType
+     *            JAVA <code>Type</code> with actual parameter
+     * @return <code>ParametrizedType</code> representation of raw type
+     *         <code>Augmentable</code> with actual parameter
+     *         <code>valueType</code>
+     */
+    public static ParameterizedType augmentableTypeFor(final Type valueType) {
+        final Type augmentable = typeForClass(Augmentable.class);
+        return parameterizedTypeFor(augmentable, valueType);
+    }
+
+    /**
+     * Creates instance of
+     * {@link org.opendaylight.yangtools.sal.binding.model.api.ParameterizedType
+     * ParameterizedType} where raw type is
+     * {@link org.opendaylight.yangtools.yang.binding.Augmentation} and actual
+     * parameter is <code>valueType</code>.
+     *
+     * @param valueType
+     *            JAVA <code>Type</code> with actual parameter
+     * @return <code>ParametrizedType</code> reprezentation of raw type
+     *         <code>Augmentation</code> with actual parameter
+     *         <code>valueType</code>
+     */
+    public static ParameterizedType augmentationTypeFor(final Type valueType) {
+        final Type augmentation = typeForClass(Augmentation.class);
+        return parameterizedTypeFor(augmentation, valueType);
+    }
+
+
+    public static  @Nullable String getOuterClassName(final Type valueType) {
+        final String pkgName = valueType.getPackageName();
+        if(CharMatcher.JAVA_UPPER_CASE.indexIn(pkgName) >= 0) {
+            // It is inner class.
+            return Iterables.getLast(DOT_SPLITTER.split(pkgName));
+        }
+        return null;
+    }
+
+    /**
+     *
+     * Represents concrete JAVA type.
+     *
+     */
+    private static final class ConcreteTypeImpl extends AbstractBaseType implements ConcreteType {
+        private final Restrictions restrictions;
+
+        /**
+         * Creates instance of this class with package <code>pkName</code> and
+         * with the type name <code>name</code>.
+         *
+         * @param pkName
+         *            string with package name
+         * @param name
+         *            string with the name of the type
+         */
+        private ConcreteTypeImpl(final String pkName, final String name, final Restrictions restrictions) {
+            super(pkName, name);
+            this.restrictions = restrictions;
+        }
+
+        @Override
+        public Restrictions getRestrictions() {
+            return restrictions;
+        }
+    }
+
+    /**
+     *
+     * Represents concrete JAVA type with changed restriction values.
+     *
+     */
+    private static final class BaseTypeWithRestrictionsImpl extends AbstractBaseType implements BaseTypeWithRestrictions {
+        private final Restrictions restrictions;
+
+        /**
+         * Creates instance of this class with package <code>pkName</code> and
+         * with the type name <code>name</code>.
+         *
+         * @param pkName
+         *            string with package name
+         * @param name
+         *            string with the name of the type
+         */
+        private BaseTypeWithRestrictionsImpl(final String pkName, final String name, final Restrictions restrictions) {
+            super(pkName, name);
+            this.restrictions = Preconditions.checkNotNull(restrictions);
+        }
+
+        @Override
+        public Restrictions getRestrictions() {
+            return restrictions;
+        }
+    }
+
+    /**
+     *
+     * Represents parametrized JAVA type.
+     *
+     */
+    private static class ParametrizedTypeImpl extends AbstractBaseType implements ParameterizedType {
+        /**
+         * Array of JAVA actual type parameters.
+         */
+        private final Type[] actualTypes;
+
+        /**
+         * JAVA raw type (like List, Set, Map...)
+         */
+        private final Type rawType;
+
+        @Override
+        public Type[] getActualTypeArguments() {
+
+            return actualTypes;
+        }
+
+        @Override
+        public Type getRawType() {
+            return rawType;
+        }
+
+        /**
+         * Creates instance of this class with concrete rawType and array of
+         * actual parameters.
+         *
+         * @param rawType
+         *            JAVA <code>Type</code> for raw type
+         * @param actTypes
+         *            array of actual parameters
+         */
+        public ParametrizedTypeImpl(final Type rawType, final Type[] actTypes) {
+            super(rawType.getPackageName(), rawType.getName());
+            this.rawType = rawType;
+            this.actualTypes = actTypes.clone();
+        }
+
+    }
+
+    /**
+     *
+     * Represents JAVA bounded wildcard type.
+     *
+     */
+    private static class WildcardTypeImpl extends AbstractBaseType implements WildcardType {
+        /**
+         * Creates instance of this class with concrete package and type name.
+         *
+         * @param packageName
+         *            string with the package name
+         * @param typeName
+         *            string with the name of type
+         */
+        public WildcardTypeImpl(final String packageName, final String typeName) {
+            super(packageName, typeName);
+        }
+    }
+
+    public static <T extends Number> DefaultRestrictions<T> getDefaultRestrictions(final T min, final T max) {
+        return new DefaultRestrictions<>(min, max);
+    }
+
+    private static final class DefaultRestrictions<T extends Number> implements Restrictions {
+        private final T min;
+        private final T max;
+        private final List<RangeConstraint> rangeConstraints;
+
+        private DefaultRestrictions(final T min, final T max) {
+            this.min = Preconditions.checkNotNull(min);
+            this.max = Preconditions.checkNotNull(max);
+            this.rangeConstraints = Collections.singletonList(BaseConstraints.newRangeConstraint(min, max, Optional
+                    .<String>absent(), Optional.<String>absent()));
+        }
+
+        @Override
+        public boolean isEmpty() {
+            return false;
+        }
+
+        @Override
+        public List<RangeConstraint> getRangeConstraints() {
+            return rangeConstraints;
+        }
+
+        @Override
+        public List<PatternConstraint> getPatternConstraints() {
+            return Collections.emptyList();
+        }
+
+        @Override
+        public List<LengthConstraint> getLengthConstraints() {
+            return Collections.emptyList();
+        }
+    }
+}
\ No newline at end of file
diff --git a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/AbstractGeneratedType.java b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/AbstractGeneratedType.java
new file mode 100644 (file)
index 0000000..b2df0a3
--- /dev/null
@@ -0,0 +1,215 @@
+/*
+ * 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.mdsal.binding.generator.util.generated.type.builder;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.opendaylight.mdsal.binding.generator.util.AbstractBaseType;
+import org.opendaylight.mdsal.binding.model.api.AnnotationType;
+import org.opendaylight.mdsal.binding.model.api.Constant;
+import org.opendaylight.mdsal.binding.model.api.Enumeration;
+import org.opendaylight.mdsal.binding.model.api.GeneratedProperty;
+import org.opendaylight.mdsal.binding.model.api.GeneratedType;
+import org.opendaylight.mdsal.binding.model.api.MethodSignature;
+import org.opendaylight.mdsal.binding.model.api.Type;
+import org.opendaylight.mdsal.binding.model.api.type.builder.AnnotationTypeBuilder;
+import org.opendaylight.mdsal.binding.model.api.type.builder.EnumBuilder;
+import org.opendaylight.mdsal.binding.model.api.type.builder.GeneratedPropertyBuilder;
+import org.opendaylight.mdsal.binding.model.api.type.builder.GeneratedTOBuilder;
+import org.opendaylight.mdsal.binding.model.api.type.builder.GeneratedTypeBuilder;
+import org.opendaylight.mdsal.binding.model.api.type.builder.MethodSignatureBuilder;
+
+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 List<GeneratedProperty> properties;
+    private final boolean isAbstract;
+
+    public AbstractGeneratedType(final AbstractGeneratedTypeBuilder<?> builder) {
+        super(builder.getPackageName(), builder.getName());
+        this.parent = builder.getParent();
+        this.comment = builder.getComment();
+        this.annotations = toUnmodifiableAnnotations(builder.getAnnotations());
+        this.implementsTypes = makeUnmodifiable(builder.getImplementsTypes());
+        this.constants = makeUnmodifiable(builder.getConstants());
+        this.enumerations = toUnmodifiableEnumerations(builder.getEnumerations());
+        this.methodSignatures = toUnmodifiableMethods(builder.getMethodDefinitions());
+        this.enclosedTypes = toUnmodifiableEnclosedTypes(builder.getEnclosedTypes(),
+                builder.getEnclosedTransferObjects());
+        this.properties = toUnmodifiableProperties(builder.getProperties());
+        this.isAbstract = builder.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,
+            final List<GeneratedPropertyBuilder> propertyBuilders) {
+        super(packageName, name);
+        this.parent = parent;
+        this.comment = comment;
+        this.annotations = toUnmodifiableAnnotations(annotationBuilders);
+        this.implementsTypes = makeUnmodifiable(implementsTypes);
+        this.constants = makeUnmodifiable(constants);
+        this.enumerations = toUnmodifiableEnumerations(enumBuilders);
+        this.methodSignatures = toUnmodifiableMethods(methodBuilders);
+        this.enclosedTypes = toUnmodifiableEnclosedTypes(enclosedGenTypeBuilders, enclosedGenTOBuilders);
+        this.properties = toUnmodifiableProperties(propertyBuilders);
+        this.isAbstract = isAbstract;
+    }
+
+    protected static final <T> List<T> makeUnmodifiable(final List<T> list) {
+        switch (list.size()) {
+        case 0:
+            return Collections.emptyList();
+        case 1:
+            return Collections.singletonList(list.get(0));
+        default:
+            return Collections.unmodifiableList(list);
+        }
+    }
+
+    private static List<GeneratedType> toUnmodifiableEnclosedTypes(final List<GeneratedTypeBuilder> enclosedGenTypeBuilders,
+            final List<GeneratedTOBuilder> enclosedGenTOBuilders) {
+        final ArrayList<GeneratedType> enclosedTypesList = new ArrayList<>(enclosedGenTypeBuilders.size() + enclosedGenTOBuilders.size());
+        for (final GeneratedTypeBuilder builder : enclosedGenTypeBuilders) {
+            if (builder != null) {
+                enclosedTypesList.add(builder.toInstance());
+            }
+        }
+
+        for (final GeneratedTOBuilder builder : enclosedGenTOBuilders) {
+            if (builder != null) {
+                enclosedTypesList.add(builder.toInstance());
+            }
+        }
+
+        return makeUnmodifiable(enclosedTypesList);
+    }
+
+    protected static final List<AnnotationType> toUnmodifiableAnnotations(final List<AnnotationTypeBuilder> annotationBuilders) {
+        final List<AnnotationType> annotationList = new ArrayList<>(annotationBuilders.size());
+        for (final AnnotationTypeBuilder builder : annotationBuilders) {
+            annotationList.add(builder.toInstance());
+        }
+        return makeUnmodifiable(annotationList);
+    }
+
+    protected final List<MethodSignature> toUnmodifiableMethods(final List<MethodSignatureBuilder> methodBuilders) {
+        final List<MethodSignature> methods = new ArrayList<>(methodBuilders.size());
+        for (final MethodSignatureBuilder methodBuilder : methodBuilders) {
+            methods.add(methodBuilder.toInstance(this));
+        }
+        return makeUnmodifiable(methods);
+    }
+
+    protected final List<Enumeration> toUnmodifiableEnumerations(final List<EnumBuilder> enumBuilders) {
+        final List<Enumeration> enums = new ArrayList<>(enumBuilders.size());
+        for (final EnumBuilder enumBuilder : enumBuilders) {
+            enums.add(enumBuilder.toInstance(this));
+        }
+        return makeUnmodifiable(enums);
+    }
+
+    protected final List<GeneratedProperty> toUnmodifiableProperties(final List<GeneratedPropertyBuilder> methodBuilders) {
+        final List<GeneratedProperty> methods = new ArrayList<>(methodBuilders.size());
+        for (final GeneratedPropertyBuilder methodBuilder : methodBuilders) {
+            methods.add(methodBuilder.toInstance(this));
+        }
+        return makeUnmodifiable(methods);
+    }
+
+    @Override
+    public final Type getParentType() {
+        return parent;
+    }
+
+    @Override
+    public final String getComment() {
+        return comment;
+    }
+
+    @Override
+    public final List<AnnotationType> getAnnotations() {
+        return annotations;
+    }
+
+    @Override
+    public final boolean isAbstract() {
+        return isAbstract;
+    }
+
+    @Override
+    public final List<Type> getImplements() {
+        return implementsTypes;
+    }
+
+    @Override
+    public final List<GeneratedType> getEnclosedTypes() {
+        return enclosedTypes;
+    }
+
+    @Override
+    public final List<Enumeration> getEnumerations() {
+        return enumerations;
+    }
+
+    @Override
+    public final List<Constant> getConstantDefinitions() {
+        return constants;
+    }
+
+    @Override
+    public final List<MethodSignature> getMethodDefinitions() {
+        return methodSignatures;
+    }
+
+    @Override
+    public final List<GeneratedProperty> getProperties() {
+        return properties;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder builder = new StringBuilder();
+        builder.append("GeneratedType [packageName=");
+        builder.append(getPackageName());
+        builder.append(", name=");
+        builder.append(getName());
+        if (parent != null) {
+            builder.append(", parent=");
+            builder.append(parent.getFullyQualifiedName());
+        } else {
+            builder.append(", parent=null");
+        }
+        builder.append(", comment=");
+        builder.append(comment);
+        builder.append(", annotations=");
+        builder.append(annotations);
+        builder.append(", enclosedTypes=");
+        builder.append(enclosedTypes);
+        builder.append(", enumerations=");
+        builder.append(enumerations);
+        builder.append(", constants=");
+        builder.append(constants);
+        builder.append(", methodSignatures=");
+        builder.append(methodSignatures);
+        builder.append("]");
+        return builder.toString();
+    }
+}
diff --git a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/AbstractGeneratedTypeBuilder.java b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/AbstractGeneratedTypeBuilder.java
new file mode 100644 (file)
index 0000000..223faeb
--- /dev/null
@@ -0,0 +1,241 @@
+/*
+ * 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.mdsal.binding.generator.util.generated.type.builder;
+
+import com.google.common.base.Preconditions;
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+import org.opendaylight.mdsal.binding.generator.util.AbstractBaseType;
+import org.opendaylight.mdsal.binding.model.api.AccessModifier;
+import org.opendaylight.mdsal.binding.model.api.Constant;
+import org.opendaylight.mdsal.binding.model.api.Type;
+import org.opendaylight.mdsal.binding.model.api.type.builder.AnnotationTypeBuilder;
+import org.opendaylight.mdsal.binding.model.api.type.builder.EnumBuilder;
+import org.opendaylight.mdsal.binding.model.api.type.builder.GeneratedPropertyBuilder;
+import org.opendaylight.mdsal.binding.model.api.type.builder.GeneratedTOBuilder;
+import org.opendaylight.mdsal.binding.model.api.type.builder.GeneratedTypeBuilder;
+import org.opendaylight.mdsal.binding.model.api.type.builder.GeneratedTypeBuilderBase;
+import org.opendaylight.mdsal.binding.model.api.type.builder.MethodSignatureBuilder;
+import org.opendaylight.yangtools.util.LazyCollections;
+
+abstract class AbstractGeneratedTypeBuilder<T extends GeneratedTypeBuilderBase<T>> extends AbstractBaseType implements GeneratedTypeBuilderBase<T> {
+
+    private List<AnnotationTypeBuilder> annotationBuilders = Collections.emptyList();
+    private List<Type> implementsTypes = Collections.emptyList();
+    private List<EnumBuilder> enumDefinitions = Collections.emptyList();
+    private List<Constant> constants = Collections.emptyList();
+    private List<MethodSignatureBuilder> methodDefinitions = Collections.emptyList();
+    private final List<GeneratedTypeBuilder> enclosedTypes = Collections.emptyList();
+    private List<GeneratedTOBuilder> enclosedTransferObjects = Collections.emptyList();
+    private List<GeneratedPropertyBuilder> properties = Collections.emptyList();
+    private String comment = "";
+    private boolean isAbstract;
+
+    protected AbstractGeneratedTypeBuilder(final String packageName, final String name) {
+        super(packageName, name);
+    }
+
+    protected String getComment() {
+        return comment;
+    }
+
+    protected List<AnnotationTypeBuilder> getAnnotations() {
+        return annotationBuilders;
+    }
+
+    @Override
+    public boolean isAbstract() {
+        return isAbstract;
+    }
+
+    @Override
+    public List<Type> getImplementsTypes() {
+        return implementsTypes;
+    }
+
+    protected List<EnumBuilder> getEnumerations() {
+        return enumDefinitions;
+    }
+
+    protected List<Constant> getConstants() {
+        return constants;
+    }
+
+    @Override
+    public List<MethodSignatureBuilder> getMethodDefinitions() {
+        return methodDefinitions;
+    }
+
+    protected List<GeneratedTypeBuilder> getEnclosedTypes() {
+        return enclosedTypes;
+    }
+
+    protected List<GeneratedTOBuilder> getEnclosedTransferObjects() {
+        return enclosedTransferObjects;
+    }
+
+    protected abstract T thisInstance();
+
+    @Override
+    public GeneratedTOBuilder addEnclosingTransferObject(final String name) {
+        Preconditions.checkArgument(name != null, "Name for Enclosing Generated Transfer Object cannot be null!");
+        GeneratedTOBuilder builder = new GeneratedTOBuilderImpl(getFullyQualifiedName(), name);
+
+        Preconditions.checkArgument(!enclosedTransferObjects.contains(builder), "This generated type already contains equal enclosing transfer object.");
+        enclosedTransferObjects = LazyCollections.lazyAdd(enclosedTransferObjects, builder);
+        return builder;
+    }
+
+    @Override
+    public T addEnclosingTransferObject(final GeneratedTOBuilder genTOBuilder) {
+        Preconditions.checkArgument(genTOBuilder != null, "Parameter genTOBuilder cannot be null!");
+        Preconditions.checkArgument(!enclosedTransferObjects.contains(genTOBuilder), "This generated type already contains equal enclosing transfer object.");
+        enclosedTransferObjects = LazyCollections.lazyAdd(enclosedTransferObjects, genTOBuilder);
+        return thisInstance();
+    }
+
+    @Override
+    public T addComment(final String comment) {
+        this.comment = comment;
+        return thisInstance();
+    }
+
+    @Override
+    public AnnotationTypeBuilder addAnnotation(final String packageName, final String name) {
+        Preconditions.checkArgument(packageName != null, "Package Name for Annotation Type cannot be null!");
+        Preconditions.checkArgument(name != null, "Name of Annotation Type cannot be null!");
+
+        final AnnotationTypeBuilder builder = new AnnotationTypeBuilderImpl(packageName, name);
+
+        Preconditions.checkArgument(!annotationBuilders.contains(builder), "This generated type already contains equal annotation.");
+        annotationBuilders = LazyCollections.lazyAdd(annotationBuilders, builder);
+        return builder;
+    }
+
+    @Override
+    public T setAbstract(final boolean isAbstract) {
+        this.isAbstract = isAbstract;
+        return thisInstance();
+    }
+
+    @Override
+    public T addImplementsType(final Type genType) {
+        Preconditions.checkArgument(genType != null, "Type cannot be null");
+        Preconditions.checkArgument(!implementsTypes.contains(genType), "This generated type already contains equal implements type.");
+        implementsTypes = LazyCollections.lazyAdd(implementsTypes, genType);
+        return thisInstance();
+    }
+
+    @Override
+    public Constant addConstant(final Type type, final String name, final Object value) {
+        Preconditions.checkArgument(type != null, "Returning Type for Constant cannot be null!");
+        Preconditions.checkArgument(name != null, "Name of constant cannot be null!");
+        Preconditions.checkArgument(!containsConstant(name), "This generated type already contains constant with the same name.");
+
+        final Constant constant = new ConstantImpl(this, type, name, value);
+        constants = LazyCollections.lazyAdd(constants, constant);
+        return constant;
+    }
+
+    public boolean containsConstant(final String name) {
+        Preconditions.checkArgument(name != null, "Parameter name can't be null");
+        for (Constant constant : constants) {
+            if (name.equals(constant.getName())) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    @Override
+    public EnumBuilder addEnumeration(final String name) {
+        Preconditions.checkArgument(name != null, "Name of enumeration cannot be null!");
+        final EnumBuilder builder = new EnumerationBuilderImpl(getFullyQualifiedName(), name);
+
+        Preconditions.checkArgument(!enumDefinitions.contains(builder), "This generated type already contains equal enumeration.");
+        enumDefinitions = LazyCollections.lazyAdd(enumDefinitions, builder);
+        return builder;
+    }
+
+    @Override
+    public MethodSignatureBuilder addMethod(final String name) {
+        Preconditions.checkArgument(name != null, "Name of method cannot be null!");
+        final MethodSignatureBuilder builder = new MethodSignatureBuilderImpl(name);
+        builder.setAccessModifier(AccessModifier.PUBLIC);
+        builder.setAbstract(true);
+        methodDefinitions = LazyCollections.lazyAdd(methodDefinitions, builder);
+        return builder;
+    }
+
+    @Override
+    public boolean containsMethod(final String name) {
+        Preconditions.checkArgument(name != null, "Parameter name can't be null");
+        for (MethodSignatureBuilder methodDefinition : methodDefinitions) {
+            if (name.equals(methodDefinition.getName())) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    @Override
+    public GeneratedPropertyBuilder addProperty(final String name) {
+        Preconditions.checkArgument(name != null, "Parameter name can't be null");
+        Preconditions.checkArgument(!containsProperty(name), "This generated type already contains property with the same name.");
+
+        final GeneratedPropertyBuilder builder = new GeneratedPropertyBuilderImpl(name);
+        builder.setAccessModifier(AccessModifier.PUBLIC);
+        properties = LazyCollections.lazyAdd(properties, builder);
+        return builder;
+    }
+
+    @Override
+    public boolean containsProperty(final String name) {
+        Preconditions.checkArgument(name != null, "Parameter name can't be null");
+        for (GeneratedPropertyBuilder property : properties) {
+            if (name.equals(property.getName())) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + Objects.hashCode(getName());
+        result = prime * result + Objects.hashCode(getPackageName());
+        return result;
+    }
+
+    @Override
+    public boolean equals(final Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null) {
+            return false;
+        }
+        if (getClass() != obj.getClass()) {
+            return false;
+        }
+        AbstractGeneratedTypeBuilder<?> other = (AbstractGeneratedTypeBuilder<?>) obj;
+        return Objects.equals(getName(), other.getName()) && Objects.equals(getPackageName(), other.getPackageName());
+    }
+
+    public Type getParent() {
+        return null;
+    }
+
+    @Override
+    public List<GeneratedPropertyBuilder> getProperties() {
+        return properties;
+    }
+}
diff --git a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/AbstractTypeMember.java b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/AbstractTypeMember.java
new file mode 100644 (file)
index 0000000..88347e6
--- /dev/null
@@ -0,0 +1,128 @@
+/*
+ * 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.mdsal.binding.generator.util.generated.type.builder;
+
+import java.util.List;
+import java.util.Objects;
+import org.opendaylight.mdsal.binding.model.api.AccessModifier;
+import org.opendaylight.mdsal.binding.model.api.AnnotationType;
+import org.opendaylight.mdsal.binding.model.api.Type;
+import org.opendaylight.mdsal.binding.model.api.TypeMember;
+
+abstract class AbstractTypeMember implements TypeMember {
+
+    private final String name;
+    private final String comment;
+    private final Type definingType;
+    private final Type returnType;
+    private final List<AnnotationType> annotations;
+    private final boolean isFinal;
+    private final boolean isStatic;
+    private final AccessModifier accessModifier;
+
+    protected AbstractTypeMember(final Type definingType, final String name,  final List<AnnotationType> annotations,
+            final String comment, final AccessModifier accessModifier, final Type returnType,
+            final boolean isFinal, final boolean isStatic) {
+        super();
+        this.definingType = definingType;
+        this.name = name;
+        this.annotations = annotations;
+        this.comment = comment;
+        this.accessModifier = accessModifier;
+        this.returnType = returnType;
+        this.isFinal = isFinal;
+        this.isStatic = isStatic;
+    }
+
+    @Override
+    public List<AnnotationType> getAnnotations() {
+        return annotations;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public String getComment() {
+        return comment;
+    }
+
+    @Override
+    public Type getDefiningType() {
+        return definingType;
+    }
+
+    @Override
+    public AccessModifier getAccessModifier() {
+        return accessModifier;
+    }
+
+    @Override
+    public Type getReturnType() {
+        return returnType;
+    }
+
+    @Override
+    public boolean isFinal() {
+        return isFinal;
+    }
+
+    @Override
+    public boolean isStatic() {
+        return isStatic;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + Objects.hashCode(getName());
+        result = prime * result + Objects.hashCode(getReturnType());
+        return result;
+    }
+
+    @Override
+    public boolean equals(final Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null) {
+            return false;
+        }
+        if (getClass() != obj.getClass()) {
+            return false;
+        }
+        AbstractTypeMember other = (AbstractTypeMember) obj;
+        return Objects.equals(getName(), other.getName()) && Objects.equals(getReturnType(), other.getReturnType());
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder builder = new StringBuilder();
+        builder.append("MethodSignatureImpl [name=");
+        builder.append(getName());
+        builder.append(", comment=");
+        builder.append(getComment());
+        if (getDefiningType() != null) {
+            builder.append(", definingType=");
+            builder.append(getDefiningType().getPackageName());
+            builder.append(".");
+            builder.append(getDefiningType().getName());
+        } else {
+            builder.append(", definingType= null");
+        }
+        builder.append(", returnType=");
+        builder.append(getReturnType());
+        builder.append(", annotations=");
+        builder.append(getAnnotations());
+        builder.append("]");
+        return builder.toString();
+    }
+}
diff --git a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/AbstractTypeMemberBuilder.java b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/AbstractTypeMemberBuilder.java
new file mode 100644 (file)
index 0000000..f3cc5dc
--- /dev/null
@@ -0,0 +1,166 @@
+/*
+ * 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.mdsal.binding.generator.util.generated.type.builder;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableList;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+import org.opendaylight.mdsal.binding.model.api.AccessModifier;
+import org.opendaylight.mdsal.binding.model.api.AnnotationType;
+import org.opendaylight.mdsal.binding.model.api.Type;
+import org.opendaylight.mdsal.binding.model.api.type.builder.AnnotationTypeBuilder;
+import org.opendaylight.mdsal.binding.model.api.type.builder.TypeMemberBuilder;
+import org.opendaylight.yangtools.util.LazyCollections;
+
+abstract class AbstractTypeMemberBuilder<T extends TypeMemberBuilder<T>> implements TypeMemberBuilder<T> {
+    private final String name;
+    private Type returnType;
+    private List<AnnotationTypeBuilder> annotationBuilders = Collections.emptyList();
+    private String comment = "";
+    private boolean isFinal;
+    private boolean isStatic;
+    private AccessModifier accessModifier;
+
+    public AbstractTypeMemberBuilder(final String name) {
+        this.name = name;
+    }
+
+    @Override
+    public AnnotationTypeBuilder addAnnotation(final String packageName, final String name) {
+        Preconditions.checkArgument(packageName != null, "Annotation Type cannot have package name null!");
+        Preconditions.checkArgument(name != null, "Annotation Type cannot have name as null!");
+
+        final AnnotationTypeBuilder builder = new AnnotationTypeBuilderImpl(packageName, name);
+        annotationBuilders = LazyCollections.lazyAdd(annotationBuilders, builder);
+        return builder;
+    }
+
+    protected Type getReturnType() {
+        return returnType;
+    }
+
+    protected Iterable<AnnotationTypeBuilder> getAnnotationBuilders() {
+        return annotationBuilders;
+    }
+
+    protected String getComment() {
+        return comment;
+    }
+
+    protected boolean isFinal() {
+        return isFinal;
+    }
+
+    protected boolean isStatic() {
+        return isStatic;
+    }
+
+    @Override
+    public AccessModifier getAccessModifier() {
+        return accessModifier;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    protected abstract T thisInstance();
+
+    @Override
+    public T setReturnType(final Type returnType) {
+        Preconditions.checkArgument(returnType != null, "Return Type of member cannot be null!");
+        this.returnType = returnType;
+        return thisInstance();
+    }
+
+    @Override
+    public T setAccessModifier(final AccessModifier modifier) {
+        Preconditions.checkArgument(modifier != null, "Access Modifier for member type cannot be null!");
+        this.accessModifier = modifier;
+        return thisInstance();
+    }
+
+    @Override
+    public T setComment(final String comment) {
+        if (comment == null) {
+            this.comment = "";
+        }
+        this.comment = comment;
+        return thisInstance();
+    }
+
+    @Override
+    public T setFinal(final boolean isFinal) {
+        this.isFinal = isFinal;
+        return thisInstance();
+    }
+
+    @Override
+    public T setStatic(final boolean isStatic) {
+        this.isStatic = isStatic;
+        return thisInstance();
+    }
+
+    protected List<AnnotationType> toAnnotationTypes() {
+        final List<AnnotationType> annotations = new ArrayList<>();
+        for (final AnnotationTypeBuilder annotBuilder : getAnnotationBuilders()) {
+            if (annotBuilder != null) {
+                annotations.add(annotBuilder.toInstance());
+            }
+        }
+
+        return ImmutableList.copyOf(annotations);
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + Objects.hashCode(getName());
+        result = prime * result + Objects.hashCode(getReturnType());
+        return result;
+    }
+
+    @Override
+    public boolean equals(final Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null) {
+            return false;
+        }
+        if (getClass() != obj.getClass()) {
+            return false;
+        }
+        AbstractTypeMemberBuilder<?> other = (AbstractTypeMemberBuilder<?>) obj;
+        return Objects.equals(getName(), other.getName()) && Objects.equals(getReturnType(), other.getReturnType());
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder builder = new StringBuilder();
+        builder.append("GeneratedPropertyImpl [name=");
+        builder.append(getName());
+        builder.append(", annotations=");
+        builder.append(getAnnotationBuilders());
+        builder.append(", comment=");
+        builder.append(getComment());
+        builder.append(", returnType=");
+        builder.append(getReturnType());
+        builder.append(", isFinal=");
+        builder.append(isFinal());
+        builder.append(", modifier=");
+        builder.append(getAccessModifier());
+        builder.append("]");
+        return builder.toString();
+    }
+}
diff --git a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/AnnotationTypeBuilderImpl.java b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/AnnotationTypeBuilderImpl.java
new file mode 100644 (file)
index 0000000..f044f16
--- /dev/null
@@ -0,0 +1,305 @@
+/*
+ * 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.mdsal.binding.generator.util.generated.type.builder;
+
+import com.google.common.collect.ImmutableList;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+import org.opendaylight.mdsal.binding.generator.util.AbstractBaseType;
+import org.opendaylight.mdsal.binding.model.api.AnnotationType;
+import org.opendaylight.mdsal.binding.model.api.type.builder.AnnotationTypeBuilder;
+import org.opendaylight.yangtools.util.LazyCollections;
+
+final class AnnotationTypeBuilderImpl extends AbstractBaseType implements AnnotationTypeBuilder {
+
+    private final String packageName;
+    private final String name;
+    private List<AnnotationTypeBuilder> annotationBuilders = Collections.emptyList();
+    private List<AnnotationType.Parameter> parameters = Collections.emptyList();
+
+    public AnnotationTypeBuilderImpl(final String packageName, final String name) {
+        super(packageName, name);
+        this.packageName = packageName;
+        this.name = name;
+    }
+
+    @Override
+    public AnnotationTypeBuilder addAnnotation(final String packageName, final String name) {
+        if (packageName != null && name != null) {
+            final AnnotationTypeBuilder builder = new AnnotationTypeBuilderImpl(packageName, name);
+            if (!annotationBuilders.contains(builder)) {
+                annotationBuilders = LazyCollections.lazyAdd(annotationBuilders, builder);
+                return builder;
+            }
+        }
+        return null;
+    }
+
+    private boolean addParameter(final ParameterImpl param) {
+        if (!parameters.contains(param)) {
+            parameters = LazyCollections.lazyAdd(parameters, param);
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    @Override
+    public boolean addParameter(final String paramName, final String value) {
+        if (paramName != null && value != null) {
+            final ParameterImpl param = new ParameterImpl(paramName, value);
+            return addParameter(param);
+        }
+        return false;
+    }
+
+    @Override
+    public boolean addParameters(final String paramName, final List<String> values) {
+        if (paramName != null && values != null) {
+            final ParameterImpl param = new ParameterImpl(paramName, values);
+            return addParameter(param);
+        }
+        return false;
+    }
+
+    @Override
+    public AnnotationType toInstance() {
+        return new AnnotationTypeImpl(packageName, name, annotationBuilders, parameters);
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + Objects.hashCode(name);
+        result = prime * result + Objects.hashCode(packageName);
+        return result;
+    }
+
+    @Override
+    public boolean equals(final Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null) {
+            return false;
+        }
+        if (getClass() != obj.getClass()) {
+            return false;
+        }
+        AnnotationTypeBuilderImpl other = (AnnotationTypeBuilderImpl) obj;
+        return Objects.equals(name, other.name) && Objects.equals(packageName, other.packageName);
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder builder = new StringBuilder();
+        builder.append("AnnotationTypeBuilder [packageName=");
+        builder.append(packageName);
+        builder.append(", name=");
+        builder.append(name);
+        builder.append(", annotationBuilders=");
+        builder.append(annotationBuilders);
+        builder.append(", parameters=");
+        builder.append(parameters);
+        builder.append("]");
+        return builder.toString();
+    }
+
+    private static final class AnnotationTypeImpl implements AnnotationType {
+
+        private final String packageName;
+        private final String name;
+        private final List<AnnotationType> annotations;
+        private final List<AnnotationType.Parameter> parameters;
+        private final List<String> paramNames;
+
+        public AnnotationTypeImpl(final String packageName, final String name,
+                final List<AnnotationTypeBuilder> annotationBuilders,
+                final List<AnnotationType.Parameter> parameters) {
+            super();
+            this.packageName = packageName;
+            this.name = name;
+
+            final List<AnnotationType> a = new ArrayList<>();
+            for (final AnnotationTypeBuilder builder : annotationBuilders) {
+                a.add(builder.toInstance());
+            }
+            this.annotations = ImmutableList.copyOf(a);
+
+            final List<String> p = new ArrayList<>();
+            for (final AnnotationType.Parameter parameter : parameters) {
+                p.add(parameter.getName());
+            }
+            this.paramNames = ImmutableList.copyOf(p);
+
+            this.parameters = parameters.isEmpty() ? Collections.<AnnotationType.Parameter>emptyList()
+                    : Collections.unmodifiableList(parameters);
+        }
+
+        @Override
+        public String getPackageName() {
+            return packageName;
+        }
+
+        @Override
+        public String getName() {
+            return name;
+        }
+
+        @Override
+        public String getFullyQualifiedName() {
+            return packageName + "." + name;
+        }
+
+        @Override
+        public List<AnnotationType> getAnnotations() {
+            return annotations;
+        }
+
+        @Override
+        public Parameter getParameter(final String paramName) {
+            if (paramName != null) {
+                for (final AnnotationType.Parameter parameter : parameters) {
+                    if (parameter.getName().equals(paramName)) {
+                        return parameter;
+                    }
+                }
+            }
+            return null;
+        }
+
+        @Override
+        public List<Parameter> getParameters() {
+            return parameters;
+        }
+
+        @Override
+        public List<String> getParameterNames() {
+            return paramNames;
+        }
+
+        @Override
+        public boolean containsParameters() {
+            return !parameters.isEmpty();
+        }
+
+        @Override
+        public int hashCode() {
+            final int prime = 31;
+            int result = 1;
+            result = prime * result + Objects.hashCode(name);
+            result = prime * result + Objects.hashCode(packageName);
+            return result;
+        }
+
+        @Override
+        public boolean equals(final Object obj) {
+            if (this == obj) {
+                return true;
+            }
+            if (obj == null) {
+                return false;
+            }
+            if (getClass() != obj.getClass()) {
+                return false;
+            }
+            AnnotationTypeImpl other = (AnnotationTypeImpl) obj;
+            return Objects.equals(name, other.name) && Objects.equals(packageName, other.packageName);
+        }
+
+        @Override
+        public String toString() {
+            StringBuilder builder = new StringBuilder();
+            builder.append("AnnotationType [packageName=");
+            builder.append(packageName);
+            builder.append(", name=");
+            builder.append(name);
+            builder.append(", annotations=");
+            builder.append(annotations);
+            builder.append(", parameters=");
+            builder.append(parameters);
+            builder.append("]");
+            return builder.toString();
+        }
+    }
+
+    private static final class ParameterImpl implements AnnotationType.Parameter {
+
+        private final String name;
+        private final String value;
+        private final List<String> values;
+
+        public ParameterImpl(final String name, final String value) {
+            super();
+            this.name = name;
+            this.value = value;
+            this.values = Collections.emptyList();
+        }
+
+        public ParameterImpl(final String name, final List<String> values) {
+            super();
+            this.name = name;
+            this.values = values;
+            this.value = null;
+        }
+
+        @Override
+        public String getName() {
+            return name;
+        }
+
+        @Override
+        public String getValue() {
+            return value;
+        }
+
+        @Override
+        public List<String> getValues() {
+            return values;
+        }
+
+        @Override
+        public int hashCode() {
+            final int prime = 31;
+            int result = 1;
+            result = prime * result + Objects.hashCode(name);
+            return result;
+        }
+
+        @Override
+        public boolean equals(final Object obj) {
+            if (this == obj) {
+                return true;
+            }
+            if (obj == null) {
+                return false;
+            }
+            if (getClass() != obj.getClass()) {
+                return false;
+            }
+            ParameterImpl other = (ParameterImpl) obj;
+            return Objects.equals(name, other.name);
+        }
+
+        @Override
+        public String toString() {
+            StringBuilder builder = new StringBuilder();
+            builder.append("ParameterImpl [name=");
+            builder.append(name);
+            builder.append(", value=");
+            builder.append(value);
+            builder.append(", values=");
+            builder.append(values);
+            builder.append("]");
+            return builder.toString();
+        }
+    }
+}
diff --git a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/ConstantImpl.java b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/ConstantImpl.java
new file mode 100644 (file)
index 0000000..92c1fea
--- /dev/null
@@ -0,0 +1,114 @@
+/*
+ * 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.mdsal.binding.generator.util.generated.type.builder;
+
+import java.util.Objects;
+import org.opendaylight.mdsal.binding.model.api.Constant;
+import org.opendaylight.mdsal.binding.model.api.Type;
+
+final class ConstantImpl implements Constant {
+
+    private final Type definingType;
+    private final Type type;
+    private final String name;
+    private final Object value;
+
+    public ConstantImpl(final Type definingType, final Type type, final String name, final Object value) {
+        super();
+        this.definingType = definingType;
+        this.type = type;
+        this.name = name;
+        this.value = value;
+    }
+
+    @Override
+    public Type getDefiningType() {
+        return definingType;
+    }
+
+    @Override
+    public Type getType() {
+        return type;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public Object getValue() {
+        return value;
+    }
+
+    @Override
+    public String toFormattedString() {
+        StringBuilder builder = new StringBuilder();
+        builder.append(type);
+        builder.append(" ");
+        builder.append(name);
+        builder.append(" ");
+        builder.append(value);
+        return builder.toString();
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see java.lang.Object#hashCode()
+     */
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + Objects.hashCode(name);
+        result = prime * result + Objects.hashCode(type);
+        return result;
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see java.lang.Object#equals(java.lang.Object)
+     */
+    @Override
+    public boolean equals(final Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null) {
+            return false;
+        }
+        if (getClass() != obj.getClass()) {
+            return false;
+        }
+        ConstantImpl other = (ConstantImpl) obj;
+        return Objects.equals(name, other.name) && Objects.equals(type, other.type) && Objects.equals(value, other.value);
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder builder = new StringBuilder();
+        builder.append("Constant [type=");
+        builder.append(type);
+        builder.append(", name=");
+        builder.append(name);
+        builder.append(", value=");
+        builder.append(value);
+        if (definingType != null) {
+            builder.append(", definingType=");
+            builder.append(definingType.getPackageName());
+            builder.append(".");
+            builder.append(definingType.getName());
+        } else {
+            builder.append(", definingType= null");
+        }
+        builder.append("]");
+        return builder.toString();
+    }
+}
diff --git a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/EnumerationBuilderImpl.java b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/EnumerationBuilderImpl.java
new file mode 100644 (file)
index 0000000..a4596b6
--- /dev/null
@@ -0,0 +1,381 @@
+/*
+ * 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.mdsal.binding.generator.util.generated.type.builder;
+
+import com.google.common.collect.ImmutableList;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+import org.opendaylight.mdsal.binding.generator.util.AbstractBaseType;
+import org.opendaylight.mdsal.binding.model.api.AnnotationType;
+import org.opendaylight.mdsal.binding.model.api.Constant;
+import org.opendaylight.mdsal.binding.model.api.Enumeration;
+import org.opendaylight.mdsal.binding.model.api.Enumeration.Pair;
+import org.opendaylight.mdsal.binding.model.api.GeneratedProperty;
+import org.opendaylight.mdsal.binding.model.api.GeneratedType;
+import org.opendaylight.mdsal.binding.model.api.MethodSignature;
+import org.opendaylight.mdsal.binding.model.api.Type;
+import org.opendaylight.mdsal.binding.model.api.type.builder.AnnotationTypeBuilder;
+import org.opendaylight.mdsal.binding.model.api.type.builder.EnumBuilder;
+import org.opendaylight.yangtools.util.LazyCollections;
+import org.opendaylight.yangtools.yang.binding.BindingMapping;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.Status;
+import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition.EnumPair;
+
+public final class EnumerationBuilderImpl extends AbstractBaseType implements EnumBuilder {
+    private final String packageName;
+    private final String name;
+    private List<Enumeration.Pair> values = Collections.emptyList();
+    private List<AnnotationTypeBuilder> annotationBuilders = Collections.emptyList();
+    private List<Pair> unmodifiableValues  = Collections.emptyList();
+    private String description;
+    private String reference;
+    private String moduleName;
+    private Iterable<QName> schemaPath;
+
+    public EnumerationBuilderImpl(final String packageName, final String name) {
+        super(packageName, name);
+        this.packageName = packageName;
+        this.name = name;
+    }
+
+    public void setReference(final String reference) {
+        this.reference = reference;
+    }
+
+    public void setModuleName(final String moduleName) {
+        this.moduleName = moduleName;
+    }
+
+    public void setSchemaPath(final Iterable<QName> schemaPath) {
+        this.schemaPath = schemaPath;
+    }
+
+    @Override
+    public void setDescription(final String description) {
+        this.description = description;
+
+    }
+
+    @Override
+    public AnnotationTypeBuilder addAnnotation(final String packageName, final String name) {
+        if (packageName != null && name != null) {
+            final AnnotationTypeBuilder builder = new AnnotationTypeBuilderImpl(packageName, name);
+            if (!annotationBuilders.contains(builder)) {
+                annotationBuilders = LazyCollections.lazyAdd(annotationBuilders, builder);
+                return builder;
+            }
+        }
+        return null;
+    }
+
+    @Override
+    public void addValue(final String name, final int value, final String description) {
+        final EnumPairImpl p = new EnumPairImpl(name, value, description);
+        values = LazyCollections.lazyAdd(values, p);
+        unmodifiableValues = Collections.unmodifiableList(values);
+    }
+
+    @Override
+    public Enumeration toInstance(final Type definingType) {
+        return new EnumerationImpl(definingType, annotationBuilders, packageName, name, unmodifiableValues,
+                description, reference, moduleName, schemaPath);
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see java.lang.Object#toString()
+     */
+    @Override
+    public String toString() {
+        StringBuilder builder = new StringBuilder();
+        builder.append("EnumerationBuilderImpl [packageName=");
+        builder.append(packageName);
+        builder.append(", name=");
+        builder.append(name);
+        builder.append(", values=");
+        builder.append(values);
+        builder.append("]");
+        return builder.toString();
+    }
+
+    @Override
+    public void updateEnumPairsFromEnumTypeDef(final EnumTypeDefinition enumTypeDef) {
+        final List<EnumPair> enums = enumTypeDef.getValues();
+        if (enums != null) {
+            for (final EnumPair enumPair : enums) {
+                if (enumPair != null) {
+                    this.addValue(enumPair.getName(), enumPair.getValue(), enumPair.getDescription());
+                }
+            }
+        }
+
+    }
+
+    private static final class EnumPairImpl implements Enumeration.Pair {
+
+        private final String name;
+        private final String mappedName;
+        private final int value;
+        private final String description;
+
+        public EnumPairImpl(final String name, final int value, final String description) {
+            super();
+            this.name = name;
+            this.mappedName = BindingMapping.getClassName(name);
+            this.value = value;
+            this.description = description;
+        }
+
+        @Override
+        public String getName() {
+            return name;
+        }
+
+        @Override
+        public String getMappedName() {
+            return mappedName;
+        }
+
+        @Override
+        public int getValue() {
+            return value;
+        }
+
+        /*
+         * (non-Javadoc)
+         *
+         * @see java.lang.Object#hashCode()
+         */
+        @Override
+        public int hashCode() {
+            final int prime = 31;
+            int result = 1;
+            result = prime * result + Objects.hashCode(name);
+            result = prime * result + Objects.hashCode(value);
+            return result;
+        }
+
+        /*
+         * (non-Javadoc)
+         *
+         * @see java.lang.Object#equals(java.lang.Object)
+         */
+        @Override
+        public boolean equals(final Object obj) {
+            if (this == obj) {
+                return true;
+            }
+            if (obj == null) {
+                return false;
+            }
+            if (getClass() != obj.getClass()) {
+                return false;
+            }
+            EnumPairImpl other = (EnumPairImpl) obj;
+            return Objects.equals(name, other.name) && Objects.equals(value, other.value);
+        }
+
+        /*
+         * (non-Javadoc)
+         *
+         * @see java.lang.Object#toString()
+         */
+        @Override
+        public String toString() {
+            StringBuilder builder = new StringBuilder();
+            builder.append("EnumPair [name=");
+            builder.append(name);
+            builder.append(", mappedName=");
+            builder.append(getMappedName());
+            builder.append(", value=");
+            builder.append(value);
+            builder.append("]");
+            return builder.toString();
+        }
+
+        @Override
+        public String getDescription() {
+            return description;
+        }
+
+        @Override
+        public String getReference() {
+            return null;
+        }
+
+        @Override
+        public Status getStatus() {
+            // TODO Auto-generated method stub
+            return null;
+        }
+
+    }
+
+    private static final class EnumerationImpl extends AbstractBaseType implements Enumeration {
+
+        private final Type definingType;
+        private final String description;
+        private final String reference;
+        private final String moduleName;
+        private final Iterable<QName> schemaPath;
+        private final List<Pair> values;
+        private final List<AnnotationType> annotations;
+
+        public EnumerationImpl(final Type definingType, final List<AnnotationTypeBuilder> annotationBuilders,
+                final String packageName, final String name, final List<Pair> values, final String description,
+                final String reference, final String moduleName, final Iterable<QName> schemaPath) {
+            super(packageName, name);
+            this.definingType = definingType;
+            this.values = values;
+            this.description = description;
+            this.moduleName = moduleName;
+            this.schemaPath = schemaPath;
+            this.reference = reference;
+
+            final ArrayList<AnnotationType> a = new ArrayList<>();
+            for (final AnnotationTypeBuilder builder : annotationBuilders) {
+                a.add(builder.toInstance());
+            }
+            this.annotations = ImmutableList.copyOf(a);
+        }
+
+        @Override
+        public Type getParentType() {
+            return definingType;
+        }
+
+        @Override
+        public List<Pair> getValues() {
+            return values;
+        }
+
+        @Override
+        public List<AnnotationType> getAnnotations() {
+            return annotations;
+        }
+
+        @Override
+        public String toFormattedString() {
+            StringBuilder builder = new StringBuilder();
+            builder.append("public enum");
+            builder.append(" ");
+            builder.append(getName());
+            builder.append(" {");
+            builder.append("\n");
+
+            int i = 0;
+            for (final Enumeration.Pair valPair : values) {
+                builder.append("\t");
+                builder.append(" ");
+                builder.append(valPair.getMappedName());
+                builder.append(" (");
+                builder.append(valPair.getValue());
+
+                if (i == (values.size() - 1)) {
+                    builder.append(" );");
+                } else {
+                    builder.append(" ),");
+                }
+                ++i;
+            }
+            builder.append("\n}");
+            return builder.toString();
+        }
+
+        /*
+         * (non-Javadoc)
+         *
+         * @see java.lang.Object#toString()
+         */
+        @Override
+        public String toString() {
+            StringBuilder builder = new StringBuilder();
+            builder.append("Enumeration [packageName=");
+            builder.append(getPackageName());
+            if (definingType != null) {
+                builder.append(", definingType=");
+                builder.append(definingType.getPackageName());
+                builder.append(".");
+                builder.append(definingType.getName());
+            } else {
+                builder.append(", definingType= null");
+            }
+            builder.append(", name=");
+            builder.append(getName());
+            builder.append(", values=");
+            builder.append(values);
+            builder.append("]");
+            return builder.toString();
+        }
+
+        @Override
+        public String getComment() {
+            return null;
+        }
+
+        @Override
+        public boolean isAbstract() {
+            return false;
+        }
+
+        @Override
+        public List<Type> getImplements() {
+            return Collections.emptyList();
+        }
+
+        @Override
+        public List<GeneratedType> getEnclosedTypes() {
+            return Collections.emptyList();
+        }
+
+        @Override
+        public List<Enumeration> getEnumerations() {
+            return Collections.emptyList();
+        }
+
+        @Override
+        public List<Constant> getConstantDefinitions() {
+            return Collections.emptyList();
+        }
+
+        @Override
+        public List<MethodSignature> getMethodDefinitions() {
+            return Collections.emptyList();
+        }
+
+        @Override
+        public List<GeneratedProperty> getProperties() {
+            return Collections.emptyList();
+        }
+
+        @Override
+        public String getDescription() {
+            return description;
+        }
+
+        @Override
+        public String getReference() {
+            return reference;
+        }
+
+        @Override
+        public Iterable<QName> getSchemaPath() {
+            return schemaPath;
+        }
+
+        @Override
+        public String getModuleName() {
+            return moduleName;
+        }
+    }
+}
diff --git a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/GeneratedPropertyBuilderImpl.java b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/GeneratedPropertyBuilderImpl.java
new file mode 100644 (file)
index 0000000..e5abf44
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * 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.mdsal.binding.generator.util.generated.type.builder;
+
+import java.util.List;
+
+import org.opendaylight.mdsal.binding.model.api.AnnotationType;
+import org.opendaylight.mdsal.binding.model.api.GeneratedProperty;
+import org.opendaylight.mdsal.binding.model.api.Type;
+import org.opendaylight.mdsal.binding.model.api.type.builder.GeneratedPropertyBuilder;
+
+public final class GeneratedPropertyBuilderImpl extends AbstractTypeMemberBuilder<GeneratedPropertyBuilder> implements GeneratedPropertyBuilder {
+    private String value;
+    private boolean isReadOnly;
+
+    public GeneratedPropertyBuilderImpl(String name) {
+        super(name);
+        this.isReadOnly = true;
+    }
+
+    @Override
+    public GeneratedPropertyBuilderImpl setValue(String value) {
+        this.value = value;
+        return this;
+    }
+
+    @Override
+    public GeneratedPropertyBuilderImpl setReadOnly(boolean isReadOnly) {
+        this.isReadOnly = isReadOnly;
+        return this;
+    }
+
+    @Override
+    protected GeneratedPropertyBuilderImpl thisInstance() {
+        return this;
+    }
+
+    @Override
+    public GeneratedProperty toInstance(Type definingType) {
+        final List<AnnotationType> annotations = toAnnotationTypes();
+        return new GeneratedPropertyImpl(definingType, getName(), annotations, getComment(), getAccessModifier(),
+                getReturnType(), isFinal(), isStatic(), isReadOnly, value);
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder builder = new StringBuilder();
+        builder.append("GeneratedPropertyImpl [name=");
+        builder.append(getName());
+        builder.append(", annotations=");
+        builder.append(getAnnotationBuilders());
+        builder.append(", comment=");
+        builder.append(getComment());
+        builder.append(", returnType=");
+        builder.append(getReturnType());
+        builder.append(", isFinal=");
+        builder.append(isFinal());
+        builder.append(", isReadOnly=");
+        builder.append(isReadOnly);
+        builder.append(", modifier=");
+        builder.append(getAccessModifier());
+        builder.append("]");
+        return builder.toString();
+    }
+}
\ No newline at end of file
diff --git a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/GeneratedPropertyImpl.java b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/GeneratedPropertyImpl.java
new file mode 100644 (file)
index 0000000..139152f
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * 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.mdsal.binding.generator.util.generated.type.builder;
+
+import java.util.List;
+
+import org.opendaylight.mdsal.binding.model.api.AccessModifier;
+import org.opendaylight.mdsal.binding.model.api.AnnotationType;
+import org.opendaylight.mdsal.binding.model.api.GeneratedProperty;
+import org.opendaylight.mdsal.binding.model.api.Type;
+
+final class GeneratedPropertyImpl extends AbstractTypeMember implements GeneratedProperty {
+    private String value;
+    private boolean isReadOnly;
+
+    public GeneratedPropertyImpl(Type definingType, String name, List<AnnotationType> annotations, String comment,
+                                 AccessModifier accessModifier, Type returnType, boolean isFinal, boolean isStatic, boolean isReadOnly, String value) {
+        super(definingType, name, annotations, comment, accessModifier, returnType, isFinal, isStatic);
+        this.value = value;
+        this.isReadOnly = isReadOnly;
+    }
+
+    @Override
+    public String getValue() {
+        return value;
+    }
+
+    @Override
+    public boolean isReadOnly() {
+        return isReadOnly;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder builder = new StringBuilder();
+        builder.append("GeneratedPropertyImpl [name=");
+        builder.append(getName());
+        builder.append(", annotations=");
+        builder.append(getAnnotations());
+        builder.append(", comment=");
+        builder.append(getComment());
+        if (getDefiningType() != null) {
+            builder.append(", parent=");
+            builder.append(getDefiningType().getPackageName());
+            builder.append(".");
+            builder.append(getDefiningType().getName());
+        } else {
+            builder.append(", parent=null");
+        }
+        builder.append(", returnType=");
+        builder.append(getReturnType());
+        builder.append(", isFinal=");
+        builder.append(isFinal());
+        builder.append(", isReadOnly=");
+        builder.append(isReadOnly);
+        builder.append(", modifier=");
+        builder.append(getAccessModifier());
+        builder.append("]");
+        return builder.toString();
+    }
+}
diff --git a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/GeneratedTOBuilderImpl.java b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/GeneratedTOBuilderImpl.java
new file mode 100644 (file)
index 0000000..47a7950
--- /dev/null
@@ -0,0 +1,355 @@
+/*
+ * 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.mdsal.binding.generator.util.generated.type.builder;
+
+import com.google.common.base.Preconditions;
+import java.util.Collections;
+import java.util.List;
+import org.opendaylight.mdsal.binding.model.api.GeneratedProperty;
+import org.opendaylight.mdsal.binding.model.api.GeneratedTransferObject;
+import org.opendaylight.mdsal.binding.model.api.ParameterizedType;
+import org.opendaylight.mdsal.binding.model.api.Restrictions;
+import org.opendaylight.mdsal.binding.model.api.Type;
+import org.opendaylight.mdsal.binding.model.api.type.builder.GeneratedPropertyBuilder;
+import org.opendaylight.mdsal.binding.model.api.type.builder.GeneratedTOBuilder;
+import org.opendaylight.mdsal.binding.model.api.type.builder.MethodSignatureBuilder;
+import org.opendaylight.yangtools.util.LazyCollections;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
+
+public final class GeneratedTOBuilderImpl extends AbstractGeneratedTypeBuilder<GeneratedTOBuilder> implements GeneratedTOBuilder {
+
+    private GeneratedTransferObject extendsType;
+    private List<GeneratedPropertyBuilder> equalsProperties = Collections.emptyList();
+    private List<GeneratedPropertyBuilder> hashProperties = Collections.emptyList();
+    private List<GeneratedPropertyBuilder> toStringProperties = Collections.emptyList();
+    private boolean isTypedef = false;
+    private boolean isUnionType = false;
+    private boolean isUnionTypeBuilder = false;
+    private TypeDefinition<?> baseType = null;
+    private Restrictions restrictions;
+    private GeneratedPropertyBuilder SUID;
+    private String reference;
+    private String description;
+    private String moduleName;
+    private Iterable<QName> schemaPath;
+
+    public GeneratedTOBuilderImpl(final String packageName, final String name) {
+        super(packageName, name);
+        setAbstract(false);
+    }
+
+    @Override
+    public GeneratedTOBuilder setExtendsType(final GeneratedTransferObject genTransObj) {
+        Preconditions.checkArgument(genTransObj != null, "Generated Transfer Object cannot be null!");
+        extendsType = genTransObj;
+        return this;
+    }
+
+    /**
+     * 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(boolean)},
+     * {TypeMemberBuilder#setFinal(boolean)} and
+     * {TypeMemberBuilder#setAccessModifier(boolean)}
+     *
+     * @param name
+     *            Name of Method
+     * @return <code>new</code> instance of Method Signature Builder.
+     */
+    @Override
+    public MethodSignatureBuilder addMethod(final String name) {
+        final MethodSignatureBuilder builder = super.addMethod(name);
+        builder.setAbstract(false);
+        return builder;
+    }
+
+    @Override
+    public GeneratedTOBuilder addEqualsIdentity(final GeneratedPropertyBuilder property) {
+        equalsProperties = LazyCollections.lazyAdd(equalsProperties, property);
+        return this;
+    }
+
+    @Override
+    public GeneratedTOBuilder addHashIdentity(final GeneratedPropertyBuilder property) {
+        hashProperties = LazyCollections.lazyAdd(hashProperties, property);
+        return this;
+    }
+
+    @Override
+    public GeneratedTOBuilder addToStringProperty(final GeneratedPropertyBuilder property) {
+        toStringProperties = LazyCollections.lazyAdd(toStringProperties, property);
+        return this;
+    }
+
+    @Override
+    protected GeneratedTOBuilder thisInstance() {
+        return this;
+    }
+
+    @Override
+    public void setRestrictions(final Restrictions restrictions) {
+        this.restrictions = restrictions;
+    }
+
+    @Override
+    public void setSUID(final GeneratedPropertyBuilder suid) {
+        this.SUID = suid;
+    }
+
+    @Override
+    public GeneratedTransferObject toInstance() {
+        return new GeneratedTransferObjectImpl(this);
+    }
+
+    @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(", 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 setTypedef(final boolean isTypedef) {
+        this.isTypedef = isTypedef;
+    }
+
+    @Override
+    public void setBaseType(final TypeDefinition<?> typeDef) {
+        this.baseType = typeDef;
+    }
+
+    @Override
+    public void setIsUnion(final boolean isUnion) {
+        this.isUnionType = isUnion;
+    }
+
+    @Override
+    public void setIsUnionBuilder(final boolean isUnionTypeBuilder) {
+        this.isUnionTypeBuilder = isUnionTypeBuilder;
+    }
+
+    @Override
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    @Override
+    public void setModuleName(String moduleName) {
+        this.moduleName = moduleName;
+    }
+
+    @Override
+    public void setSchemaPath(Iterable<QName> schemaPath) {
+        this.schemaPath = schemaPath;
+    }
+
+    @Override
+    public void setReference(String reference) {
+        this.reference = reference;
+    }
+
+    private static final class GeneratedTransferObjectImpl extends AbstractGeneratedType implements
+    GeneratedTransferObject {
+
+        private final List<GeneratedProperty> equalsProperties;
+        private final List<GeneratedProperty> hashCodeProperties;
+        private final List<GeneratedProperty> stringProperties;
+        private final GeneratedTransferObject extendsType;
+        private final boolean isTypedef;
+        private final TypeDefinition<?> baseType;
+        private final boolean isUnionType;
+        private final boolean isUnionTypeBuilder;
+        private final Restrictions restrictions;
+        private final GeneratedProperty SUID;
+        private final String reference;
+        private final String description;
+        private final String moduleName;
+        private final Iterable<QName> schemaPath;
+
+        public GeneratedTransferObjectImpl(final GeneratedTOBuilderImpl builder) {
+            super(builder);
+            this.extendsType = builder.extendsType;
+
+            // FIXME: if these fields were guaranteed to be constant, we could perhaps
+            //        cache and reuse them between instances...
+            this.equalsProperties = toUnmodifiableProperties(builder.equalsProperties);
+            this.hashCodeProperties = toUnmodifiableProperties(builder.hashProperties);
+            this.stringProperties = toUnmodifiableProperties(builder.toStringProperties);
+
+            this.isTypedef = builder.isTypedef;
+            this.baseType = builder.baseType;
+            this.isUnionType = builder.isUnionType;
+            this.isUnionTypeBuilder = builder.isUnionTypeBuilder;
+            this.restrictions = builder.restrictions;
+            this.reference = builder.reference;
+            this.description = builder.description;
+            this.moduleName = builder.moduleName;
+            this.schemaPath = builder.schemaPath;
+
+            if (builder.SUID == null) {
+                this.SUID = null;
+            } else {
+                this.SUID = builder.SUID.toInstance(GeneratedTransferObjectImpl.this);
+            }
+        }
+
+        @Override
+        public boolean isTypedef() {
+            return isTypedef;
+        }
+
+        @Override
+        public TypeDefinition<?> getBaseType() {
+            return baseType;
+        }
+
+        @Override
+        public boolean isUnionType() {
+            return isUnionType;
+        }
+
+        @Override
+        public boolean isUnionTypeBuilder() {
+            return isUnionTypeBuilder;
+        }
+
+        @Override
+        public GeneratedTransferObject getSuperType() {
+            return extendsType;
+        }
+
+        @Override
+        public List<GeneratedProperty> getEqualsIdentifiers() {
+            return equalsProperties;
+        }
+
+        @Override
+        public List<GeneratedProperty> getHashCodeIdentifiers() {
+            return hashCodeProperties;
+        }
+
+        @Override
+        public List<GeneratedProperty> getToStringIdentifiers() {
+            return stringProperties;
+        }
+
+        @Override
+        public Restrictions getRestrictions() {
+            return restrictions;
+        }
+
+        @Override
+        public GeneratedProperty getSUID() {
+            return SUID;
+        }
+
+        @Override
+        public String toString() {
+            if (isTypedef) {
+                return serializeTypedef(this);
+            }
+            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(getSuperType());
+            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(getProperties());
+            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();
+        }
+
+        public String serializeTypedef(final Type type) {
+            if (type instanceof ParameterizedType) {
+                ParameterizedType parameterizedType = (ParameterizedType) type;
+                StringBuilder sb = new StringBuilder();
+                sb.append(parameterizedType.getRawType().getFullyQualifiedName());
+                sb.append('<');
+                boolean first = true;
+                for (Type parameter : parameterizedType.getActualTypeArguments()) {
+                    if (first) {
+                        first = false;
+                    } else {
+                        sb.append(',');
+                    }
+                    sb.append(serializeTypedef(parameter));
+                }
+                sb.append('>');
+                return sb.toString();
+            } else {
+                return type.getFullyQualifiedName();
+            }
+        }
+
+        @Override
+        public String getDescription() {
+            return description;
+        }
+
+        @Override
+        public String getReference() {
+            return reference;
+        }
+
+        @Override
+        public Iterable<QName> getSchemaPath() {
+            return schemaPath;
+        }
+
+        @Override
+        public String getModuleName() {
+            return moduleName;
+        }
+    }
+}
diff --git a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/GeneratedTypeBuilderImpl.java b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/GeneratedTypeBuilderImpl.java
new file mode 100644 (file)
index 0000000..09057f5
--- /dev/null
@@ -0,0 +1,119 @@
+/*
+ * 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.mdsal.binding.generator.util.generated.type.builder;
+
+import org.opendaylight.mdsal.binding.model.api.GeneratedType;
+import org.opendaylight.mdsal.binding.model.api.type.builder.GeneratedTypeBuilder;
+import org.opendaylight.yangtools.yang.common.QName;
+
+public final class GeneratedTypeBuilderImpl extends AbstractGeneratedTypeBuilder<GeneratedTypeBuilder> implements
+        GeneratedTypeBuilder {
+
+    private String description;
+    private String reference;
+    private String moduleName;
+    private Iterable<QName> schemaPath;
+
+    public GeneratedTypeBuilderImpl(final String packageName, final String name) {
+        super(packageName, name);
+        setAbstract(true);
+    }
+
+    @Override
+    public GeneratedType toInstance() {
+        return new GeneratedTypeImpl(this);
+    }
+
+    @Override
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    @Override
+    public void setModuleName(String moduleName) {
+        this.moduleName = moduleName;
+    }
+
+    @Override
+    public void setSchemaPath(Iterable<QName> schemaPath) {
+        this.schemaPath = schemaPath;
+    }
+
+    @Override
+    public void setReference(String reference) {
+        this.reference = reference;
+    }
+
+    @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(", annotations=");
+        builder.append(getAnnotations());
+        builder.append(", implements=");
+        builder.append(getImplementsTypes());
+        builder.append(", enclosedTypes=");
+        builder.append(getEnclosedTypes());
+        builder.append(", constants=");
+        builder.append(getConstants());
+        builder.append(", enumerations=");
+        builder.append(getEnumerations());
+        builder.append(", properties=");
+        builder.append(", methods=");
+        builder.append(getMethodDefinitions());
+        builder.append("]");
+        return builder.toString();
+    }
+
+    @Override
+    protected GeneratedTypeBuilderImpl thisInstance() {
+        return this;
+    }
+
+    private static final class GeneratedTypeImpl extends AbstractGeneratedType {
+
+        private final String description;
+        private final String reference;
+        private final String moduleName;
+        private final Iterable<QName> schemaPath;
+
+        public GeneratedTypeImpl(GeneratedTypeBuilderImpl builder) {
+            super(builder);
+
+            this.description = builder.description;
+            this.reference = builder.reference;
+            this.moduleName = builder.moduleName;
+            this.schemaPath = builder.schemaPath;
+        }
+
+        @Override
+        public String getDescription() {
+            return description;
+        }
+
+        @Override
+        public String getReference() {
+            return reference;
+        }
+
+        @Override
+        public Iterable<QName> getSchemaPath() {
+            return schemaPath;
+        }
+
+        @Override
+        public String getModuleName() {
+            return moduleName;
+        }
+    }
+}
diff --git a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/MethodParameterImpl.java b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/MethodParameterImpl.java
new file mode 100644 (file)
index 0000000..682e0fa
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * 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.mdsal.binding.generator.util.generated.type.builder;
+
+import java.util.Objects;
+import org.opendaylight.mdsal.binding.model.api.MethodSignature.Parameter;
+import org.opendaylight.mdsal.binding.model.api.Type;
+
+final class MethodParameterImpl implements Parameter {
+
+    private final String name;
+    private final Type type;
+
+    public MethodParameterImpl(final String name, final Type type) {
+        super();
+        this.name = name;
+        this.type = type;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public Type getType() {
+        return type;
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see java.lang.Object#hashCode()
+     */
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + Objects.hashCode(name);
+        result = prime * result + Objects.hashCode(type);
+        return result;
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see java.lang.Object#equals(java.lang.Object)
+     */
+    @Override
+    public boolean equals(final Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null) {
+            return false;
+        }
+        if (getClass() != obj.getClass()) {
+            return false;
+        }
+        MethodParameterImpl other = (MethodParameterImpl) obj;
+        return Objects.equals(name, other.name) && Objects.equals(type, other.type);
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see java.lang.Object#toString()
+     */
+    @Override
+    public String toString() {
+        StringBuilder builder = new StringBuilder();
+        builder.append("MethodParameter [name=");
+        builder.append(name);
+        builder.append(", type=");
+        builder.append(type.getPackageName());
+        builder.append(".");
+        builder.append(type.getName());
+        builder.append("]");
+        return builder.toString();
+    }
+}
diff --git a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/MethodSignatureBuilderImpl.java b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/MethodSignatureBuilderImpl.java
new file mode 100644 (file)
index 0000000..aa17fc8
--- /dev/null
@@ -0,0 +1,104 @@
+/*
+ * 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.mdsal.binding.generator.util.generated.type.builder;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+import org.opendaylight.mdsal.binding.model.api.AnnotationType;
+import org.opendaylight.mdsal.binding.model.api.MethodSignature;
+import org.opendaylight.mdsal.binding.model.api.Type;
+import org.opendaylight.mdsal.binding.model.api.type.builder.MethodSignatureBuilder;
+import org.opendaylight.yangtools.util.LazyCollections;
+
+final class MethodSignatureBuilderImpl extends AbstractTypeMemberBuilder<MethodSignatureBuilder> implements MethodSignatureBuilder {
+
+    private List<MethodSignature.Parameter> parameters = Collections.emptyList();
+    private List<MethodSignature.Parameter> unmodifiableParams  = Collections.emptyList();
+    private boolean isAbstract;
+
+    public MethodSignatureBuilderImpl(final String name) {
+        super(name);
+    }
+
+    @Override
+    public MethodSignatureBuilder setAbstract(final boolean isAbstract) {
+        this.isAbstract = isAbstract;
+        return this;
+    }
+
+    @Override
+    public MethodSignatureBuilder addParameter(final Type type, final String name) {
+        parameters = LazyCollections.lazyAdd(parameters, new MethodParameterImpl(name, type));
+        unmodifiableParams = Collections.unmodifiableList(parameters);
+        return this;
+    }
+
+    @Override
+    protected MethodSignatureBuilder thisInstance() {
+        return this;
+    }
+
+    @Override
+    public MethodSignature toInstance(final Type definingType) {
+        final List<AnnotationType> annotations = toAnnotationTypes();
+        return new MethodSignatureImpl(definingType, getName(), annotations, getComment(), getAccessModifier(),
+                getReturnType(), unmodifiableParams, isFinal(), isAbstract, isStatic());
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + Objects.hashCode(getName());
+        result = prime * result + Objects.hashCode(parameters);
+        result = prime * result + Objects.hashCode(getReturnType());
+        return result;
+    }
+
+    @Override
+    public boolean equals(final Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null) {
+            return false;
+        }
+        if (getClass() != obj.getClass()) {
+            return false;
+        }
+        MethodSignatureBuilderImpl other = (MethodSignatureBuilderImpl) obj;
+        if (!Objects.equals(getName(), other.getName())) {
+            return false;
+        }
+        if (!Objects.equals(parameters, other.parameters)) {
+            return false;
+        }
+        if (!Objects.equals(getReturnType(), other.getReturnType())) {
+            return false;
+        }
+        return true;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder builder = new StringBuilder();
+        builder.append("MethodSignatureBuilderImpl [name=");
+        builder.append(getName());
+        builder.append(", returnType=");
+        builder.append(getReturnType());
+        builder.append(", parameters=");
+        builder.append(parameters);
+        builder.append(", annotationBuilders=");
+        builder.append(getAnnotationBuilders());
+        builder.append(", comment=");
+        builder.append(getComment());
+        builder.append("]");
+        return builder.toString();
+    }
+}
diff --git a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/MethodSignatureImpl.java b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/MethodSignatureImpl.java
new file mode 100644 (file)
index 0000000..886b9d0
--- /dev/null
@@ -0,0 +1,100 @@
+/*
+ * 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.mdsal.binding.generator.util.generated.type.builder;
+
+import java.util.List;
+import java.util.Objects;
+import org.opendaylight.mdsal.binding.model.api.AccessModifier;
+import org.opendaylight.mdsal.binding.model.api.AnnotationType;
+import org.opendaylight.mdsal.binding.model.api.MethodSignature;
+import org.opendaylight.mdsal.binding.model.api.Type;
+
+class MethodSignatureImpl extends AbstractTypeMember implements MethodSignature {
+
+    private final List<Parameter> params;
+    private final boolean isAbstract;
+
+    public MethodSignatureImpl(final Type definingType, final String name,
+            final List<AnnotationType> annotations,
+            final String comment, final AccessModifier accessModifier,
+            final Type returnType, final List<Parameter> params, final boolean isFinal,
+            final boolean isAbstract, final boolean isStatic) {
+        super(definingType, name, annotations, comment, accessModifier, returnType, isFinal, isStatic);
+        this.params = params;
+        this.isAbstract = isAbstract;
+    }
+
+    @Override
+    public boolean isAbstract() {
+        return isAbstract;
+    }
+
+    @Override
+    public List<Parameter> getParameters() {
+        return params;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + Objects.hashCode(getName());
+        result = prime * result + Objects.hashCode(params);
+        result = prime * result + Objects.hashCode(getReturnType());
+        return result;
+    }
+
+    @Override
+    public boolean equals(final Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null) {
+            return false;
+        }
+        if (getClass() != obj.getClass()) {
+            return false;
+        }
+        MethodSignatureImpl other = (MethodSignatureImpl) obj;
+        if (!Objects.equals(getName(), other.getName())) {
+            return false;
+        }
+        if (!Objects.equals(params, other.params)) {
+            return false;
+        }
+        if (!Objects.equals(getReturnType(), other.getReturnType())) {
+            return false;
+        }
+        return true;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder builder = new StringBuilder();
+        builder.append("MethodSignatureImpl [name=");
+        builder.append(getName());
+        builder.append(", comment=");
+        builder.append(getComment());
+        if (getDefiningType() != null) {
+            builder.append(", definingType=");
+            builder.append(getDefiningType().getPackageName());
+            builder.append(".");
+            builder.append(getDefiningType().getName());
+        } else {
+            builder.append(", definingType= null");
+        }
+        builder.append(", returnType=");
+        builder.append(getReturnType());
+        builder.append(", params=");
+        builder.append(params);
+        builder.append(", annotations=");
+        builder.append(getAnnotations());
+        builder.append("]");
+        return builder.toString();
+    }
+}
diff --git a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/package-info.java b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/package-info.java
new file mode 100644 (file)
index 0000000..f15bfa5
--- /dev/null
@@ -0,0 +1,8 @@
+/*
+ * 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.mdsal.binding.generator.util;
\ No newline at end of file
index 0f33815408b4ed312e2922ceb3818699a430b49f..f8cf91463ba0254bfcd8da8613e547368d6c6334 100644 (file)
@@ -13,7 +13,9 @@ import org.opendaylight.yangtools.sal.binding.model.api.Type;
 /**
  * It is used only as ancestor for other <code>Type</code>s
  *
+ * @deprecated Use {@link org.opendaylight.mdsal.binding.generator.util.AbstractBaseType} instead.
  */
+@Deprecated
 public class AbstractBaseType implements Type {
 
     /**
index 6ce7dc1c7f85f4abbf3ece1417c7b61145ad9125..6df9cdd7825c646a8e8dd04d8ce63950c518212f 100644 (file)
@@ -50,8 +50,9 @@ import org.opendaylight.yangtools.yang.model.util.type.DecimalTypeBuilder;
  * Contains the methods for converting strings to valid JAVA language strings
  * (package names, class names, attribute names) and to valid javadoc comments.
  *
- *
+ * @deprecated Use {@link org.opendaylight.mdsal.binding.generator.util.BindingGeneratorUtil} instead.
  */
+@Deprecated
 public final class BindingGeneratorUtil {
 
     /**
@@ -216,6 +217,8 @@ public final class BindingGeneratorUtil {
      * @param schemaPath
      *            list of names of YANG nodes which are parents of some node +
      *            name of this node
+     * @param isUsesAugment
+     *            boolean true if using augment
      * @return string with valid JAVA package name
      *
      * @deprecated Use {@link #packageNameForGeneratedType(String, SchemaPath)} or
index eb310b627f0d40f09ba0cf0fd014d7d0742b4136..531825c4cb8eb85159641d7f519aeac78a8a6d83 100644 (file)
@@ -26,6 +26,10 @@ import org.opendaylight.yangtools.yang.binding.Notification;
 import org.opendaylight.yangtools.yang.binding.NotificationListener;
 import org.opendaylight.yangtools.yang.binding.RpcService;
 
+/**
+* @deprecated Use {@link org.opendaylight.mdsal.binding.generator.util.BindingTypes} instead.
+*/
+@Deprecated
 public final class BindingTypes {
 
     public static final ConcreteType AUGMENTABLE = typeForClass(Augmentable.class);
index c3c48d850fc2450ccc9c98a69dc830d20fcb0d25..c0f913f77cc79fb83b0557f400d29746abf1a6f3 100644 (file)
@@ -8,16 +8,18 @@
 package org.opendaylight.yangtools.binding.generator.util;
 
 /**
- * 
+ *
  * Wraps combination of <code>packageName</code> and <code>name</code> to the
  * object representation
- * 
+ *
+ * @deprecated Use {@link org.opendaylight.mdsal.binding.generator.util.ReferencedTypeImpl} instead.
  */
+@Deprecated
 public final class ReferencedTypeImpl extends AbstractBaseType {
 
     /**
      * Creates instance of this class with concrete package name and type name
-     * 
+     *
      * @param packageName
      *            string with the package name
      * @param name
index d5982be345b5fdac29c36aadff94ffd0b90da8b7..02dbd492ded498f97fb55c4235261b6cb0bf3d13 100644 (file)
@@ -8,9 +8,12 @@
 package org.opendaylight.yangtools.binding.generator.util;
 
 /**
- * 
+ *
  * Contains constants used in relations with <code>Type</code>.
+ *
+ * @deprecated Use {@link org.opendaylight.mdsal.binding.generator.util.TypeConstants} instead.
  */
+@Deprecated
 public final class TypeConstants {
 
     /**
index da3531aa2a9e4a0e0499d4e4d9cb079b7a14d1b0..a9014bc88e22e57e1c948be1801a8110d1e3e7fa 100644 (file)
@@ -34,6 +34,10 @@ import org.opendaylight.yangtools.yang.model.api.type.PatternConstraint;
 import org.opendaylight.yangtools.yang.model.api.type.RangeConstraint;
 import org.opendaylight.yangtools.yang.model.util.BaseConstraints;
 
+/**
+ * @deprecated Use {@link org.opendaylight.mdsal.binding.generator.util.Types} instead.
+ */
+@Deprecated
 public final class Types {
     private static final CacheLoader<Class<?>, ConcreteType> TYPE_LOADER =
             new CacheLoader<Class<?>, ConcreteType>() {
@@ -84,6 +88,8 @@ public final class Types {
      * @param primitiveType
      *            string containing programmatic construction based on
      *            primitive type (e.g byte[])
+     * @param restrictions
+     *            restrictions object
      * @return <code>ConcreteType</code> instance which represents programmatic
      *         construction with primitive JAVA type
      */
index a2bc6da9394ea0b0265313bcd9dcf38a8609f7a4..950198a689c6ae447bbe8bf1bccd2d00e0d1a2a5 100644 (file)
@@ -26,6 +26,10 @@ import org.opendaylight.yangtools.sal.binding.model.api.type.builder.GeneratedTO
 import org.opendaylight.yangtools.sal.binding.model.api.type.builder.GeneratedTypeBuilder;
 import org.opendaylight.yangtools.sal.binding.model.api.type.builder.MethodSignatureBuilder;
 
+/**
+ * @deprecated Use {@link org.opendaylight.mdsal.binding.generator.util.generated.type.builder.AbstractGeneratedType} instead.
+ */
+@Deprecated
 abstract class AbstractGeneratedType extends AbstractBaseType implements GeneratedType {
 
     private final Type parent;
index e4fc107a98d9446212776d6f1c4ba77c6ccbdc49..904848c645b5f1d6fdc88d58e677a523d3795ecf 100644 (file)
@@ -24,6 +24,10 @@ import org.opendaylight.yangtools.sal.binding.model.api.type.builder.GeneratedTy
 import org.opendaylight.yangtools.sal.binding.model.api.type.builder.MethodSignatureBuilder;
 import org.opendaylight.yangtools.util.LazyCollections;
 
+/**
+ * @deprecated Use {org.opendaylight.mdsal.binding.generator.util.generated.type.builder.AbstractGeneratedTypeBuilder} instead.
+ */
+@Deprecated
 abstract class AbstractGeneratedTypeBuilder<T extends GeneratedTypeBuilderBase<T>> extends AbstractBaseType implements GeneratedTypeBuilderBase<T> {
 
     private List<AnnotationTypeBuilder> annotationBuilders = Collections.emptyList();
index 0cb81701ef50b6b47c8aa079090809cd0ddde797..16bdf2e1dae8ce9274ce04e181f81dd3d36bfdb0 100644 (file)
@@ -14,6 +14,10 @@ import org.opendaylight.yangtools.sal.binding.model.api.AnnotationType;
 import org.opendaylight.yangtools.sal.binding.model.api.Type;
 import org.opendaylight.yangtools.sal.binding.model.api.TypeMember;
 
+/**
+ * @deprecated Use {@link org.opendaylight.mdsal.binding.generator.util.generated.type.builder.AbstractTypeMember} instead.
+ */
+@Deprecated
 abstract class AbstractTypeMember implements TypeMember {
 
     private final String name;
index 58451825d885a180750029eb9295823f13bb8cc7..ffe9f93f266450d4b9dc10ab8d2ed65098eead42 100644 (file)
@@ -20,6 +20,10 @@ import org.opendaylight.yangtools.sal.binding.model.api.type.builder.AnnotationT
 import org.opendaylight.yangtools.sal.binding.model.api.type.builder.TypeMemberBuilder;
 import org.opendaylight.yangtools.util.LazyCollections;
 
+/**
+ * @deprecated Use {org.opendaylight.mdsal.binding.generator.util.generated.type.builder.AbstractTypeMemberBuilder} instead.
+ */
+@Deprecated
 abstract class AbstractTypeMemberBuilder<T extends TypeMemberBuilder<T>> implements TypeMemberBuilder<T> {
     private final String name;
     private Type returnType;
index 04c2b8840134ab1b01ba864e4bc4021d6a01e926..d299c464a6bf350b08c6d7d571d8085cfc0b138a 100644 (file)
@@ -17,6 +17,10 @@ import org.opendaylight.yangtools.sal.binding.model.api.AnnotationType;
 import org.opendaylight.yangtools.sal.binding.model.api.type.builder.AnnotationTypeBuilder;
 import org.opendaylight.yangtools.util.LazyCollections;
 
+/**
+ * @deprecated Use {@link org.opendaylight.mdsal.binding.generator.util.generated.type.builder.AnnotationTypeBuilderImpl} instead.
+ */
+@Deprecated
 final class AnnotationTypeBuilderImpl extends AbstractBaseType implements AnnotationTypeBuilder {
 
     private final String packageName;
index 920d4eb9ac6182f24f33700d1a6abef01f4f6b4f..a9dbe11e9d40bdfaeb99277f0909b2c4ff51dd72 100644 (file)
@@ -11,6 +11,10 @@ import java.util.Objects;
 import org.opendaylight.yangtools.sal.binding.model.api.Constant;
 import org.opendaylight.yangtools.sal.binding.model.api.Type;
 
+/**
+ * @deprecated Use {@link org.opendaylight.mdsal.binding.generator.util.generated.type.builder.ConstantImpl} instead.
+ */
+@Deprecated
 final class ConstantImpl implements Constant {
 
     private final Type definingType;
index 198d938e2dbb5cc09d81c26755dd15eb2f1020f6..a0cb98a3a2ee6e0194b44c559feacf87343c3db7 100644 (file)
@@ -30,6 +30,10 @@ import org.opendaylight.yangtools.yang.model.api.Status;
 import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition.EnumPair;
 
+/**
+ * @deprecated Use {@link org.opendaylight.mdsal.binding.generator.util.generated.type.builder.EnumerationBuilderImpl} instead.
+ */
+@Deprecated
 public final class EnumerationBuilderImpl extends AbstractBaseType implements EnumBuilder {
     private final String packageName;
     private final String name;
index e4c80190078e0c1d0a7d25ad2079207f95cecfa0..764d635187b032f3c991abc154408b356c1000c7 100644 (file)
@@ -14,6 +14,10 @@ import org.opendaylight.yangtools.sal.binding.model.api.GeneratedProperty;
 import org.opendaylight.yangtools.sal.binding.model.api.Type;
 import org.opendaylight.yangtools.sal.binding.model.api.type.builder.GeneratedPropertyBuilder;
 
+/**
+ * @deprecated Use {@link org.opendaylight.mdsal.binding.generator.util.generated.type.builder.GeneratedPropertyBuilderImpl} instead.
+ */
+@Deprecated
 public final class GeneratedPropertyBuilderImpl extends AbstractTypeMemberBuilder<GeneratedPropertyBuilder> implements GeneratedPropertyBuilder {
     private String value;
     private boolean isReadOnly;
index 2abe75c7d1d29f27ca340466c570947438addbd9..10885693bb147572066e090f68b0e6b788c2db33 100644 (file)
@@ -14,6 +14,10 @@ import org.opendaylight.yangtools.sal.binding.model.api.AnnotationType;
 import org.opendaylight.yangtools.sal.binding.model.api.GeneratedProperty;
 import org.opendaylight.yangtools.sal.binding.model.api.Type;
 
+/**
+ * @deprecated Use {@link org.opendaylight.mdsal.binding.generator.util.generated.type.builder.GeneratedPropertyImpl} instead.
+ */
+@Deprecated
 final class GeneratedPropertyImpl extends AbstractTypeMember implements GeneratedProperty {
     private String value;
     private boolean isReadOnly;
index c340d927dc612f7b9265d82ebb8ecb726dfc97dc..2129f14e88f13992c04ca66b0e954acdf6dd5f21 100644 (file)
@@ -22,6 +22,10 @@ import org.opendaylight.yangtools.util.LazyCollections;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 
+/**
+ * @deprecated Use {@link org.opendaylight.mdsal.binding.generator.util.generated.type.builder.GeneratedTOBuilderImpl} instead.
+ */
+@Deprecated
 public final class GeneratedTOBuilderImpl extends AbstractGeneratedTypeBuilder<GeneratedTOBuilder> implements GeneratedTOBuilder {
 
     private GeneratedTransferObject extendsType;
index 92c5629eab8861674bb2532957d4ab0bb9239256..6dfe20a1a10260996312e9017e4f8e16f356b084 100644 (file)
@@ -11,6 +11,10 @@ import org.opendaylight.yangtools.sal.binding.model.api.GeneratedType;
 import org.opendaylight.yangtools.sal.binding.model.api.type.builder.GeneratedTypeBuilder;
 import org.opendaylight.yangtools.yang.common.QName;
 
+/**
+ * @deprecated Use {@link org.opendaylight.mdsal.binding.generator.util.generated.type.builder.GeneratedTypeBuilderImpl} instead.
+ */
+@Deprecated
 public final class GeneratedTypeBuilderImpl extends AbstractGeneratedTypeBuilder<GeneratedTypeBuilder> implements
         GeneratedTypeBuilder {
 
index 4ca84acadb29e83003e69312ffe89483778608d4..ca91f943b06c299bc7467688d046175975125918 100644 (file)
@@ -11,6 +11,10 @@ import java.util.Objects;
 import org.opendaylight.yangtools.sal.binding.model.api.MethodSignature.Parameter;
 import org.opendaylight.yangtools.sal.binding.model.api.Type;
 
+/**
+ * @deprecated Use {@link org.opendaylight.mdsal.binding.generator.util.generated.type.builder.MethodParameterImpl} instead.
+ */
+@Deprecated
 final class MethodParameterImpl implements Parameter {
 
     private final String name;
index ca711fd9d679ce18b98b79eb61e85addd34c24d9..d73b52b5adf333b4853d789e6733b0fb94ed0cfd 100644 (file)
@@ -16,6 +16,10 @@ import org.opendaylight.yangtools.sal.binding.model.api.Type;
 import org.opendaylight.yangtools.sal.binding.model.api.type.builder.MethodSignatureBuilder;
 import org.opendaylight.yangtools.util.LazyCollections;
 
+/**
+ * @deprecated Use {@link org.opendaylight.mdsal.binding.generator.util.generated.type.builder.MethodSignatureBuilderImpl} instead.
+ */
+@Deprecated
 final class MethodSignatureBuilderImpl extends AbstractTypeMemberBuilder<MethodSignatureBuilder> implements MethodSignatureBuilder {
 
     private List<MethodSignature.Parameter> parameters = Collections.emptyList();
index 2b3c5fc339bd17239f8bc5ce47ec20aaabe9e46b..184132946b8cfc91406c0538d6ce973d20c2275c 100644 (file)
@@ -14,6 +14,10 @@ import org.opendaylight.yangtools.sal.binding.model.api.AnnotationType;
 import org.opendaylight.yangtools.sal.binding.model.api.MethodSignature;
 import org.opendaylight.yangtools.sal.binding.model.api.Type;
 
+/**
+ * @deprecated Use {@link org.opendaylight.mdsal.binding.generator.util.generated.type.builder.MethodSignatureImpl} instead.
+ */
+@Deprecated
 class MethodSignatureImpl extends AbstractTypeMember implements MethodSignature {
 
     private final List<Parameter> params;