@Test public void equals() { Context context1 = mockContext(); Context context2 = mockContext(); Resource r = mockResource(); replay(); Resource r1 = new ContextResource(context1, "foo"); Resource r2 = new ContextResource(context1, "foo"); Resource r3 = new ContextResource(context2, "foo"); Resource r4 = new ContextResource(context1, "bar"); assertTrue(r1.equals(r2)); assertFalse(r1.equals(r3)); assertFalse(r1.equals(r4)); assertFalse(r1.equals(null)); assertTrue(r1.equals(r1)); assertFalse(r1.equals(r)); verify(); }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; final ContextResource other = (ContextResource) obj; return context == other.context && getPath().equals(other.getPath()); }
ContextResource extends AbstractResource { @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; final ContextResource other = (ContextResource) obj; return context == other.context && getPath().equals(other.getPath()); } }
ContextResource extends AbstractResource { @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; final ContextResource other = (ContextResource) obj; return context == other.context && getPath().equals(other.getPath()); } ContextResource(Context context, String path); }
ContextResource extends AbstractResource { @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; final ContextResource other = (ContextResource) obj; return context == other.context && getPath().equals(other.getPath()); } ContextResource(Context context, String path); @Override String toString(); URL toURL(); @Override int hashCode(); @Override boolean equals(Object obj); }
ContextResource extends AbstractResource { @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; final ContextResource other = (ContextResource) obj; return context == other.context && getPath().equals(other.getPath()); } ContextResource(Context context, String path); @Override String toString(); URL toURL(); @Override int hashCode(); @Override boolean equals(Object obj);  }