/**
 * Created by Mike Dunn on 5/31/15.
 */

public class HashCode {

  public static int calculate(int initialNonZeroOddNumber, int multiplierNonZeroOddNumber, Object... members) {
    for (Object member : members) {
      initialNonZeroOddNumber = multiplierNonZeroOddNumber * initialNonZeroOddNumber + getHashCode(member);
    }
    return initialNonZeroOddNumber;
  }

  private static int getHashCode(Object object) {
    if (object == null) {
      return 0;
    }
    return object.hashCode();
  }

}

Example use:

public class SomeClass {

  private int x;
  private String name;
  private Date date;

  @Override
  public int hashCode() {
    return HashCode.calculate(17, 31, x, name, date);
  }

}