Equal implements Predicate<Field<T>> { @Override public boolean resolve(final Field<T> field) { return new And<>( new Parallel<>(this.first, this.second), new PointInLine<>(this.first.point(), this.second) ).resolve(field); } Equal(final Line<T> first, final Line<T> second); @Override boolean resolve(final Field<T> field);  }
@Test public void resolvesTrueIfSameLine() { final Line<Double> line = new RandomLine<>(); MatcherAssert.assertThat( new Equal<>(line, line).resolve(new Decimal()), Matchers.is(true) ); }
@Test public void resolvesTrueIfEqualLines() { final Line<Double> line = new RandomLine<>(); final InLinePoint<Double> first = new InLinePoint<>(line); MatcherAssert.assertThat( new Equal<>( line, new PtsLine<>(first, new InLinePoint<>(line, new Different<>(first.xcoor()))) ).resolve(new Decimal()), Matchers.is(true) ); }
@Test public void resolvesFalseIfOnlyParallel() { final Line<Double> line = new RandomLine<>(); MatcherAssert.assertThat( new Equal<>( line, new PtsLine<>(new OutsideLinePoint<>(line), line.point()) ).resolve(new Decimal()), Matchers.is(false) ); }