title: Correct hashcode implementation for Colors
body: <p>I have a class:</p>
  
  <pre><code>public class Color {
      private double red;
      private double green;
      private double blue;
  }
  </code></pre>
  
  <p>with such <em>equals</em> method:</p>
  
  <pre><code>public boolean equals(Object o) {
      if (this == o) {
          return true;
      }
      if (o == null || getClass() != o.getClass()) {
          return false;
      }
  
      Color color = (Color) o;
  
      if (Math.abs(color.red - red) &lt; COLOR_TRESHOLD) {
          return false;
      }
      if (Math.abs(color.green - green) &lt; COLOR_TRESHOLD) {
          return false;
      }
      return Math.abs(color.blue - blue) &lt; COLOR_TRESHOLD;
  }
  </code></pre>
  
  <p>So, as you can see I would like similar colors to be equivalent.
  My question is how to create correct <em>hashcode</em> implementation for this case. 
  Of course I could return constant value. But it seems to be not a good idea.</p>