ClusteredRoadPath implements Collection<RoadPath> { @Pure public RoadPath toRoadPath() { if (this.paths.size() == 1) { return this.paths.iterator().next(); } return null; } ClusteredRoadPath();  ClusteredRoadPath(RoadPath... paths);  ClusteredRoadPath(Collection<? extends RoadPath> paths); @Pure double getLength(); void invert(); @Pure RoadPath first(); @Pure RoadPath last(); @Pure int getRoadSegmentCount(); @Pure RoadPath getRoadPathAt(int index); @Pure int indexOf(RoadSegment segment); @Pure int lastIndexOf(RoadSegment segment); @Pure RoadSegment getRoadSegmentAt(int index); @Pure RoadPath getPathForRoadSegmentAt(int index); @Pure Direction1D getRoadSegmentDirectionAt(int index); RoadSegment removeRoadSegmentAt(int index); @Override final boolean add(RoadPath path); @SuppressWarnings({"checkstyle:cyclomaticcomplexity", "checkstyle:npathcomplexity", "checkstyle:nestedifdepth"}) RoadPath addAndGetPath(RoadPath end); @Override boolean addAll(Collection<? extends RoadPath> col); @Override void clear(); @Override @Pure boolean contains(Object obj); @Override @Pure boolean containsAll(Collection<?> col); @Override @Pure boolean isEmpty(); @Override @Pure Iterator<RoadPath> iterator(); @Override boolean remove(Object obj); void sync(); @Override boolean removeAll(Collection<?> col); @Override boolean retainAll(Collection<?> col); @Override @Pure int size(); @Override @Pure Object[] toArray(); @Override @Pure T[] toArray(T[] array); @Override @Pure String toString(); @Pure RoadPath toRoadPath(); @Pure Iterator<RoadSegment> roadSegments();  }
@Test public void testToRoadPath() { assertNull(this.cPath.toRoadPath()); this.cPath.add(this.path1); assertEquals(1, this.cPath.size()); assertTrue(this.cPath.contains(this.path1)); assertFalse(this.cPath.contains(this.path2)); assertFalse(this.cPath.contains(this.path3)); assertSame(this.path1, this.cPath.toRoadPath()); this.cPath.add(this.path2); assertEquals(2, this.cPath.size()); assertTrue(this.cPath.contains(this.path1)); assertTrue(this.cPath.contains(this.path2)); assertFalse(this.cPath.contains(this.path3)); assertNull(this.cPath.toRoadPath()); this.cPath.add(this.path3); assertEquals(1, this.cPath.size()); assertTrue(this.cPath.contains(this.path1)); assertFalse(this.cPath.contains(this.path2)); assertFalse(this.cPath.contains(this.path3)); assertSame(this.path1, this.cPath.toRoadPath()); }