From: Robert Varga Date: Tue, 17 Oct 2017 14:58:56 +0000 (+0200) Subject: Fix checkstyle violations in yang-binding X-Git-Tag: release/oxygen~61 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=9d7d03933651bdb8774275583c179a6a7dc38771;p=mdsal.git Fix checkstyle violations in yang-binding Fixes violations and activates enforcement. Change-Id: Iaa11d659549fa62a35201dea77992b32aebbd998 Signed-off-by: Robert Varga --- diff --git a/binding/yang-binding/pom.xml b/binding/yang-binding/pom.xml index f2439f91f8..1bfaf1ddb6 100644 --- a/binding/yang-binding/pom.xml +++ b/binding/yang-binding/pom.xml @@ -65,20 +65,32 @@ - - ${odl.site.url}/${project.groupId}/${stream}/${project.artifactId}/ + + ${odl.site.url}/${project.groupId}/${stream}/${project.artifactId}/ + + + + opendaylight-site + ${nexus.site.url}/${project.artifactId}/ + + diff --git a/binding/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/Augmentable.java b/binding/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/Augmentable.java index 832cdcdca3..ea603097a6 100644 --- a/binding/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/Augmentable.java +++ b/binding/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/Augmentable.java @@ -8,24 +8,22 @@ package org.opendaylight.yangtools.yang.binding; /** - * Augmentable (extensible) object which could carry additional data defined by - * third-party extension, without introducing conflict between various - * extension. - * - * This interface uses extended version of ExtensibleInterface pattern which - * also adds marker interface for augmentations (extensions) - - * {@link Augmentable} - * - * @author Tony Tkacik + * Augmentable (extensible) object which could carry additional data defined by a third-party extension, without + * introducing conflict between various extension. + * + *

+ * This interface uses extended version of ExtensibleInterface pattern which also adds marker interface for + * augmentations (extensions) - {@link Augmentable}. + * * @param * Base class which should implements this interface and is target * for augmentation. + * @author Tony Tkacik */ public interface Augmentable { - /** * Returns instance of augmentation. - * + * * @param augmentationType * Type of augmentation to be returned. * @return instance of augmentation. diff --git a/binding/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/Augmentation.java b/binding/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/Augmentation.java index cb6f1a1e75..52de172fd1 100644 --- a/binding/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/Augmentation.java +++ b/binding/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/Augmentation.java @@ -8,16 +8,11 @@ package org.opendaylight.yangtools.yang.binding; /** - * Augmentation (extension) of other interface. - * - * This interface uniquely bounds Augmentation to generated - * interface. - * - * All interfaces generated from YANG Augmentation statement - * must implement this interface with parameter P + * Augmentation (extension) of other interface. This interface uniquely bounds Augmentation to generated interface. + * + *

+ * All interfaces generated from YANG Augmentation statement must implement this interface with parameter P * which uniquely points to it's target class. - * - * * * @param Class to which this implementation is extension. */ diff --git a/binding/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/AugmentationHolder.java b/binding/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/AugmentationHolder.java index 472c3c28c8..b23e72eb77 100644 --- a/binding/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/AugmentationHolder.java +++ b/binding/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/AugmentationHolder.java @@ -10,19 +10,15 @@ package org.opendaylight.yangtools.yang.binding; import java.util.Map; /** + * Augmentable (extensible) object which could carry additional data defined by third-party extension, without + * introducing conflict between various extension. * - * Augmentable (extensible) object which could carry additional data defined by - * third-party extension, without introducing conflict between various - * extension. - * - * - * @author Tony Tkacik * @param * Base class which should is target * for augmentations. + * @author Tony Tkacik */ public interface AugmentationHolder { - /** * Returns map of all augmentations. * diff --git a/binding/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/BaseIdentity.java b/binding/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/BaseIdentity.java index fec92f2497..c6f0d0e5cf 100644 --- a/binding/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/BaseIdentity.java +++ b/binding/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/BaseIdentity.java @@ -8,13 +8,11 @@ package org.opendaylight.yangtools.yang.binding; /** - * Base Identity - * + * Base Identity. */ public abstract class BaseIdentity { - public static final BaseIdentity INSTANCE = new BaseIdentity() { - }; + public static final BaseIdentity INSTANCE = new BaseIdentity() { }; protected BaseIdentity() { diff --git a/binding/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/BindingMapping.java b/binding/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/BindingMapping.java index 72f63cc060..13ff3cd7b6 100644 --- a/binding/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/BindingMapping.java +++ b/binding/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/BindingMapping.java @@ -8,6 +8,7 @@ package org.opendaylight.yangtools.yang.binding; import static com.google.common.base.Preconditions.checkArgument; + import com.google.common.base.CharMatcher; import com.google.common.base.Splitter; import com.google.common.collect.ImmutableSet; @@ -88,19 +89,22 @@ public final class BindingMapping { final char[] chars = namespace.toCharArray(); for (int i = 0; i < chars.length; ++i) { switch (chars[i]) { - case '/': - case ':': - case '-': - case '@': - case '$': - case '#': - case '\'': - case '*': - case '+': - case ',': - case ';': - case '=': - chars[i] = '.'; + case '/': + case ':': + case '-': + case '@': + case '$': + case '#': + case '\'': + case '*': + case '+': + case ',': + case ';': + case '=': + chars[i] = '.'; + break; + default: + // no-op } } @@ -138,24 +142,24 @@ public final class BindingMapping { return PACKAGE_INTERNER.intern(builder.toString()); } - public static String getMethodName(final QName name) { - checkArgument(name != null, "Name should not be null."); - return getMethodName(name.getLocalName()); - } - public static String getClassName(final String localName) { checkArgument(localName != null, "Name should not be null."); return toFirstUpper(toCamelCase(localName)); } + public static String getClassName(final QName name) { + checkArgument(name != null, "Name should not be null."); + return toFirstUpper(toCamelCase(name.getLocalName())); + } + public static String getMethodName(final String yangIdentifier) { checkArgument(yangIdentifier != null,"Identifier should not be null"); return toFirstLower(toCamelCase(yangIdentifier)); } - public static String getClassName(final QName name) { + public static String getMethodName(final QName name) { checkArgument(name != null, "Name should not be null."); - return toFirstUpper(toCamelCase(name.getLocalName())); + return getMethodName(name.getLocalName()); } public static String getGetterSuffix(final QName name) { @@ -195,52 +199,44 @@ public final class BindingMapping { } /** - * Returns the {@link String} {@code s} with an - * {@link Character#isUpperCase(char) upper case} first character. This + * Returns the {@link String} {@code s} with an {@link Character#isUpperCase(char) upper case} first character. This * function is null-safe. * - * @param s - * the string that should get an upper case first character. May - * be null. - * @return the {@link String} {@code s} with an upper case first character - * or null if the input {@link String} {@code s} was - * null. + * @param str the string that should get an upper case first character. May be null. + * @return the {@link String} {@code str} with an upper case first character or null if the input + * {@link String} {@code str} was null. */ - public static String toFirstUpper(final String s) { - if (s == null || s.length() == 0) { - return s; + public static String toFirstUpper(final String str) { + if (str == null || str.length() == 0) { + return str; } - if (Character.isUpperCase(s.charAt(0))) { - return s; + if (Character.isUpperCase(str.charAt(0))) { + return str; } - if (s.length() == 1) { - return s.toUpperCase(); + if (str.length() == 1) { + return str.toUpperCase(); } - return s.substring(0, 1).toUpperCase() + s.substring(1); + return str.substring(0, 1).toUpperCase() + str.substring(1); } /** - * Returns the {@link String} {@code s} with an - * {@link Character#isLowerCase(char) lower case} first character. This + * Returns the {@link String} {@code s} with a {@link Character#isLowerCase(char) lower case} first character. This * function is null-safe. * - * @param s - * the string that should get an lower case first character. May - * be null. - * @return the {@link String} {@code s} with an lower case first character - * or null if the input {@link String} {@code s} was - * null. + * @param str the string that should get an lower case first character. May be null. + * @return the {@link String} {@code str} with an lower case first character or null if the input + * {@link String} {@code str} was null. */ - private static String toFirstLower(final String s) { - if (s == null || s.length() == 0) { - return s; + private static String toFirstLower(final String str) { + if (str == null || str.length() == 0) { + return str; } - if (Character.isLowerCase(s.charAt(0))) { - return s; + if (Character.isLowerCase(str.charAt(0))) { + return str; } - if (s.length() == 1) { - return s.toLowerCase(); + if (str.length() == 1) { + return str.toLowerCase(); } - return s.substring(0, 1).toLowerCase() + s.substring(1); + return str.substring(0, 1).toLowerCase() + str.substring(1); } } diff --git a/binding/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/BindingStreamEventWriter.java b/binding/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/BindingStreamEventWriter.java index cd943e9400..2d6ed5cba7 100644 --- a/binding/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/BindingStreamEventWriter.java +++ b/binding/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/BindingStreamEventWriter.java @@ -13,8 +13,7 @@ import java.io.IOException; /** - * Event Stream Writer for Binding Representation - * + * Event Stream Writer for Binding Representation. * *

Emmiting Event Stream

* @@ -33,81 +32,65 @@ import java.io.IOException; * {@link #startMapNode(Class, int)} and is ended using {@link #endNode()}. Each map * entry start is emitted using {@link #startMapEntryNode(Identifier, int)} with Map of keys * and finished using {@link #endNode()}. - * *
  • UnkeyedList - Unkeyed list represent list without keys, * unkeyed list start is emitted using {@link #startUnkeyedList(Class, int)} list * end is emitted using {@link #endNode()}. Each list item is emitted using * {@link #startUnkeyedListItem(int)} and ended using {@link #endNode()}.
  • * - * *
  • leaf - Leaf node event is emitted using * {@link #leafNode(String, Object)}. {@link #endNode()} MUST be not emitted for * leaf node.
  • - * *
  • leaf-list - Leaf list start is emitted using * {@link #startLeafSet(String, int)}. Leaf list end is emitted using * {@link #endNode()}. Leaf list entries are emitted using * {@link #leafSetEntryNode(Object)}. - * *
  • anyxml - Anyxml node event is emitted using * {@link #leafNode(String, Object)}. {@link #endNode()} MUST be not emitted * for anyxml node.
  • - * - * *
  • choice Choice node event is emitted by * {@link #startChoiceNode(Class, int)} event and must be immediately followed by * {@link #startCase(Class, int)} event. Choice node is finished by emitting an * {@link #endNode()} event.
  • - * *
  • * case - Case node may be emitted only inside choice node by * invoking {@link #startCase(Class, int)}. Case node is finished be emitting an * {@link #endNode()} event.
  • - * *
  • * augment - Represents augmentation, augmentation node is started * by invoking {@link #startAugmentationNode(Class)} and * finished by invoking {@link #endNode()}.
  • - * * * - *

    Implementation notes

    This interface is not intended to be - * implemented by users of generated Binding DTOs but to be used by utilities, - * which needs to emit NormalizedNode model from Binding DTOs. - *

    - * This interface is intended as API definition of facade for real Event / - * Stream Writer, without explicitly requiring stream writer and related - * interfaces to be imported by all generated Binding DTOs. - *

    - * Existence of this interface in base Java Binding package is required to - * support runtime generation of users of this interface in OSGI and OSGI-like - * environment, since this package is only package which is imported by all - * generated Binding DTOs and wired in OSGI. + *

    Implementation notes

    This interface is not intended to be implemented by users of generated Binding DTOs + * but to be used by utilities, which needs to emit NormalizedNode model from Binding DTOs. * + *

    + * This interface is intended as API definition of facade for real Event / Stream Writer, without explicitly requiring + * stream writer and related interfaces to be imported by all generated Binding DTOs. * + *

    + * Existence of this interface in base Java Binding package is required to support runtime generation of users of this + * interface in OSGI and OSGI-like environment, since this package is only package which is imported by all generated + * Binding DTOs and wired in OSGI. */ public interface BindingStreamEventWriter extends Closeable, Flushable { /** - * Methods in this interface allow users to hint the underlying - * implementation about the sizing of container-like constructors - * (leafLists, containers, etc.). These hints may be taken into account by a - * particular implementation to improve performance, but clients are not - * required to provide hints. This constant should be used by clients who - * either do not have the sizing information, or do not wish to divulge it - * (for whatever reasons). Implementations are free to ignore these hints - * completely, but if they do use them, they are expected to be resilient in - * face of missing and mismatched hints, which is to say the user can - * specify startLeafSet(..., 1) and then call leafNode() 15 times. + * Methods in this interface allow users to hint the underlying implementation about the sizing of container-like + * constructors (leafLists, containers, etc.). These hints may be taken into account by a particular implementation + * to improve performance, but clients are not required to provide hints. This constant should be used by clients + * who either do not have the sizing information, or do not wish to divulge it (for whatever reasons). + * Implementations are free to ignore these hints completely, but if they do use them, they are expected to be + * resilient in face of missing and mismatched hints, which is to say the user can specify startLeafSet(..., 1) + * and then call leafNode() 15 times. + * *

    - * The acceptable hint values are non-negative integers and this constant, - * all other values will result, based on implementation preference, in the - * hint being completely ignored or IllegalArgumentException being thrown. + * The acceptable hint values are non-negative integers and this constant, all other values will result, based on + * implementation preference, in the hint being completely ignored or IllegalArgumentException being thrown. */ int UNKNOWN_SIZE = -1; /** - * * Emits a leaf node event with supplied value. * * @param localName @@ -126,12 +109,8 @@ public interface BindingStreamEventWriter extends Closeable, Flushable { void leafNode(String localName, Object value) throws IOException; /** - * - * Emits a start of leaf set (leaf-list). - *

    - * Emits start of leaf set, during writing leaf set event, only - * {@link #leafSetEntryNode(Object)} calls are valid. Leaf set event is - * finished by calling {@link #endNode()}. + * Emits a start of leaf set (leaf-list). Emits start of leaf set, during writing leaf set event, only + * {@link #leafSetEntryNode(Object)} calls are valid. Leaf set event is finished by calling {@link #endNode()}. * * @param localName * name of node as defined in schema, namespace and revision are @@ -152,8 +131,8 @@ public interface BindingStreamEventWriter extends Closeable, Flushable { void startLeafSet(String localName, int childSizeHint) throws IOException; /** - * * Emits a start of leaf set (leaf-list). + * *

    * Emits start of leaf set, during writing leaf set event, only * {@link #leafSetEntryNode(Object)} calls are valid. Leaf set event is @@ -178,7 +157,7 @@ public interface BindingStreamEventWriter extends Closeable, Flushable { void startOrderedLeafSet(String localName, int childSizeHint) throws IOException; /** - * Emits a leaf set entry node + * Emits a leaf set entry node. * * @param value * Value of leaf set entry node. @@ -191,11 +170,7 @@ public interface BindingStreamEventWriter extends Closeable, Flushable { void leafSetEntryNode(Object value) throws IOException; /** - * - * Emits start of new container. - * - *

    - * End of container event is emitted by invoking {@link #endNode()}. + * Emits start of new container. End of container event is emitted by invoking {@link #endNode()}. * *

    * Valid sub-events are: @@ -228,7 +203,6 @@ public interface BindingStreamEventWriter extends Closeable, Flushable { void startContainerNode(Class container, int childSizeHint) throws IOException; /** - * * Emits start of unkeyed list node event. * *

    @@ -260,9 +234,6 @@ public interface BindingStreamEventWriter extends Closeable, Flushable { *

    * Unkeyed list item event is finished by invoking {@link #endNode()}. Valid * sub-events are: - *

    - * Valid sub-events are: - * *

    * - * * @param childSizeHint * Non-negative count of expected direct child nodes or * {@link #UNKNOWN_SIZE} if count is unknown. This is only hint @@ -286,12 +256,11 @@ public interface BindingStreamEventWriter extends Closeable, Flushable { void startUnkeyedListItem(int childSizeHint) throws IOException; /** - * * Emits start of unordered map node event. * *

    * End of map node event is emitted by invoking {@link #endNode()}. Valid - * subevents is only {@link #startMapEntryNode(Identifier, int)}. All other methods will + * subevent is only {@link #startMapEntryNode(Identifier, int)}. All other methods will * throw {@link IllegalArgumentException}. * * @param mapEntryType @@ -311,12 +280,11 @@ public interface BindingStreamEventWriter extends Closeable, Flushable { throws IOException; /** - * * Emits start of ordered map node event. * *

    * End of map node event is emitted by invoking {@link #endNode()}. Valid - * subevents is only {@link #startMapEntryNode(Identifier, int)}. All other methods will + * subevent is only {@link #startMapEntryNode(Identifier, int)}. All other methods will * throw {@link IllegalArgumentException}. * * @param mapEntryType @@ -336,7 +304,6 @@ public interface BindingStreamEventWriter extends Closeable, Flushable { throws IOException; /** - * * Emits start of map entry. * *

    @@ -383,7 +350,6 @@ public interface BindingStreamEventWriter extends Closeable, Flushable { * {@link #UNKNOWN_SIZE} if count is unknown. This is only hint * and should not fail writing of child events, if there are more * events than count. - * @throws IllegalArgumentException * @throws IllegalStateException * If node was emitted inside map, choice, * unkeyed list node. @@ -392,7 +358,6 @@ public interface BindingStreamEventWriter extends Closeable, Flushable { void startChoiceNode(Class choice, int childSizeHint) throws IOException; /** - * * Starts a case node. * *

    @@ -408,7 +373,6 @@ public interface BindingStreamEventWriter extends Closeable, Flushable { * * * @param caze Case class - * @throws IllegalArgumentException * @throws IOException if an underlying IO error occurs */ void startCase(Class caze, int childSizeHint) throws IOException; @@ -445,9 +409,8 @@ public interface BindingStreamEventWriter extends Closeable, Flushable { /** * Emits anyxml node event. * - * @param name - * @param value - * @throws IllegalArgumentException + * @param name node name + * @param value node value * @throws IllegalStateException * If node was emitted inside map, * choice unkeyed list node. @@ -462,6 +425,7 @@ public interface BindingStreamEventWriter extends Closeable, Flushable { * @throws IOException if an underlying IO error occurs */ void endNode() throws IOException; + @Override void flush() throws IOException; diff --git a/binding/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/ChildOf.java b/binding/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/ChildOf.java index 28b4e0c577..0f3aa59d8a 100644 --- a/binding/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/ChildOf.java +++ b/binding/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/ChildOf.java @@ -8,19 +8,16 @@ package org.opendaylight.yangtools.yang.binding; /** - * Child of parent container - * - * Marker interface uniquelly bounding generated Java interfaces to their - * parent container. - * - * Any nested Java interface generated from YANG must implement this interface, - * where parameter P points to it's defining data node container - * (interface generated for List, Container, Case). - * - * In case of children added by augmentation (which implements {@link Augmentation}) - * interfaces representing nested container must implements {@link ChildOf} with - * same argument as Augmentation. - * + * Child of parent container. Marker interface uniquely bounding generated Java interfaces to their parent container. + * + *

    + * Any nested Java interface generated from YANG must implement this interface, where parameter P points + * to it's defining data node container (interface generated for List, Container, Case). + * + *

    + * In case of children added by augmentation (which implements {@link Augmentation}) interfaces representing nested + * container must implements {@link ChildOf} with same argument as Augmentation. + * * @param

    Parent container */ public interface ChildOf

    extends DataObject { diff --git a/binding/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/DataContainer.java b/binding/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/DataContainer.java index f4bc7a3142..aceef54c31 100644 --- a/binding/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/DataContainer.java +++ b/binding/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/DataContainer.java @@ -8,13 +8,11 @@ package org.opendaylight.yangtools.yang.binding; /** - * Data Container - object contains structured data - * - * Marker interface which must be implmeneted by all interfaces + * Data Container - object contains structured data. Marker interface which must be implmeneted by all interfaces * generated for YANG: *