From: Jie Han Date: Fri, 20 Oct 2017 02:09:21 +0000 (+0800) Subject: Fix checkstyle in mdsal-binding2-generator-util X-Git-Tag: v3.0.0~19 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;ds=sidebyside;h=7ef19ce5ce81746ffd3dac9a96c789250a90dab3;p=mdsal.git Fix checkstyle in mdsal-binding2-generator-util - Fix checkstyle issues and activate enforcement. Change-Id: I5e83540c54650f899afa9e711d17f4c3efb2e9f0 Signed-off-by: Jie Han --- diff --git a/binding2/mdsal-binding2-generator-util/pom.xml b/binding2/mdsal-binding2-generator-util/pom.xml index 7d083dbbac..26c71c812c 100644 --- a/binding2/mdsal-binding2-generator-util/pom.xml +++ b/binding2/mdsal-binding2-generator-util/pom.xml @@ -67,13 +67,22 @@ yang-parser-impl test - - junit - junit - org.apache.commons commons-lang3 + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + + checkstyle.violationSeverity=error + + + + + diff --git a/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/AbstractBaseType.java b/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/AbstractBaseType.java index de719fee4a..f12b041345 100644 --- a/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/AbstractBaseType.java +++ b/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/AbstractBaseType.java @@ -15,7 +15,7 @@ import org.opendaylight.mdsal.binding.javav2.generator.context.ModuleContext; import org.opendaylight.mdsal.binding.javav2.model.api.Type; /** - * This class represents ancestor for other Types + * This class represents ancestor for other Types. */ @Beta public abstract class AbstractBaseType implements Type { @@ -40,12 +40,12 @@ public abstract class AbstractBaseType implements Type { * @param name * string with the name for this Type */ - protected AbstractBaseType(final String pkName, final String name, ModuleContext context) { + protected AbstractBaseType(final String pkName, final String name, final ModuleContext context) { Preconditions.checkNotNull(pkName, "Package Name for Generated Type cannot be null!"); Preconditions.checkNotNull(name, "Name of Generated Type cannot be null!"); this.packageName = JavaIdentifierNormalizer.normalizeFullPackageName(pkName); - Preconditions.checkNotNull(context, "In case of not having identifiers normalized, " + - "ModuleContext instance must be provided."); + Preconditions.checkNotNull(context, + "In case of not having identifiers normalized, ModuleContext instance must be provided."); this.name = JavaIdentifierNormalizer.normalizeClassIdentifier(pkName, name, context); } @@ -62,7 +62,7 @@ public abstract class AbstractBaseType implements Type { * true if pkName and name are normalized */ protected AbstractBaseType(final String pkName, final String name, final boolean isNormalized, - ModuleContext context) { + final ModuleContext context) { Preconditions.checkNotNull(pkName, "Package Name for Generated Type cannot be null!"); Preconditions.checkNotNull(name, "Name of Generated Type cannot be null!"); if (isNormalized) { @@ -70,14 +70,14 @@ public abstract class AbstractBaseType implements Type { this.name = name; } else { this.packageName = JavaIdentifierNormalizer.normalizeFullPackageName(pkName); - Preconditions.checkNotNull(context, "In case of not having identifiers normalized, " + - "ModuleContext instance must be provided."); + Preconditions.checkNotNull(context, + "In case of not having identifiers normalized, ModuleContext instance must be provided."); this.name = JavaIdentifierNormalizer.normalizeClassIdentifier(pkName, name, context); } } protected AbstractBaseType(final String pkName, final String name, final boolean isPkNameNormalized, - final boolean isTypeNormalized, ModuleContext context ) { + final boolean isTypeNormalized, final ModuleContext context) { Preconditions.checkNotNull(pkName, "Package Name for Generated Type cannot be null!"); Preconditions.checkNotNull(name, "Name of Generated Type cannot be null!"); if (isPkNameNormalized) { @@ -89,8 +89,8 @@ public abstract class AbstractBaseType implements Type { if (isTypeNormalized) { this.name = name; } else { - Preconditions.checkNotNull(context, "In case of not having identifiers normalized, " + - "ModuleContext instance must be provided."); + Preconditions.checkNotNull(context, + "In case of not having identifiers normalized ModuleContext instance must be provided."); this.name = JavaIdentifierNormalizer.normalizeClassIdentifier(pkName, name, context); } } diff --git a/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/BindingGeneratorUtil.java b/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/BindingGeneratorUtil.java index 1c3a6d5960..10e59a980c 100644 --- a/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/BindingGeneratorUtil.java +++ b/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/BindingGeneratorUtil.java @@ -99,7 +99,7 @@ public final class BindingGeneratorUtil { } /** - * Encodes angle brackets in yang statement description + * 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 */ @@ -114,7 +114,7 @@ public final class BindingGeneratorUtil { public static long computeDefaultSUID(final GeneratedTypeBuilderBase to) { final ByteArrayOutputStream bout = new ByteArrayOutputStream(); - try (final DataOutputStream dout = new DataOutputStream(bout)) { + try (DataOutputStream dout = new DataOutputStream(bout)) { dout.writeUTF(to.getName()); dout.writeInt(to.isAbstract() ? 3 : 7); @@ -150,10 +150,12 @@ public final class BindingGeneratorUtil { * Creates package name from specified basePackageName (package * name for module) and schemaPath. * + *

* Resulting package name is concatenation of basePackageName * and all local names of YANG nodes which are parents of some node for * which schemaPath is specified. * + *

* Based on type of node, there is also possible suffix added in order * to prevent package name conflicts. * @@ -175,9 +177,7 @@ public final class BindingGeneratorUtil { if (size <= 0) { if (namespaceType != null) { final StringBuilder sb = new StringBuilder(); - sb.append(basePackageName) - .append('.') - .append(namespaceType.getPackagePrefix()); + sb.append(basePackageName).append('.').append(namespaceType.getPackagePrefix()); return JavaIdentifierNormalizer.normalizeFullPackageName(sb.toString()); } return JavaIdentifierNormalizer.normalizeFullPackageName(basePackageName); @@ -190,6 +190,7 @@ public final class BindingGeneratorUtil { * Creates package name from specified basePackageName (package * name for module) and namespaceType. * + *

* Resulting package name is concatenation of basePackageName * and prefix of namespaceType. * @@ -316,14 +317,17 @@ public final class BindingGeneratorUtil { public Optional> getRangeConstraint() { return range; } + @Override public List getPatternConstraints() { return pattern; } + @Override public Optional getLengthConstraint() { return length; } + @Override public boolean isEmpty() { return false; @@ -335,10 +339,12 @@ public final class BindingGeneratorUtil { * Creates package name from specified basePackageName (package * name for module) and schemaPath which crosses an augmentation. * + *

* Resulting package name is concatenation of basePackageName * and all local names of YANG nodes which are parents of some node for * which schemaPath is specified. * + *

* Based on type of node, there is also possible suffix added in order * to prevent package name conflicts. * @@ -351,7 +357,8 @@ public final class BindingGeneratorUtil { * @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) { + public static String packageNameForAugmentedGeneratedType(final String basePackageName, + final SchemaPath schemaPath) { final Iterable pathTowardsRoot = schemaPath.getPathTowardsRoot(); final Iterable pathFromRoot = schemaPath.getPathFromRoot(); final int size = Iterables.size(pathTowardsRoot); @@ -366,9 +373,11 @@ public final class BindingGeneratorUtil { * Creates package name from parentAugmentPackageName (package * name for direct parent augmentation) and augmentationSchema . * + *

* Resulting package name is concatenation of parentAugmentPackageName * and the local name of schemaPath. * + *

* Based on type of node, there is also possible suffix added in order * to prevent package name conflicts. * @@ -511,7 +520,7 @@ public final class BindingGeneratorUtil { return def.getRangeConstraint(); } - public static String replaceAllIllegalChars(final CharSequence stringBuilder){ + public static String replaceAllIllegalChars(final CharSequence stringBuilder) { final String ret = UNICODE_CHAR_PATTERN.matcher(stringBuilder).replaceAll("\\\\\\\\u"); return ret.isEmpty() ? "" : ret; } diff --git a/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/BindingTypes.java b/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/BindingTypes.java index c10619650e..756b56e2aa 100644 --- a/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/BindingTypes.java +++ b/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/BindingTypes.java @@ -32,8 +32,8 @@ import org.opendaylight.mdsal.binding.javav2.spec.runtime.NotificationListener; import org.opendaylight.mdsal.binding.javav2.spec.structural.Augmentable; import org.opendaylight.mdsal.binding.javav2.spec.structural.Augmentation; import org.opendaylight.mdsal.binding.javav2.spec.structural.TreeChildNode; -import org.opendaylight.yangtools.concepts.Identifier; import org.opendaylight.yangtools.concepts.Identifiable; +import org.opendaylight.yangtools.concepts.Identifier; public final class BindingTypes { @@ -62,7 +62,7 @@ public final class BindingTypes { throw new UnsupportedOperationException("Utility class"); } - public static ParameterizedType augmentable(Type t) { - return parameterizedTypeFor(AUGMENTABLE, t); + public static ParameterizedType augmentable(Type type) { + return parameterizedTypeFor(AUGMENTABLE, type); } } diff --git a/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/FormattingUtils.java b/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/FormattingUtils.java index 440f27085c..3045f8664f 100644 --- a/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/FormattingUtils.java +++ b/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/FormattingUtils.java @@ -17,7 +17,7 @@ import javax.annotation.RegEx; import org.opendaylight.yangtools.yang.common.QName; /** - * Util class + * Util class. */ @Beta public final class FormattingUtils { @@ -48,7 +48,7 @@ public final class FormattingUtils { } /** - * Used in #yangtemplateformodule.scala.txt for formating revision description + * Used in #yangtemplateformodule.scala.txt for formating revision description. * * @param text Content of tag description * @param nextLineIndent Number of spaces from left side default is 12 @@ -99,7 +99,7 @@ public final class FormattingUtils { } /** - * Used in all yangtemplates for formating augmentation target + * Used in all yangtemplates for formating augmentation target. * * @param schemaPath path to augmented node * @return path in string format diff --git a/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/JavaIdentifier.java b/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/JavaIdentifier.java index d1933db21d..06d6d05abe 100644 --- a/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/JavaIdentifier.java +++ b/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/JavaIdentifier.java @@ -20,7 +20,7 @@ import com.google.common.annotations.Beta; *

  • variable
  • *
  • constant
  • *
  • package
  • - * + * . */ @Beta public enum JavaIdentifier { diff --git a/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/JavaIdentifierNormalizer.java b/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/JavaIdentifierNormalizer.java index ea090f72db..714807bd83 100644 --- a/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/JavaIdentifierNormalizer.java +++ b/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/JavaIdentifierNormalizer.java @@ -122,6 +122,7 @@ import org.opendaylight.mdsal.binding.javav2.util.BindingMapping; * * * + *

    * There is special case in CLASS, INTERFACE, ENUM, ENUM VALUE, CONSTANT, METHOD * and VARIABLE if identifier contains single dash - then the converter ignores * the single dash in the way of the non-java chars. In other way, if dash is @@ -158,6 +159,7 @@ import org.opendaylight.mdsal.binding.javav2.util.BindingMapping; * * * + *

    * Next special case talks about normalizing class name which already exists in * package - but with different camel cases (foo, Foo, fOo, ...). To every next * classes with same names will by added their actual rank (serial number), @@ -245,6 +247,7 @@ public final class JavaIdentifierNormalizer { * } * * + *

    * YANG enum values will be mapped to 'FOO' and 'FOO_1' Java enum values. * * @param name @@ -361,6 +364,39 @@ public final class JavaIdentifierNormalizer { return normalizeClassIdentifier(basePackageName, convertedClassName, convertedClassName, 1, context); } + /** + * Checking while there doesn't exist any class name with the same name + * (regardless of camel cases) in package. + * + * @param packageName + * - package of class name + * @param origClassName + * - original class name + * @param actualClassName + * - actual class name with rank (serial number) + * @param rank + * - actual rank (serial number) + * @return converted identifier + */ + private static String normalizeClassIdentifier(final String packageName, final String origClassName, + final String actualClassName, final int rank, final ModuleContext context) { + + final ListMultimap packagesMap = context.getPackagesMap(); + + synchronized (packagesMap) { + if (packagesMap.containsKey(packageName)) { + for (final String existingName : packagesMap.get(packageName)) { + if (actualClassName.equalsIgnoreCase(existingName)) { + return normalizeClassIdentifier(packageName, origClassName, origClassName + rank, + rank + 1, context); + } + } + } + context.putToPackagesMap(packageName, actualClassName); + return actualClassName; + } + } + /** * Find and convert non Java chars in identifiers of generated transfer objects, initially * derived from corresponding YANG. @@ -413,40 +449,7 @@ public final class JavaIdentifierNormalizer { } /** - * Checking while there doesn't exist any class name with the same name - * (regardless of camel cases) in package. - * - * @param packageName - * - package of class name - * @param origClassName - * - original class name - * @param actualClassName - * - actual class name with rank (serial number) - * @param rank - * - actual rank (serial number) - * @return converted identifier - */ - private static String normalizeClassIdentifier(final String packageName, final String origClassName, - final String actualClassName, final int rank, final ModuleContext context) { - - final ListMultimap packagesMap = context.getPackagesMap(); - - synchronized (packagesMap) { - if (packagesMap.containsKey(packageName)) { - for (final String existingName : packagesMap.get(packageName)) { - if (actualClassName.equalsIgnoreCase(existingName)) { - return normalizeClassIdentifier(packageName, origClassName, origClassName + rank, - rank + 1, context); - } - } - } - context.putToPackagesMap(packageName, actualClassName); - return actualClassName; - } - } - - /** - * Fix cases of converted identifiers by Java type + * Fix cases of converted identifiers by Java type. * * @param convertedIdentifier * - converted identifier @@ -495,7 +498,7 @@ public final class JavaIdentifierNormalizer { } /** - * Check if there exist next char in identifier behind actual char position + * Check if there exist next char in identifier behind actual char position. * * @param identifier * - original identifier @@ -509,24 +512,24 @@ public final class JavaIdentifierNormalizer { /** * Converting first char of identifier. This happen only if this char is - * non-java char + * non-java char. * - * @param c + * @param firstChar * - first char * @param existNext * - existing of next char behind actual char * @return converted char */ - private static String convertFirst(final char c, final boolean existNext) { - final String name = DASH_OR_SPACE_MATCHER.replaceFrom(Character.getName(c), UNDERSCORE); + private static String convertFirst(final char firstChar, final boolean existNext) { + final String name = DASH_OR_SPACE_MATCHER.replaceFrom(Character.getName(firstChar), UNDERSCORE); return existNext ? name + '_' : name; } /** * Converting any char in java identifier, This happen only if this char is - * non-java char + * non-java char. * - * @param c + * @param actualChar * - actual char * @param existNext * - existing of next char behind actual char @@ -534,12 +537,12 @@ public final class JavaIdentifierNormalizer { * - last char of partial converted identifier * @return converted char */ - private static String convert(final char c, final boolean existNext, final char partialLastChar) { - return partialLastChar == '_' ? convertFirst(c, existNext) : "_" + convertFirst(c, existNext); + private static String convert(final char actualChar, final boolean existNext, final char partialLastChar) { + return partialLastChar == '_' ? convertFirst(actualChar, existNext) : "_" + convertFirst(actualChar, existNext); } /** - * Capitalize input string + * Capitalize input string. * * @param identifier * - string to be capitalized diff --git a/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/ReferencedTypeImpl.java b/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/ReferencedTypeImpl.java index 66fb631dd0..2a326a46f8 100644 --- a/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/ReferencedTypeImpl.java +++ b/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/ReferencedTypeImpl.java @@ -11,15 +11,14 @@ package org.opendaylight.mdsal.binding.javav2.generator.util; import org.opendaylight.mdsal.binding.javav2.generator.context.ModuleContext; /** - * * Wraps combination of packageName and name to the - * object representation + * object representation. * */ public final class ReferencedTypeImpl extends AbstractBaseType { /** - * Creates instance of this class with concrete package name and type name + * Creates instance of this class with concrete package name and type name. * * @param packageName * string with the package name @@ -32,7 +31,7 @@ public final class ReferencedTypeImpl extends AbstractBaseType { /** * Creates instance of this class with concrete package name and type name - * for already normalized identifier + * for already normalized identifier. * * @param packageName * string with the package name diff --git a/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/TypeComments.java b/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/TypeComments.java index 0bf2f9a569..9543ea5646 100644 --- a/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/TypeComments.java +++ b/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/TypeComments.java @@ -32,6 +32,10 @@ public final class TypeComments { .addEscape('@', "@").build(); private static final Pattern TAIL_COMMENT_PATTERN = Pattern.compile("*/", Pattern.LITERAL); + private TypeComments() { + //Defeat initialization. + } + /** * Create a {@link TypeComment} for a javadoc-compliant text snippet. This snippet must be eligible for direct * inclusion in a Java comment without further escaping. diff --git a/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/Types.java b/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/Types.java index a51ece91af..33f9aa5742 100644 --- a/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/Types.java +++ b/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/Types.java @@ -20,12 +20,14 @@ import com.google.common.collect.ImmutableRangeSet; import com.google.common.collect.Iterables; import com.google.common.collect.Range; import com.google.common.collect.RangeSet; + import java.util.List; import java.util.Map; import java.util.Optional; import java.util.Set; import javax.annotation.Nonnull; import javax.annotation.Nullable; + import org.opendaylight.mdsal.binding.javav2.generator.context.ModuleContext; import org.opendaylight.mdsal.binding.javav2.model.api.BaseTypeWithRestrictions; import org.opendaylight.mdsal.binding.javav2.model.api.ConcreteType; @@ -43,13 +45,13 @@ import org.w3c.dom.Document; @Beta public final class Types { private static final CacheLoader, ConcreteType> TYPE_LOADER = - new CacheLoader, ConcreteType>() { + new CacheLoader, ConcreteType>() { - @Override - public ConcreteType load(@Nonnull final Class key) throws Exception { - return new ConcreteTypeImpl(key.getPackage().getName(), key.getSimpleName(), null); - } - }; + @Override + public ConcreteType load(@Nonnull final Class key) throws Exception { + return new ConcreteTypeImpl(key.getPackage().getName(), key.getSimpleName(), null); + } + }; private static final LoadingCache, ConcreteType> TYPE_CACHE = CacheBuilder.newBuilder().weakKeys().build(TYPE_LOADER); @@ -78,7 +80,7 @@ public final class Types { * ConcreteType} which represents JAVA void type. * * @return ConcreteType instance which represents JAVA - * void + * void */ public static ConcreteType voidType() { return VOID; @@ -90,21 +92,19 @@ public final class Types { * 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 primitiveType string containing programmatic construction based on + * primitive type (e.g byte[]) * @return ConcreteType instance which represents programmatic - * construction with primitive JAVA type + * 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 + * Returns an instance of {@link ConcreteType} describing the class. * - * @param cls - * Class to describe + * @param cls Class to describe * @return Description of class */ public static ConcreteType typeForClass(final Class cls) { @@ -124,7 +124,7 @@ public final class Types { } public static ConcreteType typeForClass(final Class cls, final Restrictions restrictions, - final ModuleContext moduleContext) { + final ModuleContext moduleContext) { if (restrictions == null) { return typeForClass(cls); } @@ -132,18 +132,16 @@ public final class Types { return new ConcreteTypeImpl(cls.getPackage().getName(), cls.getSimpleName(), restrictions); } else { return new BaseTypeWithRestrictionsImpl(cls.getPackage().getName(), cls.getSimpleName(), restrictions, - moduleContext); + moduleContext); } } /** - * Returns an instance of {@link ParameterizedType} describing the typed + * Returns an instance of {@link ParameterizedType} describing the typed. * {@link Map}<K,V> * - * @param keyType - * Key Type - * @param valueType - * Value Type + * @param keyType Key Type + * @param valueType Value Type * @return Description of generic type instance */ public static ParameterizedType mapTypeFor(final Type keyType, final Type valueType) { @@ -154,8 +152,7 @@ public final class Types { * Returns an instance of {@link ParameterizedType} describing the typed * {@link Set}<V> with concrete type of value. * - * @param valueType - * Value Type + * @param valueType Value Type * @return Description of generic type instance of Set */ public static ParameterizedType setTypeFor(final Type valueType) { @@ -166,8 +163,7 @@ public final class Types { * Returns an instance of {@link ParameterizedType} describing the typed * {@link List}<V> with concrete type of value. * - * @param valueType - * Value Type + * @param valueType Value Type * @return Description of type instance of List */ public static ParameterizedType listTypeFor(final Type valueType) { @@ -175,55 +171,42 @@ public final class Types { } /** - * Creates instance of type - * {@link ParameterizedType - * ParameterizedType} + * Creates instance of type {@link ParameterizedType ParameterizedType}. * - * @param type - * JAVA Type for raw type - * @param parameters - * JAVA Types for actual parameter types + * @param type JAVA Type for raw type + * @param parameters JAVA Types for actual parameter types * @return ParametrizedType reprezentation of type - * and its parameters parameters + * and its parameters parameters */ public static ParameterizedType parameterizedTypeFor(final Type type, final Type... parameters) { return new ParameterizedTypeImpl(type, parameters); } /** - * Creates instance of type - * {@link WildcardType - * WildcardType} + * Creates instance of type {@link WildcardType WildcardType}. * - * @param packageName - * string with the package name - * @param typeName - * string with the type name + * @param packageName string with the package name + * @param typeName string with the type name * @return WildcardType representation of - * packageName and typeName + * packageName and typeName */ public static WildcardType wildcardTypeFor(final String packageName, final String typeName) { return new WildcardTypeImpl(packageName, typeName); } /** - * Creates instance of type - * {@link WildcardType - * WildcardType} + * Creates instance of type {@link WildcardType WildcardType}. * - * @param packageName - * string with the package name - * @param typeName - * string with the type name - * @param isPkNameNormalized - * if the package name has been normalized - * @param isTypeNormalized - * if the type name has been normalized + * @param packageName string with the package name + * @param typeName string with the type name + * @param isPkNameNormalized if the package name has been normalized + * @param isTypeNormalized if the type name has been normalized * @return WildcardType representation of - * packageName and typeName + * packageName and typeName */ public static WildcardType wildcardTypeFor(final String packageName, final String typeName, - final boolean isPkNameNormalized, final boolean isTypeNormalized, final ModuleContext context) { + final boolean isPkNameNormalized, final boolean isTypeNormalized, + final ModuleContext context) { return new WildcardTypeImpl(packageName, typeName, isPkNameNormalized, isTypeNormalized, context); } @@ -234,11 +217,10 @@ public final class Types { * {@link Augmentable} and actual * parameter is valueType. * - * @param valueType - * JAVA Type with actual parameter + * @param valueType JAVA Type with actual parameter * @return ParametrizedType representation of raw type - * Augmentable with actual parameter - * valueType + * Augmentable with actual parameter + * valueType */ public static ParameterizedType augmentableTypeFor(final Type valueType) { final Type augmentable = typeForClass(Augmentable.class); @@ -252,11 +234,10 @@ public final class Types { * {@link Augmentation} and actual * parameter is valueType. * - * @param valueType - * JAVA Type with actual parameter + * @param valueType JAVA Type with actual parameter * @return ParametrizedType reprezentation of raw type - * Augmentation with actual parameter - * valueType + * Augmentation with actual parameter + * valueType */ public static ParameterizedType augmentationTypeFor(final Type valueType) { final Type augmentation = typeForClass(Augmentation.class); @@ -285,9 +266,7 @@ public final class Types { } /** - * * Represents concrete JAVA type. - * */ private static final class ConcreteTypeImpl extends AbstractBaseType implements ConcreteType { @@ -297,13 +276,11 @@ public final class Types { * Creates instance of this class with package pkName and * with the type name name. * - * @param pkName - * string with package name - * @param name - * string with the name of the type + * @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, true,null); + super(pkName, name, true, null); this.restrictions = restrictions; } @@ -314,21 +291,18 @@ public final class Types { } /** - * * Represents concrete JAVA type with changed restriction values. - * */ - private static final class BaseTypeWithRestrictionsImpl extends AbstractBaseType implements BaseTypeWithRestrictions { + private static final class BaseTypeWithRestrictionsImpl extends AbstractBaseType implements + BaseTypeWithRestrictions { private final Restrictions restrictions; /** * Creates instance of this class with package pkName and * with the type name name. * - * @param pkName - * string with package name - * @param name - * string with the name of the type + * @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, null); @@ -336,7 +310,7 @@ public final class Types { } private BaseTypeWithRestrictionsImpl(final String pkName, final String name, final Restrictions restrictions, - final ModuleContext moduleContext) { + final ModuleContext moduleContext) { super(pkName, name, moduleContext); this.restrictions = Preconditions.checkNotNull(restrictions); } @@ -348,9 +322,7 @@ public final class Types { } /** - * * Represents parametrized JAVA type. - * */ private static class ParameterizedTypeImpl extends AbstractBaseType implements ParameterizedType { /** @@ -359,7 +331,7 @@ public final class Types { private final Type[] actualTypes; /** - * JAVA raw type (like List, Set, Map...) + * JAVA raw type (like List, Set, Map...). */ private final Type rawType; @@ -367,12 +339,10 @@ public final class Types { * Creates instance of this class with concrete rawType and array of * actual parameters. * - * @param rawType - * JAVA Type for raw type - * @param actTypes - * array of actual parameters + * @param rawType JAVA Type for raw type + * @param actTypes array of actual parameters */ - public ParameterizedTypeImpl(final Type rawType, final Type[] actTypes) { + ParameterizedTypeImpl(final Type rawType, final Type[] actTypes) { super(rawType.getPackageName(), rawType.getName(), true, null); this.rawType = rawType; this.actualTypes = actTypes.clone(); @@ -391,44 +361,36 @@ public final class Types { } /** - * * 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 + * @param packageName string with the package name + * @param typeName string with the name of type */ //FIXME: doesn't seem to be called at all - public WildcardTypeImpl(final String packageName, final String typeName) { + WildcardTypeImpl(final String packageName, final String typeName) { super(packageName, typeName, null); } /** * 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 - * @param isPkNameNormalized - * if the package name has been normalized - * @param isTypeNormalized - * if the type name has been normalized + * @param packageName string with the package name + * @param typeName string with the name of type + * @param isPkNameNormalized if the package name has been normalized + * @param isTypeNormalized if the type name has been normalized */ - public WildcardTypeImpl(final String packageName, final String typeName, final boolean isPkNameNormalized, - final boolean isTypeNormalized, final ModuleContext context) { + WildcardTypeImpl(final String packageName, final String typeName, final boolean isPkNameNormalized, + final boolean isTypeNormalized, final ModuleContext context) { super(packageName, typeName, isPkNameNormalized, isTypeNormalized, context); } } public static > DefaultRestrictions getDefaultRestrictions(final T min, - final T max) { + final T max) { return new DefaultRestrictions<>(min, max); } diff --git a/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/YangSnippetCleaner.java b/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/YangSnippetCleaner.java index 7b59f87a66..8f60f22bdd 100644 --- a/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/YangSnippetCleaner.java +++ b/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/YangSnippetCleaner.java @@ -13,7 +13,7 @@ import javax.annotation.RegEx; import org.apache.commons.lang3.StringUtils; /** - * Utility class for cleaning yang models of excess whitespaces + * Utility class for cleaning yang models of excess whitespaces. */ @Beta public final class YangSnippetCleaner { @@ -44,7 +44,7 @@ public final class YangSnippetCleaner { } /** - * Cleaning yang model of excess whitespaces, adding indentations + * Cleaning yang model of excess whitespaces, adding indentations. * * @param unformedYang * - unformed yang model @@ -69,7 +69,7 @@ public final class YangSnippetCleaner { indentCount = lineIndent(sb, indentCount, line); sb.append(line).append(NEW_LINE); if (!StringUtils.startsWithAny(line, RESERVED_LINES) && indentCount == 1 && i != 0) { - sb.append(NEW_LINE); + sb.append(NEW_LINE); } } } @@ -86,11 +86,11 @@ public final class YangSnippetCleaner { } private static int mergeWithPrevious(final StringBuilder sb, final int indentCount) { - int newIndentCount = indentCount; removeRemainingWhitespace(sb); sb.append(SPACE); sb.append(START_BODY); sb.append(NEW_LINE); + int newIndentCount = indentCount; return ++newIndentCount; } diff --git a/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/generated/type/builder/AbstractGeneratedType.java b/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/generated/type/builder/AbstractGeneratedType.java index fcde49fc84..b0e6b22568 100755 --- a/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/generated/type/builder/AbstractGeneratedType.java +++ b/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/generated/type/builder/AbstractGeneratedType.java @@ -10,12 +10,14 @@ package org.opendaylight.mdsal.binding.javav2.generator.util.generated.type.buil import com.google.common.annotations.Beta; import com.google.common.collect.ImmutableList; + import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Objects; import java.util.Optional; import java.util.stream.Collectors; + import org.opendaylight.mdsal.binding.javav2.generator.util.AbstractBaseType; import org.opendaylight.mdsal.binding.javav2.model.api.AnnotationType; import org.opendaylight.mdsal.binding.javav2.model.api.Constant; @@ -51,7 +53,7 @@ abstract class AbstractGeneratedType extends AbstractBaseType implements Generat private final YangSourceDefinition definition; private final BindingNamespaceType namespaceType; - public AbstractGeneratedType(final AbstractGeneratedTypeBuilder builder) { + AbstractGeneratedType(final AbstractGeneratedTypeBuilder builder) { super(builder.getPackageName(), builder.getName(), true, null); this.parent = builder.getParent(); this.parentTypeForBuilder = builder.getParentTypeForBuilder(); @@ -80,37 +82,47 @@ abstract class AbstractGeneratedType extends AbstractBaseType implements Generat } } - private static List toUnmodifiableEnclosedTypes(final List enclosedGenTypeBuilders, - final List enclosedGenTOBuilders) { - final ArrayList enclosedTypesList = new ArrayList<>(enclosedGenTypeBuilders.size() + enclosedGenTOBuilders.size()); - enclosedTypesList.addAll(enclosedGenTypeBuilders.stream().filter(Objects::nonNull).map(GeneratedTypeBuilder::toInstance).collect(Collectors.toList())); + private static List toUnmodifiableEnclosedTypes( + final List enclosedGenTypeBuilders, + final List enclosedGenTOBuilders) { + final ArrayList enclosedTypesList = new ArrayList<>(enclosedGenTypeBuilders.size() + + enclosedGenTOBuilders.size()); + enclosedTypesList.addAll(enclosedGenTypeBuilders.stream().filter(Objects::nonNull) + .map(GeneratedTypeBuilder::toInstance).collect(Collectors.toList())); - enclosedTypesList.addAll(enclosedGenTOBuilders.stream().filter(Objects::nonNull).map(GeneratedTOBuilder::toInstance).collect(Collectors.toList())); + enclosedTypesList.addAll(enclosedGenTOBuilders.stream().filter(Objects::nonNull) + .map(GeneratedTOBuilder::toInstance).collect(Collectors.toList())); return makeUnmodifiable(enclosedTypesList); } - protected static final List toUnmodifiableAnnotations(final List annotationBuilders) { + protected static final List toUnmodifiableAnnotations(final List + annotationBuilders) { final List annotationList = new ArrayList<>(annotationBuilders.size()); - annotationList.addAll(annotationBuilders.stream().map(AnnotationTypeBuilder::toInstance).collect(Collectors.toList())); + annotationList.addAll(annotationBuilders.stream().map(AnnotationTypeBuilder::toInstance).collect(Collectors + .toList())); return makeUnmodifiable(annotationList); } protected final List toUnmodifiableMethods(final List methodBuilders) { final List methods = new ArrayList<>(methodBuilders.size()); - methods.addAll(methodBuilders.stream().map(methodBuilder -> methodBuilder.toInstance(this)).collect(Collectors.toList())); + methods.addAll(methodBuilders.stream().map(methodBuilder -> methodBuilder.toInstance(this)) + .collect(Collectors.toList())); return makeUnmodifiable(methods); } protected final List toUnmodifiableEnumerations(final List enumBuilders) { final List enums = new ArrayList<>(enumBuilders.size()); - enums.addAll(enumBuilders.stream().map(enumBuilder -> enumBuilder.toInstance(this)).collect(Collectors.toList())); + enums.addAll(enumBuilders.stream().map(enumBuilder -> enumBuilder.toInstance(this)) + .collect(Collectors.toList())); return makeUnmodifiable(enums); } - protected final List toUnmodifiableProperties(final List methodBuilders) { + protected final List toUnmodifiableProperties(final List + methodBuilders) { final List methods = new ArrayList<>(methodBuilders.size()); - methods.addAll(methodBuilders.stream().map(methodBuilder -> methodBuilder.toInstance(this)).collect(Collectors.toList())); + methods.addAll(methodBuilders.stream().map(methodBuilder -> methodBuilder.toInstance(this)) + .collect(Collectors.toList())); return makeUnmodifiable(methods); } @@ -192,10 +204,10 @@ abstract class AbstractGeneratedType extends AbstractBaseType implements Generat } else { builder.append(", parent=null"); } - final TypeComment comment = getComment(); - if (comment != null) { + + if (getComment() != null) { builder.append(", comment="); - builder.append(comment.getJavadoc()); + builder.append(getComment().getJavadoc()); } builder.append(", annotations="); builder.append(this.annotations); diff --git a/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/generated/type/builder/AbstractGeneratedTypeBuilder.java b/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/generated/type/builder/AbstractGeneratedTypeBuilder.java index 569addbf50..7d7dfe46ff 100755 --- a/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/generated/type/builder/AbstractGeneratedTypeBuilder.java +++ b/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/generated/type/builder/AbstractGeneratedTypeBuilder.java @@ -11,9 +11,11 @@ package org.opendaylight.mdsal.binding.javav2.generator.util.generated.type.buil import com.google.common.annotations.Beta; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; + import java.util.List; import java.util.Objects; import java.util.Optional; + import org.opendaylight.mdsal.binding.javav2.generator.context.ModuleContext; import org.opendaylight.mdsal.binding.javav2.generator.util.AbstractBaseType; import org.opendaylight.mdsal.binding.javav2.model.api.AccessModifier; @@ -54,12 +56,12 @@ abstract class AbstractGeneratedTypeBuilder> impleme private AccessModifier accessModifier; private List annotationBuilders = ImmutableList.of(); - public AbstractTypeMemberBuilder(final String name) { + AbstractTypeMemberBuilder(final String name) { this.name = name; } @Override - public AnnotationTypeBuilder addAnnotation(final String packageName, final String name) { + public AnnotationTypeBuilder addAnnotation(final String packageName, final String typeName) { Preconditions.checkArgument(packageName != null, "Annotation Type cannot have package name null!"); - Preconditions.checkArgument(name != null, "Annotation Type cannot have name as null!"); + Preconditions.checkArgument(typeName != null, "Annotation Type cannot have name as null!"); - final AnnotationTypeBuilder builder = new AnnotationTypeBuilderImpl(packageName, name); + final AnnotationTypeBuilder builder = new AnnotationTypeBuilderImpl(packageName, typeName); annotationBuilders = LazyCollections.lazyAdd(annotationBuilders, builder); return builder; } @@ -79,9 +79,9 @@ abstract class AbstractTypeMemberBuilder> impleme } @Override - public T setReturnType(final Type returnType) { - Preconditions.checkArgument(returnType != null, "Return Type of member cannot be null!"); - this.returnType = returnType; + public T setReturnType(final Type retType) { + Preconditions.checkArgument(retType != null, "Return Type of member cannot be null!"); + this.returnType = retType; return thisInstance(); } @@ -93,23 +93,23 @@ abstract class AbstractTypeMemberBuilder> impleme } @Override - public T setComment(final String comment) { - if (comment == null) { + public T setComment(final String commentText) { + if (commentText == null) { this.comment = ""; } - this.comment = comment; + this.comment = commentText; return thisInstance(); } @Override - public T setFinal(final boolean isFinal) { - this.isFinal = isFinal; + public T setFinal(final boolean finalOrNot) { + this.isFinal = finalOrNot; return thisInstance(); } @Override - public T setStatic(final boolean isStatic) { - this.isStatic = isStatic; + public T setStatic(final boolean staticOrNot) { + this.isStatic = staticOrNot; return thisInstance(); } diff --git a/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/generated/type/builder/AnnotationTypeBuilderImpl.java b/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/generated/type/builder/AnnotationTypeBuilderImpl.java index a04b9f17ce..526437f6c4 100644 --- a/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/generated/type/builder/AnnotationTypeBuilderImpl.java +++ b/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/generated/type/builder/AnnotationTypeBuilderImpl.java @@ -28,16 +28,16 @@ final class AnnotationTypeBuilderImpl extends AbstractBaseType implements Annota private List annotationBuilders = ImmutableList.of(); private List parameters = ImmutableList.of(); - public AnnotationTypeBuilderImpl(final String packageName, final String name) { + AnnotationTypeBuilderImpl(final String packageName, final String name) { super(packageName, name, true, null); 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); + public AnnotationTypeBuilder addAnnotation(final String pkgName, final String typeName) { + if (pkgName != null && typeName != null) { + final AnnotationTypeBuilder builder = new AnnotationTypeBuilderImpl(pkgName, typeName); if (!annotationBuilders.contains(builder)) { annotationBuilders = LazyCollections.lazyAdd(annotationBuilders, builder); return builder; @@ -125,7 +125,7 @@ final class AnnotationTypeBuilderImpl extends AbstractBaseType implements Annota private final List parameters; private final List paramNames; - public AnnotationTypeImpl(final String packageName, final String name, + AnnotationTypeImpl(final String packageName, final String name, final List annotationBuilders, final List parameters) { this.packageName = packageName; @@ -205,7 +205,8 @@ final class AnnotationTypeBuilderImpl extends AbstractBaseType implements Annota .compare(this.name, other.getName()) .compare(this.packageName, other.getPackageName()) //FIXME: what is natural ordering for AnnotationType? - .compare(this.annotations, other.getAnnotations(), Ordering.natural().lexicographical()) + .compare(this.annotations, other.getAnnotations(), + Ordering.natural().lexicographical()) .compare(this.paramNames, other.getParameterNames(), Ordering.natural().lexicographical()) .result(); } @@ -251,13 +252,13 @@ final class AnnotationTypeBuilderImpl extends AbstractBaseType implements Annota private final String value; private final List values; - public ParameterImpl(final String name, final String value) { + ParameterImpl(final String name, final String value) { this.name = name; this.value = value; this.values = ImmutableList.of(); } - public ParameterImpl(final String name, final List values) { + ParameterImpl(final String name, final List values) { this.name = name; this.values = values; this.value = null; @@ -280,7 +281,7 @@ final class AnnotationTypeBuilderImpl extends AbstractBaseType implements Annota @Override public int hashCode() { - return Objects.hash(name); + return Objects.hash(name); } @Override diff --git a/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/generated/type/builder/ConstantImpl.java b/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/generated/type/builder/ConstantImpl.java index d58fa19769..c1658b30c4 100644 --- a/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/generated/type/builder/ConstantImpl.java +++ b/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/generated/type/builder/ConstantImpl.java @@ -72,7 +72,8 @@ final class ConstantImpl implements Constant { } ConstantImpl other = (ConstantImpl) obj; - return Objects.equals(name, other.name) && Objects.equals(type, other.type) && Objects.equals(value, other.value); + return Objects.equals(name, other.name) && Objects.equals(type, other.type) + && Objects.equals(value, other.value); } @Override diff --git a/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/generated/type/builder/EnumerationBuilderImpl.java b/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/generated/type/builder/EnumerationBuilderImpl.java index 0d8fdb1d38..90c31dc5d2 100755 --- a/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/generated/type/builder/EnumerationBuilderImpl.java +++ b/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/generated/type/builder/EnumerationBuilderImpl.java @@ -10,12 +10,14 @@ package org.opendaylight.mdsal.binding.javav2.generator.util.generated.type.buil import com.google.common.annotations.Beta; import com.google.common.collect.ImmutableList; + import java.util.List; import java.util.Objects; import java.util.Optional; import java.util.stream.Collectors; import javax.annotation.Nonnull; import javax.annotation.Nullable; + import org.opendaylight.mdsal.binding.javav2.generator.context.ModuleContext; import org.opendaylight.mdsal.binding.javav2.generator.util.AbstractBaseType; import org.opendaylight.mdsal.binding.javav2.generator.util.JavaIdentifierNormalizer; @@ -52,7 +54,7 @@ public class EnumerationBuilderImpl extends AbstractBaseType implements EnumBuil } public EnumerationBuilderImpl(final String packageName, final String name, final boolean isPkNameNormalized, - final boolean isTypeNormalized, final ModuleContext context) { + final boolean isTypeNormalized, final ModuleContext context) { super(packageName, name, isPkNameNormalized, isTypeNormalized, context); } @@ -83,15 +85,16 @@ public class EnumerationBuilderImpl extends AbstractBaseType implements EnumBuil } @Override - public void addValue(final String name, final int value, final String description, final String reference, final Status status) { - final EnumPairImpl p = new EnumPairImpl(name, value, description, reference, status, this.values); + public void addValue(final String name, final int value, final String desc, final String ref, + final Status status) { + final EnumPairImpl p = new EnumPairImpl(name, value, desc, ref, status, this.values); this.values = LazyCollections.lazyAdd(this.values, p); } @Override public Enumeration toInstance(final Type definingType) { - return new EnumerationImpl(definingType, this.annotationBuilders, this.packageName, this.name, this.values, this.description, - this.reference, this.moduleName, this.schemaPath); + return new EnumerationImpl(definingType, this.annotationBuilders, this.packageName, this.name, this.values, + this.description, this.reference, this.moduleName, this.schemaPath); } @Override @@ -123,8 +126,8 @@ public class EnumerationBuilderImpl extends AbstractBaseType implements EnumBuil private final String reference; private final Status status; - public EnumPairImpl(final String name, final int value, final String description, - final String reference, final Status status, final List values) { + EnumPairImpl(final String name, final int value, final String description, + final String reference, final Status status, final List values) { this.name = name; this.mappedName = JavaIdentifierNormalizer.normalizeEnumValueIdentifier(name, values); @@ -164,7 +167,7 @@ public class EnumerationBuilderImpl extends AbstractBaseType implements EnumBuil @Nonnull @Override public Status getStatus() { - return this.status; + return this.status; } @Override @@ -219,9 +222,10 @@ public class EnumerationBuilderImpl extends AbstractBaseType implements EnumBuil private final List values; private final List annotations; - public EnumerationImpl(final Type definingType, final List annotationBuilders, - final String packageName, final String name, final List values, final String description, - final String reference, final String moduleName, final List schemaPath) { + EnumerationImpl(final Type definingType, final List annotationBuilders, + final String packageName, final String name, final List values, final String + description, + final String reference, final String moduleName, final List schemaPath) { super(packageName, name, true, null); this.definingType = definingType; this.values = values; @@ -264,7 +268,7 @@ public class EnumerationBuilderImpl extends AbstractBaseType implements EnumBuil builder.append(" {"); builder.append("\n"); - int i = 0; + int count = 0; for (final Enumeration.Pair valPair : this.values) { builder.append("\t"); builder.append(' '); @@ -272,12 +276,12 @@ public class EnumerationBuilderImpl extends AbstractBaseType implements EnumBuil builder.append(" ("); builder.append(valPair.getValue()); - if (i == this.values.size() - 1) { + if (count == this.values.size() - 1) { builder.append(" );"); } else { builder.append(" ),"); } - ++i; + ++count; } builder.append("\n}"); return builder.toString(); diff --git a/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/generated/type/builder/GeneratedPropertyBuilderImpl.java b/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/generated/type/builder/GeneratedPropertyBuilderImpl.java index 025d470d5e..d3b7769c10 100644 --- a/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/generated/type/builder/GeneratedPropertyBuilderImpl.java +++ b/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/generated/type/builder/GeneratedPropertyBuilderImpl.java @@ -28,14 +28,14 @@ public final class GeneratedPropertyBuilderImpl extends AbstractTypeMemberBuilde } @Override - public GeneratedPropertyBuilder setValue(String value) { - this.value = value; + public GeneratedPropertyBuilder setValue(String valueString) { + this.value = valueString; return this; } @Override - public GeneratedPropertyBuilder setReadOnly(boolean isReadOnly) { - this.isReadOnly = isReadOnly; + public GeneratedPropertyBuilder setReadOnly(boolean readOnlyOrNot) { + this.isReadOnly = readOnlyOrNot; return this; } diff --git a/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/generated/type/builder/GeneratedPropertyImpl.java b/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/generated/type/builder/GeneratedPropertyImpl.java index c6a8cab263..b7a8195c5f 100644 --- a/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/generated/type/builder/GeneratedPropertyImpl.java +++ b/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/generated/type/builder/GeneratedPropertyImpl.java @@ -21,7 +21,7 @@ final class GeneratedPropertyImpl extends AbstractTypeMember implements Generate private String value; private boolean isReadOnly; - public GeneratedPropertyImpl(Type definingType, String name, List annotations, String comment, + GeneratedPropertyImpl(Type definingType, String name, List annotations, String comment, AccessModifier accessModifier, Type returnType, boolean isFinal, boolean isStatic, boolean isReadOnly, String value) { super(definingType, name, annotations, comment, accessModifier, returnType, isFinal, isStatic); diff --git a/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/generated/type/builder/GeneratedTOBuilderImpl.java b/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/generated/type/builder/GeneratedTOBuilderImpl.java index 174928eca3..db0e54ccf6 100644 --- a/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/generated/type/builder/GeneratedTOBuilderImpl.java +++ b/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/generated/type/builder/GeneratedTOBuilderImpl.java @@ -11,8 +11,10 @@ package org.opendaylight.mdsal.binding.javav2.generator.util.generated.type.buil import com.google.common.annotations.Beta; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; + import java.util.List; import java.util.Optional; + import org.opendaylight.mdsal.binding.javav2.generator.context.ModuleContext; import org.opendaylight.mdsal.binding.javav2.model.api.GeneratedProperty; import org.opendaylight.mdsal.binding.javav2.model.api.GeneratedTransferObject; @@ -56,7 +58,7 @@ public final class GeneratedTOBuilderImpl extends AbstractGeneratedTypeBuildernew instance of Method Signature Builder. */ @Override @@ -118,8 +119,8 @@ public final class GeneratedTOBuilderImpl extends AbstractGeneratedTypeBuilder equalsProperties; private final List hashCodeProperties; @@ -211,7 +213,7 @@ public final class GeneratedTOBuilderImpl extends AbstractGeneratedTypeBuilder schemaPath; - public GeneratedTransferObjectImpl(final GeneratedTOBuilderImpl builder) { + GeneratedTransferObjectImpl(final GeneratedTOBuilderImpl builder) { super(builder); this.extendsType = builder.extendsType; diff --git a/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/generated/type/builder/GeneratedTypeBuilderImpl.java b/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/generated/type/builder/GeneratedTypeBuilderImpl.java index d2d30499d4..e18bf9a7c4 100755 --- a/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/generated/type/builder/GeneratedTypeBuilderImpl.java +++ b/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/generated/type/builder/GeneratedTypeBuilderImpl.java @@ -129,7 +129,7 @@ public final class GeneratedTypeBuilderImpl extends AbstractGeneratedTypeBuilder private final String moduleName; private final List schemaPath; - public GeneratedTypeImpl(final GeneratedTypeBuilderImpl builder) { + GeneratedTypeImpl(final GeneratedTypeBuilderImpl builder) { super(builder); this.description = builder.description; @@ -165,7 +165,7 @@ public final class GeneratedTypeBuilderImpl extends AbstractGeneratedTypeBuilder private final String basePackageName; private final String builderPackageName; - public GeneratedTypeWithBuilderImpl(GeneratedTypeBuilderImpl builder) { + GeneratedTypeWithBuilderImpl(GeneratedTypeBuilderImpl builder) { super(builder); Preconditions.checkState(builder.getBasePackageName() != null, "Base package name can not be null for type with builder!"); diff --git a/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/generated/type/builder/MethodParameterImpl.java b/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/generated/type/builder/MethodParameterImpl.java index 9481ef58f4..e9aea315d7 100644 --- a/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/generated/type/builder/MethodParameterImpl.java +++ b/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/generated/type/builder/MethodParameterImpl.java @@ -19,7 +19,7 @@ final class MethodParameterImpl implements Parameter { private final String name; private final Type type; - public MethodParameterImpl(final String name, final Type type) { + MethodParameterImpl(final String name, final Type type) { this.name = name; this.type = type; } diff --git a/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/generated/type/builder/MethodSignatureBuilderImpl.java b/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/generated/type/builder/MethodSignatureBuilderImpl.java index 90bb5e32b9..33acc4d927 100644 --- a/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/generated/type/builder/MethodSignatureBuilderImpl.java +++ b/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/generated/type/builder/MethodSignatureBuilderImpl.java @@ -9,9 +9,11 @@ package org.opendaylight.mdsal.binding.javav2.generator.util.generated.type.buil import com.google.common.annotations.Beta; import com.google.common.collect.ImmutableList; + import java.util.Collections; import java.util.List; import java.util.Objects; + import org.opendaylight.mdsal.binding.javav2.model.api.AnnotationType; import org.opendaylight.mdsal.binding.javav2.model.api.MethodSignature; import org.opendaylight.mdsal.binding.javav2.model.api.Type; @@ -19,19 +21,20 @@ import org.opendaylight.mdsal.binding.javav2.model.api.type.builder.MethodSignat import org.opendaylight.yangtools.util.LazyCollections; @Beta -final class MethodSignatureBuilderImpl extends AbstractTypeMemberBuilder implements MethodSignatureBuilder { +final class MethodSignatureBuilderImpl extends AbstractTypeMemberBuilder implements + MethodSignatureBuilder { private List parameters = ImmutableList.of(); - private List unmodifiableParams = ImmutableList.of(); + private List unmodifiableParams = ImmutableList.of(); private boolean isAbstract; - public MethodSignatureBuilderImpl(final String name) { + MethodSignatureBuilderImpl(final String name) { super(name); } @Override - public MethodSignatureBuilder setAbstract(final boolean isAbstract) { - this.isAbstract = isAbstract; + public MethodSignatureBuilder setAbstract(final boolean abstractOrNot) { + this.isAbstract = abstractOrNot; return this; } diff --git a/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/generated/type/builder/MethodSignatureImpl.java b/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/generated/type/builder/MethodSignatureImpl.java index 47ff88606c..fd27b98530 100644 --- a/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/generated/type/builder/MethodSignatureImpl.java +++ b/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/generated/type/builder/MethodSignatureImpl.java @@ -21,7 +21,7 @@ class MethodSignatureImpl extends AbstractTypeMember implements MethodSignature private final List params; private final boolean isAbstract; - public MethodSignatureImpl(final Type definingType, final String name, + MethodSignatureImpl(final Type definingType, final String name, final List annotations, final String comment, final AccessModifier accessModifier, final Type returnType, final List params, final boolean isFinal, diff --git a/binding2/mdsal-binding2-generator-util/src/test/java/org/opendaylight/mdsal/binding/javav2/generator/util/JavaIdentifierNormalizerTest.java b/binding2/mdsal-binding2-generator-util/src/test/java/org/opendaylight/mdsal/binding/javav2/generator/util/JavaIdentifierNormalizerTest.java index 32210f52b2..c1f58bb84a 100644 --- a/binding2/mdsal-binding2-generator-util/src/test/java/org/opendaylight/mdsal/binding/javav2/generator/util/JavaIdentifierNormalizerTest.java +++ b/binding2/mdsal-binding2-generator-util/src/test/java/org/opendaylight/mdsal/binding/javav2/generator/util/JavaIdentifierNormalizerTest.java @@ -10,6 +10,7 @@ package org.opendaylight.mdsal.binding.javav2.generator.util; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; + import org.junit.Test; import org.opendaylight.mdsal.binding.javav2.generator.context.ModuleContext; import org.opendaylight.mdsal.binding.javav2.util.BindingMapping; @@ -38,11 +39,13 @@ public class JavaIdentifierNormalizerTest { // Augmentable - reserved & non reserved normalizeIdentifier = JavaIdentifierNormalizer - .normalizeClassIdentifier("org.opendaylight.mdsal.binding.javav2.spec.structural", "Augmentable", context); + .normalizeClassIdentifier("org.opendaylight.mdsal.binding.javav2.spec.structural", "Augmentable", + context); assertEquals("Augmentable", normalizeIdentifier); // again reserved normalizeIdentifier = JavaIdentifierNormalizer - .normalizeClassIdentifier("org.opendaylight.mdsal.binding.javav2.spec.structural", "Augmentable", context); + .normalizeClassIdentifier("org.opendaylight.mdsal.binding.javav2.spec.structural", "Augmentable", + context); assertEquals("Augmentable", normalizeIdentifier); // non reserved normalizeIdentifier = JavaIdentifierNormalizer @@ -73,10 +76,12 @@ public class JavaIdentifierNormalizerTest { normalizeIdentifier = JavaIdentifierNormalizer.normalizeClassIdentifier("java.lang", "String", context); assertEquals("String", normalizeIdentifier); // non reserved - normalizeIdentifier = JavaIdentifierNormalizer.normalizeClassIdentifier("string.non.reserved", "String", context); + normalizeIdentifier = JavaIdentifierNormalizer.normalizeClassIdentifier("string.non.reserved", "String", + context); assertEquals("String", normalizeIdentifier); // again non reserved - normalizeIdentifier = JavaIdentifierNormalizer.normalizeClassIdentifier("string.non.reserved", "String", context); + normalizeIdentifier = JavaIdentifierNormalizer.normalizeClassIdentifier("string.non.reserved", "String", + context); assertEquals("String1", normalizeIdentifier); } @@ -115,7 +120,8 @@ public class JavaIdentifierNormalizerTest { String normalizeIdentifier2 = JavaIdentifierNormalizer.normalizeClassIdentifier("org.example.other.package.next", "fOo", context); final String normalizeIdentifier3 = - JavaIdentifierNormalizer.normalizeClassIdentifier("org.example.other.package.next.next", "foo", context); + JavaIdentifierNormalizer.normalizeClassIdentifier("org.example.other.package.next.next", "foo", + context); assertEquals(normalizeIdentifier1, "Foo"); assertEquals(normalizeIdentifier2, "Foo"); assertEquals(normalizeIdentifier3, "Foo"); @@ -123,7 +129,8 @@ public class JavaIdentifierNormalizerTest { normalizeIdentifier1 = JavaIdentifierNormalizer.normalizeClassIdentifier("org.example.other.package", "*", context); normalizeIdentifier2 = - JavaIdentifierNormalizer.normalizeClassIdentifier("org.example.other.package.next", "asterisk", context); + JavaIdentifierNormalizer.normalizeClassIdentifier("org.example.other.package.next", "asterisk", + context); assertEquals(normalizeIdentifier1, "Asterisk"); assertEquals(normalizeIdentifier2, "Asterisk"); } @@ -154,7 +161,8 @@ public class JavaIdentifierNormalizerTest { final String normalizeIdentifier1 = JavaIdentifierNormalizer.normalizeClassIdentifier("org.example.keywords.other.package", "int", context); final String normalizeIdentifier2 = - JavaIdentifierNormalizer.normalizeClassIdentifier("org.example.keywords.other.package.next", "InT", context); + JavaIdentifierNormalizer.normalizeClassIdentifier("org.example.keywords.other.package.next", "InT", + context); final String normalizeIdentifier3 = JavaIdentifierNormalizer.normalizeClassIdentifier("org.example.keywords.other.package.next.next", "inT", context); @@ -428,7 +436,7 @@ public class JavaIdentifierNormalizerTest { } private void assertTest(final String testedIdentifier, final String acceptable, - final JavaIdentifier javaTypeOfIdentifier) { + final JavaIdentifier javaTypeOfIdentifier) { final String convertedIdentifier = JavaIdentifierNormalizer.normalizeSpecificIdentifier(testedIdentifier, javaTypeOfIdentifier); assertNotNull(convertedIdentifier); diff --git a/binding2/mdsal-binding2-generator-util/src/test/java/org/opendaylight/mdsal/binding/javav2/generator/util/generated/type/builder/EnumerationBuilderImplTest.java b/binding2/mdsal-binding2-generator-util/src/test/java/org/opendaylight/mdsal/binding/javav2/generator/util/generated/type/builder/EnumerationBuilderImplTest.java index e192f426c2..5788a3899e 100644 --- a/binding2/mdsal-binding2-generator-util/src/test/java/org/opendaylight/mdsal/binding/javav2/generator/util/generated/type/builder/EnumerationBuilderImplTest.java +++ b/binding2/mdsal-binding2-generator-util/src/test/java/org/opendaylight/mdsal/binding/javav2/generator/util/generated/type/builder/EnumerationBuilderImplTest.java @@ -20,7 +20,8 @@ public class EnumerationBuilderImplTest { @Test public void sameEnumTest() { ModuleContext context = new ModuleContext(); - EnumerationBuilderImpl enumerationBuilderImpl = new EnumerationBuilderImpl("package.same.test", "test", context); + EnumerationBuilderImpl enumerationBuilderImpl = new EnumerationBuilderImpl("package.same.test", "test", + context); Enumeration enumeration = enumerationBuilderImpl.toInstance(enumerationBuilderImpl); String formattedString = enumeration.toFormattedString();