title: Java Comparable Contract
body: <p>Must I always adhere to the contract established for <code>Comparable Interface</code>?  Is there acceptable leverage when all three cases of the contract are unclear?</p>
  
  <p>The contract simply states:</p>
  
  <pre><code>If this object precedes that; return negative value
  If this object equals that; return zero
  If this object proceeds that; return positive value 
  </code></pre>
  
  <p>I desire to compare two points which are <code>Point2D</code> objects.  Comparing two points using the <code>distance(Point2D point)</code> behavior makes a <code>compareTo()</code> appear binary; Either two points have a zero distance or their distance is nonzero.</p>
  
  <p>If I were to write such a <code>compareTo()</code> behavior that overrides the default, perhaps it would be as follows:</p>
  
  <pre><code>private Point2D location;
  
  public int compareTo(Object o)
  {
      if(this.getLocation().distance(o.getLocation() == 0)
      {
          return 0;
      }
      else
      {
          return 1;
      }
  }
  </code></pre>
  
  <p>Perhaps comparing two Point2D objects would be better suited using simple behavior testing distance and not bother implementing <code>Comparable</code>.  There may even be a way to adhere to the contract I do not know.</p>