Fix checkstyle errors and activate enforcement for concepts 08/42408/1
authorRobert Varga <rovarga@cisco.com>
Sun, 24 Jul 2016 17:16:41 +0000 (19:16 +0200)
committerRobert Varga <rovarga@cisco.com>
Sun, 24 Jul 2016 17:17:07 +0000 (19:17 +0200)
In an effort to clean our code up, this activates enforcement
of checkstyle rules in concepts and makes sure the build passes.

Change-Id: Ide488a7e4664ff146c23f5f84a2a284055dcb0b3
Signed-off-by: Robert Varga <rovarga@cisco.com>
common/concepts/pom.xml
common/concepts/src/main/java/org/opendaylight/yangtools/concepts/Identifier.java
common/concepts/src/main/java/org/opendaylight/yangtools/concepts/Mutable.java
common/concepts/src/main/java/org/opendaylight/yangtools/concepts/MutationBehaviour.java
common/concepts/src/main/java/org/opendaylight/yangtools/concepts/SemVer.java
common/concepts/src/main/java/org/opendaylight/yangtools/concepts/WritableObject.java
common/concepts/src/main/java/org/opendaylight/yangtools/concepts/WritableObjects.java
common/concepts/src/test/java/org/opendaylight/yangtools/concepts/WritableObjectsTest.java

index 328d392105c1d980ccdffad39019556cbfb2a6ba..3e3007b5df813769dda9fb71d345d97544b93c9f 100644 (file)
         </dependency>
     </dependencies>
 
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-checkstyle-plugin</artifactId>
+                <configuration>
+                    <failsOnError>true</failsOnError>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
   <!--
       Maven Site Configuration
 
index b673486196fbe34bfd453d24d42a1a5acdb402b4..db6216976c6f2c9d8b2e736f59d6aa6eb675e85e 100644 (file)
@@ -15,19 +15,20 @@ import javax.annotation.concurrent.ThreadSafe;
  * addresses, classes, etc. We do not require too much, just that the identifiers are serializable (and this
  * transferable).
  *
- * Implementations are expected to implement {@link #hashCode()} and {@link #equals(Object)} methods in a way, which
- * ensures that objects before and after serialization are considered equal.
+ * <p>Implementations are expected to implement {@link #hashCode()} and {@link #equals(Object)} methods in a way,
+ * which ensures that objects before and after serialization are considered equal.
  *
- * Implementations are advised to use the {@link java.io.Externalizable} Proxy pattern to allow future evolution
+ * <p>Implementations are advised to use the {@link java.io.Externalizable} Proxy pattern to allow future evolution
  * of their serialization format. For further efficiency, implementation should implement {@link WritableObject},
  * so they can be efficiently embedded in other {@link Serializable} objects.
  *
- * Note that this class is annotated as {@link ThreadSafe}, hence all implementations are expected to be thread-safe.
+ * <p>Note that this class is annotated as {@link ThreadSafe}, hence all implementations are expected to be
+ * thread-safe.
  */
 @ThreadSafe
 public interface Identifier extends Serializable, Immutable {
     @Override
-    boolean equals(Object o);
+    boolean equals(Object obj);
 
     @Override
     int hashCode();
index 82b2bb11571f8da41e8ef9f894b766c8f46e1009..f6f2893f7222136494c459275fe88da71b9f6f6e 100644 (file)
@@ -8,13 +8,10 @@
 package org.opendaylight.yangtools.concepts;
 
 /**
- * Mutable object - object may change it's state during lifecycle.
- *
- * This interface is mutually exclusive with {@link Immutable}  and other
- * {@link MutationBehaviour}s.
+ * Mutable object - object may change it's state during lifecycle. This interface is mutually exclusive
+ * with {@link Immutable} and other {@link MutationBehaviour}s.
  *
  * @author Tony Tkacik
- *
  */
 public interface Mutable extends MutationBehaviour<Mutable> {
 
index 30e1fbd2f925f31779cafea99260f8578a2563a0..2004062ecafc3e3fc9ab4adf407944e54e0685dc 100644 (file)
@@ -8,9 +8,7 @@
 package org.opendaylight.yangtools.concepts;
 
 /**
- * Mutation behavior
- *
- * This interface is used to prevent same class extends multiple types of MutationBehaviour
+ * Mutation behavior. This interface is used to prevent same class extends multiple types of MutationBehaviour
  * such as {@link Immutable} and {@link Mutable} which are mutually exclusive.
  *
  * @author Tony Tkacik
index d7520d47c9ced14f028dc9f850c8809426dbdf03..0df08925e0af52155cc1fbc4195df4d763b03e4b 100644 (file)
@@ -44,56 +44,62 @@ public final class SemVer implements Comparable<SemVer>, Serializable {
         return new SemVer(major, minor, patch);
     }
 
-    public static SemVer valueOf(@Nonnull final String s) {
-        final int minorIdx = s.indexOf('.');
+    public static SemVer valueOf(@Nonnull final String str) {
+        final int minorIdx = str.indexOf('.');
         if (minorIdx == -1) {
-            return create(Integer.parseInt(s));
+            return create(Integer.parseInt(str));
         }
 
         final String minorStr;
-        final int patchIdx = s.indexOf('.', minorIdx + 1);
+        final int patchIdx = str.indexOf('.', minorIdx + 1);
         if (patchIdx == -1) {
-            minorStr = s.substring(minorIdx + 1);
+            minorStr = str.substring(minorIdx + 1);
         } else {
-            minorStr = s.substring(minorIdx + 1, patchIdx);
+            minorStr = str.substring(minorIdx + 1, patchIdx);
         }
 
-        return create(Integer.parseInt(s.substring(0, minorIdx), 10), Integer.parseInt(minorStr, 10),
-            Integer.parseInt(s.substring(patchIdx + 1), 10));
+        return create(Integer.parseInt(str.substring(0, minorIdx), 10), Integer.parseInt(minorStr, 10),
+            Integer.parseInt(str.substring(patchIdx + 1), 10));
     }
 
     /**
-     * @return the major
+     * Return the major version number.
+     *
+     * @return major version number
      */
     public int getMajor() {
         return major;
     }
 
     /**
-     * @return the minor
+     * Return the minor version number.
+     *
+     * @return minor version number
      */
     public int getMinor() {
         return minor;
     }
 
     /**
-     * @return the patch
+     * Return the patch version number.
+     *
+     * @return patch version number
      */
     public int getPatch() {
         return patch;
     }
 
     @Override
-    public int compareTo(final SemVer o) {
-        int i = Integer.compare(major, o.major);
-        if (i == 0) {
-            i = Integer.compare(minor, o.minor);
-            if (i == 0) {
-                return Integer.compare(patch, o.patch);
+    public int compareTo(final SemVer other) {
+        int cmp = Integer.compare(major, other.major);
+        if (cmp == 0) {
+            cmp = Integer.compare(minor, other.minor);
+            if (cmp == 0) {
+                return Integer.compare(patch, other.patch);
             }
         }
 
-        return i;
+        return cmp;
     }
 
     @Override
index 7d5a3d8bfd27d08366326614f15f369cd87dfdb6..7ad2ee929d84189796b875b011efd4039b71e795 100644 (file)
@@ -20,8 +20,8 @@ import javax.annotation.Nonnull;
  *      public static CLASS readFrom(DataInput in) throws IOException;
  * </pre>
  *
- * The serialization format provided by this abstraction does not guarantee versioning. Callers are responsible for
- * ensuring the source stream is correctly positioned.
+ * <p>The serialization format provided by this abstraction does not guarantee versioning. Callers are responsible
+ * for ensuring the source stream is correctly positioned.
  *
  * @author Robert Varga
  */
index e300696b8911087d44774e481dfdec23d52ae9de..57a3714257860bcacf8e6c12753a9689c14f828c 100644 (file)
@@ -42,12 +42,12 @@ public final class WritableObjects {
      * serializing counters and similar, which have a wide range, but typically do not use it. The value provided is
      * treated as unsigned.
      *
-     * This methods writes the number of trailing non-zero in the value. It then writes the minimum required bytes
+     * <p>This methods writes the number of trailing non-zero in the value. It then writes the minimum required bytes
      * to reconstruct the value by left-padding zeroes. Inverse operation is performed by {@link #readLong(DataInput)}
      * or a combination of {@link #readLongHeader(DataInput)} and {@link #readLongBody(DataInput, byte)}.
      *
-     * Additionally the caller can use the top four bits (i.e. 0xF0) for caller-specific flags. These will be ignored
-     * by {@link #readLong(DataInput)}, but can be extracted via {@link #readLongHeader(DataInput)}.
+     * <p>Additionally the caller can use the top four bits (i.e. 0xF0) for caller-specific flags. These will be
+     * ignored by {@link #readLong(DataInput)}, but can be extracted via {@link #readLongHeader(DataInput)}.
      *
      * @param out Data output
      * @param value long value to write
@@ -103,6 +103,7 @@ public final class WritableObjects {
      *
      * @param in Data input
      * @param header Value header, as returned by {@link #readLongHeader(DataInput)}
+     * @return long value
      * @throws IOException if an I/O error occurs
      * @throws NullPointerException if input is null
      */
@@ -135,8 +136,8 @@ public final class WritableObjects {
      * Write two consecutive long values. These values can be read back using {@link #readLongHeader(DataInput)},
      * {@link #readFirstLong(DataInput, byte)} and {@link #readSecondLong(DataInput, byte)}.
      *
-     * This is a more efficient way of serializing two longs than {@link #writeLong(DataOutput, long)}. This is achieved
-     * by using the flags field to hold the length of the second long -- hence saving one byte.
+     * <p>This is a more efficient way of serializing two longs than {@link #writeLong(DataOutput, long)}. This is
+     * achieved by using the flags field to hold the length of the second long -- hence saving one byte.
      *
      * @param out Data output
      * @param value0 first long value to write
@@ -144,7 +145,8 @@ public final class WritableObjects {
      * @throws IOException if an I/O error occurs
      * @throws NullPointerException if output is null
      */
-    public static void writeLongs(final @Nonnull DataOutput out, final long value0, final long value1) throws IOException {
+    public static void writeLongs(final @Nonnull DataOutput out, final long value0, final long value1)
+            throws IOException {
         final int clen = WritableObjects.valueBytes(value1);
         writeLong(out, value0, clen << 4);
         WritableObjects.writeValue(out, value1, clen);
index c4794eaff838119b6b22ccc75ae0af9e4e50f35f..f019219cc514b8226fed87356397e470fcec727e 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.yangtools.concepts;
 
 import static org.junit.Assert.assertEquals;
+
 import com.google.common.io.ByteArrayDataOutput;
 import com.google.common.io.ByteStreams;
 import java.io.IOException;