Equals implements Predicate<Field<T>> { @Override public boolean resolve(final Field<T> field) { return field.equals(this.first, this.second); } Equals(final Scalar<T> first, final Scalar<T> second); @Override boolean resolve(final Field<T> field);  }
@Test public void resolvesToTrueWhenEqual() { final Object obj = new Object(); final Scalar<Object> first = new Scalar.Default<>(obj); final Scalar<Object> second = new Scalar.Default<>(obj); final Field<Object> field = new MkField<>(new Object(), new Object()); MatcherAssert.assertThat( new Equals<>(first, second).resolve(field), Matchers.is(true) ); }
@Test public void resolvesToFalseWhenNotEqual() { final Scalar<Object> first = new Scalar.Default<>(new Object()); final Scalar<Object> second = new Scalar.Default<>(new Object()); final Field<Object> field = new MkField<>(new Object(), new Object()); MatcherAssert.assertThat( new Equals<>(first, second).resolve(field), Matchers.is(false) ); }