@Test public void testEquals() { Offset o1 = new Offset(0, 1); Offset o2 = new Offset(1, 2); Offset o3 = new Offset(0, 2); Offset o4 = new Offset(0, 2); assertEquals(o1, o1); assertEquals(o3, o4); assertNotEquals(o1, null); assertNotEquals(o1, o2); assertNotEquals(o1, o3); assertNotEquals(o1, "other class"); }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } Offset other = (Offset) obj; if (begin != other.begin) { return false; } if (end != other.end) { return false; } return true; }
Offset implements Comparable<Offset> { @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } Offset other = (Offset) obj; if (begin != other.begin) { return false; } if (end != other.end) { return false; } return true; } }
Offset implements Comparable<Offset> { @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } Offset other = (Offset) obj; if (begin != other.begin) { return false; } if (end != other.end) { return false; } return true; } Offset(int begin, int end); }
Offset implements Comparable<Offset> { @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } Offset other = (Offset) obj; if (begin != other.begin) { return false; } if (end != other.end) { return false; } return true; } Offset(int begin, int end); int getBegin(); int getEnd(); @Override int hashCode(); @Override boolean equals(Object obj); @Override int compareTo(Offset o); }
Offset implements Comparable<Offset> { @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } Offset other = (Offset) obj; if (begin != other.begin) { return false; } if (end != other.end) { return false; } return true; } Offset(int begin, int end); int getBegin(); int getEnd(); @Override int hashCode(); @Override boolean equals(Object obj); @Override int compareTo(Offset o);  }