Parallel implements Predicate<Field<T>> { @Override public boolean resolve(final Field<T> field) { final Vertical<T> fvertical = new Vertical<>(this.first); final Vertical<T> svertical = new Vertical<>(this.second); final boolean both = new And<>(fvertical, svertical).resolve(field); final boolean none = new And<>( new Not<>(fvertical), new Not<>(svertical) ).resolve(field); return both || none && new Equals<>( new Slope<>(this.first), new Slope<>(this.second) ).resolve(field); } Parallel(final Line<T> first, final Line<T> second);  Parallel(final Ray<T> first, final Ray<T> second);  Parallel(final Segment<T> first, final Segment<T> second); @Override boolean resolve(final Field<T> field);  }
@Test public void resolvesTrueIfBothVertical() { MatcherAssert.assertThat( new Parallel<Double>( new VerticalLine<>(), new VerticalLine<>() ).resolve(new Decimal()), Matchers.is(true) ); }
@Test public void resolvesFalseIfOneVertical() { MatcherAssert.assertThat( new Parallel<Double>( new VerticalLine<>(), new RandomLine<>() ).resolve(new Decimal()), Matchers.is(false) ); }
@Test public void resolvesFalseIfDifferentDirs() { final Line<Double> any = new RandomLine<>(); MatcherAssert.assertThat( new Parallel<>( any, new PtDirLine<>( new RandomPoint<>(), new DifferentPoint<>(any.direction()) ) ).resolve(new Decimal()), Matchers.is(false) ); }
@Test public void resolvesTrueIfSameDirs() { final Line<Double> any = new RandomLine<>(); MatcherAssert.assertThat( new Parallel<>( any, new PtDirLine<>(new RandomPoint<>(), any.direction()) ).resolve(new Decimal()), Matchers.is(true) ); }