/*
 * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 */
package org.opendaylight.yangtools.util;

import org.opendaylight.yangtools.concepts.Builder;

/**
 * Utility class for incrementally building object hashCode by hashing together
 * component objects, one by one.
 *
 * @param <T> Component objec 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.
     *
     * <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>.
     */
    public HashCodeBuilder() {
        this(1);
    }

    /**
     * Create a new instance, with internal hash set to specified seed.
     *
     * @param seedHash Seed hash value
     */
    public HashCodeBuilder(final int seedHash) {
        this.currentHash = seedHash;
    }

    /**
     * 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
     * @return Combined hash code
     */
    public static int nextHashCode(final int hashCode, final Object obj) {
        return PRIME * hashCode + obj.hashCode();
    }

    /**
     * Update the internal hash code with the hash code of a component
     * object.
     *
     * @param obj Component object
     */
    public void addArgument(final T obj) {
        currentHash = nextHashCode(currentHash, obj);
    }

    @Override
    public Integer build() {
        return currentHash;
    }
}

@@ -343,16 +343,59 @@
 .util;%0A%0A
+import org.eclipse.jdt.annotation.NonNull;%0A
 import o
@@ -522,19 +522,16 @@
 together
-%0A *
  compone
@@ -586,16 +586,17 @@
 nt objec
+t
  type%0A *
@@ -770,23 +770,16 @@
 lication
-%0A     *
  overflo
@@ -782,16 +782,23 @@
 rflowed,
+%0A     *
  informa
@@ -870,23 +870,16 @@
 ing. The
-%0A     *
  advanta
@@ -900,16 +900,23 @@
 prime is
+%0A     *
  less cl
@@ -967,23 +967,16 @@
 of 31 is
-%0A     *
  that th
@@ -1018,16 +1018,23 @@
  a shift
+%0A     *
  and a s
@@ -1067,23 +1067,16 @@
 ormance:
-%0A     *
  31 * i 
@@ -1131,16 +1131,23 @@
 mization
+%0A     *
  automat
@@ -1260,23 +1260,16 @@
 when you
-%0A     *
  overrid
@@ -1277,16 +1277,23 @@
  equals,
+%0A     *
  page 48
@@ -1447,23 +1447,16 @@
 ed to 1,
-%0A     *
  equival
@@ -1863,23 +1863,16 @@
  and the
-%0A     *
  hash co
@@ -2222,23 +2222,16 @@
 omponent
-%0A     *
  object.
@@ -2410,16 +2410,25 @@
  public 
+@NonNull 
 Integer 

Fix HashCodeBuilder Eclipse error