private static boolean isResult(final RyaType query, final RyaType result) { return (query == null) || query.equals(result); }
private static boolean isResult(final RyaType query, final RyaType result) { return (query == null) || query.equals(result); }
/** * Tests for equality using the equals method of the enclosed RyaType. * @param o Object to compare with * @return true if both objects are RyaTypeWritables containing equivalent * RyaTypes. */ @Override public boolean equals(final Object o) { if (o == this) { return true; } if (o == null || !(o instanceof RyaTypeWritable)) { return false; } final RyaType rtThis = ryatype; final RyaType rtOther = ((RyaTypeWritable) o).ryatype; if (rtThis == null) { return rtOther == null; } else { return rtThis.equals(rtOther); } }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; if (!super.equals(o)) return false; RyaTypeRange that = (RyaTypeRange) o; if (start != null ? !start.equals(that.start) : that.start != null) return false; if (stop != null ? !stop.equals(that.stop) : that.stop != null) return false; return true; }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; if (!super.equals(o)) return false; RyaTypeRange that = (RyaTypeRange) o; if (start != null ? !start.equals(that.start) : that.start != null) return false; return stop != null ? stop.equals(that.stop) : that.stop == null; }
/** * Tests for equality using the equals method of the enclosed RyaType. * @param o Object to compare with * @return true if both objects are RyaTypeWritables containing equivalent * RyaTypes. */ @Override public boolean equals(Object o) { if (o == this) { return true; } if (o == null || !(o instanceof RyaTypeWritable)) { return false; } RyaType rtThis = ryatype; RyaType rtOther = ((RyaTypeWritable) o).ryatype; if (rtThis == null) { return rtOther == null; } else { return rtThis.equals(rtOther); } }
return false; if (object != null ? !object.equals(that.object) : that.object != null) { return false;
return false; if (object != null ? !object.equals(that.object) : that.object != null) { return false;
@Test public void testEqualsNullFields() throws Exception { Assert.assertFalse("equals(null) should return false.", a.equals(null)); Assert.assertFalse("Same data, one null datatype should be unequal.", a.equals(nullType)); Assert.assertFalse("Same datatype, one null data should be unequal.", a.equals(nullData)); Assert.assertFalse("Same datatype, data, one null lang should be unequal.", aLang.equals(nullLang)); final RyaType sameNull = new RyaType(null, null); Assert.assertTrue("Matching null fields should be equal.", sameNull.equals(nullBoth)); }
@Test public void testEquals() throws Exception { Assert.assertTrue("Same data and datatype should be equal.", a.equals(same)); Assert.assertFalse("Same data, different datatype should be unequal.", a.equals(aIri)); Assert.assertFalse("Same datatype, different data should be unequal.", a.equals(b)); }
@Test public void testEqualsCompareToConsistency() throws Exception { Assert.assertEquals("equals and compareTo inconsistent for matching values and types.", a.equals(same), a.compareTo(same) == 0); Assert.assertEquals("equals and compareTo inconsistent for different values with same types.", a.equals(b), a.compareTo(b) == 0); Assert.assertEquals("equals and compareTo inconsistent for same values having different types.", a.equals(aIri), a.compareTo(aIri) == 0); Assert.assertEquals("equals and compareTo inconsistent for different values and different types.", a.equals(bIri), a.compareTo(bIri) == 0); Assert.assertEquals("equals and compareTo inconsistent for different lang and same types/data.", aLang.equals(bLang), aLang.compareTo(bLang) == 0); }