Fix HashCodeBuilder Eclipse error 40/77740/1
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 13 Nov 2018 18:39:28 +0000 (19:39 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 13 Nov 2018 18:39:28 +0000 (19:39 +0100)
With .build() required to return a @NonNull, make sure we match
the annotation.

Change-Id: I1baedf6af702ec77c053f209fe43ad75f357bccd
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
common/util/src/main/java/org/opendaylight/yangtools/util/HashCodeBuilder.java

index 541ae5540c33d3fd3f108e030636c013a1d9e20b..5bd02335465bf8b81d020011a0ee691c786aec03 100644 (file)
@@ -7,31 +7,30 @@
  */
 package org.opendaylight.yangtools.util;
 
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.concepts.Builder;
 
 /**
- * Utility class for incrementally building object hashCode by hashing together
- * component objects, one by one.
+ * Utility class for incrementally building object hashCode by hashing together component objects, one by one.
  *
- * @param <T> Component objec type
+ * @param <T> Component object type
  */
 public final class HashCodeBuilder<T> implements Builder<Integer> {
     /**
-     * The value 31 was chosen because it is an odd prime. If it were even and the multiplication
-     * overflowed, information would be lost, as multiplication by 2 is equivalent to shifting. The
-     * advantage of using a prime is less clear, but it is traditional. A nice property of 31 is
-     * that the multiplication can be replaced by a shift and a subtraction for better performance:
-     * 31 * i == (i << 5) - i. Modern VMs do this sort of optimization automatically.
+     * The value 31 was chosen because it is an odd prime. If it were even and the multiplication overflowed,
+     * information would be lost, as multiplication by 2 is equivalent to shifting. The advantage of using a prime is
+     * less clear, but it is traditional. A nice property of 31 is that the multiplication can be replaced by a shift
+     * and a subtraction for better performance: 31 * i == (i << 5) - i. Modern VMs do this sort of optimization
+     * automatically.
      *
-     * <p>(from Joshua Bloch's Effective Java, Chapter 3, Item 9: Always override hashcode when you
-     * override equals, page 48)
+     * <p>(from Joshua Bloch's Effective Java, Chapter 3, Item 9: Always override hashcode when you override equals,
+     * page 48)
      */
     private static final int PRIME = 31;
     private int currentHash;
 
     /**
-     * Create a new instance, with internal hash initialized to 1,
-     * equivalent of <code>HashCodeBuilder(1)</code>.
+     * Create a new instance, with internal hash initialized to 1, equivalent of <code>HashCodeBuilder(1)</code>.
      */
     public HashCodeBuilder() {
         this(1);
@@ -47,8 +46,7 @@ public final class HashCodeBuilder<T> implements Builder<Integer> {
     }
 
     /**
-     * Determine the next hash code combining a base hash code and the
-     * hash code of an object.
+     * Determine the next hash code combining a base hash code and the hash code of an object.
      *
      * @param hashCode base hash code
      * @param obj Object to be added
@@ -59,8 +57,7 @@ public final class HashCodeBuilder<T> implements Builder<Integer> {
     }
 
     /**
-     * Update the internal hash code with the hash code of a component
-     * object.
+     * Update the internal hash code with the hash code of a component object.
      *
      * @param obj Component object
      */
@@ -69,7 +66,7 @@ public final class HashCodeBuilder<T> implements Builder<Integer> {
     }
 
     @Override
-    public Integer build() {
+    public @NonNull Integer build() {
         return currentHash;
     }
 }