Injectable { @Override public boolean equals(Object o) { if (this == o) return true; if (o == null) { return false; } if (getClass() != o.getClass()) { return false; } final Injectable<?> that = (Injectable<?>) o; return cls.equals(that.cls) && Objects.equals(supplier, that.supplier); } Injectable(Class<T> cls, Supplier<T> supplier); Class<T> get(); Supplier<T> supplier(); @Override boolean equals(Object o); @Override int hashCode();  }
@Test void testEquals() { final Injectable<Integer> injectable1 = new Injectable<>(Integer.class, SUPPLIER); final Injectable<Integer> injectable2 = new Injectable<>(Integer.class, SUPPLIER); final Injectable<Integer> injectable3 = new Injectable<>(Integer.class, () -> 42); final Injectable<String> injectable4 = new Injectable<>(String.class, null); assertEquals(injectable1, injectable1); assertEquals(injectable2, injectable2); assertEquals(injectable1, injectable2); assertEquals(injectable2, injectable1); assertNotEquals(injectable1, injectable3); assertNotEquals(injectable3, injectable4); assertNotEquals(injectable1, injectable4); assertFalse(injectable1.equals(1)); assertFalse(injectable1.equals(null)); }