@Test public void testIterator() throws Exception { assertThat(new Resolved(EmptyPath.INSTANCE, EmptyPath.INSTANCE), new IsEmptyIterable<UriEncoded>()); assertThat(new Resolved(EmptyPath.INSTANCE, new EncodedPath(new Precoded("/"))), Matchers.contains((UriEncoded) IdempotentEncoded.EMPTY, IdempotentEncoded.EMPTY)); assertThat(new Resolved(new EncodedPath(new Precoded("/")), EmptyPath.INSTANCE), Matchers.contains((UriEncoded) IdempotentEncoded.EMPTY, IdempotentEncoded.EMPTY)); assertThat(new Resolved(new EncodedPath(new Precoded("b")), new EncodedPath(new Precoded("g"))), Matchers.contains((UriEncoded) new Encoded("g"))); assertThat(new Resolved(new EncodedPath(new Precoded("b")), new EncodedPath(new Precoded("./g"))), Matchers.contains((UriEncoded) new Encoded("g"))); assertThat(new Resolved(new EncodedPath(new Precoded("b")), new EncodedPath(new Precoded("../g"))), Matchers.contains((UriEncoded) IdempotentEncoded.PARENT, new Encoded("g"))); assertThat(new Resolved(new EncodedPath(new Precoded("b/")), new EncodedPath(new Precoded("g"))), Matchers.contains((UriEncoded) new Encoded("b"), new Encoded("g"))); assertThat(new Resolved(new EncodedPath(new Precoded("b/")), new EncodedPath(new Precoded("./g"))), Matchers.contains((UriEncoded) new Encoded("b"), new Encoded("g"))); assertThat(new Resolved(new EncodedPath(new Precoded("b/")), new EncodedPath(new Precoded("../g"))), Matchers.contains((UriEncoded) new Encoded("g"))); assertThat(new Resolved(new EncodedPath(new Precoded(".")), new EncodedPath(new Precoded("."))), Matchers.contains((UriEncoded) IdempotentEncoded.CURRENT, IdempotentEncoded.EMPTY)); assertThat(new Resolved(new EncodedPath(new Precoded("/b/c/d;p")), new EncodedPath(new Precoded("g"))), Matchers.contains((UriEncoded) IdempotentEncoded.EMPTY, new Encoded("b"), new Encoded("c"), new Encoded("g"))); assertThat(new Resolved(new EncodedPath(new Precoded("/b/c/d;p")), new EncodedPath(new Precoded("./g"))), Matchers.contains((UriEncoded) IdempotentEncoded.EMPTY, new Encoded("b"), new Encoded("c"), new Encoded("g"))); assertThat(new Resolved(new EncodedPath(new Precoded("/b/c/d;p")), new EncodedPath(new Precoded("g/"))), Matchers.contains((UriEncoded) IdempotentEncoded.EMPTY, new Encoded("b"), new Encoded("c"), new Encoded("g"), IdempotentEncoded.EMPTY)); assertThat(new Resolved(new EncodedPath(new Precoded("/b/c/d;p")), new EncodedPath(new Precoded("/g"))), Matchers.contains((UriEncoded) IdempotentEncoded.EMPTY, new Encoded("g"))); assertThat(new Resolved(new EncodedPath(new Precoded("/b/c/d;p")), new EncodedPath(new Precoded(";x"))), Matchers.contains((UriEncoded) IdempotentEncoded.EMPTY, new Encoded("b"), new Encoded("c"), new Precoded(";x"))); assertThat(new Resolved(new EncodedPath(new Precoded("/b/c/d;p")), new EncodedPath(new Precoded(""))), Matchers.contains((UriEncoded) IdempotentEncoded.EMPTY, new Encoded("b"), new Encoded("c"), new Precoded("d;p"))); assertThat(new Resolved(new EncodedPath(new Precoded("/b/c/d;p")), new EncodedPath(new Precoded("."))), Matchers.contains((UriEncoded) IdempotentEncoded.EMPTY, new Encoded("b"), new Encoded("c"), IdempotentEncoded.EMPTY)); assertThat(new Resolved(new EncodedPath(new Precoded("/b/c/d;p")), new EncodedPath(new Precoded("./"))), Matchers.contains((UriEncoded) IdempotentEncoded.EMPTY, new Encoded("b"), new Encoded("c"), IdempotentEncoded.EMPTY)); assertThat(new Resolved(new EncodedPath(new Precoded("/b/c/d;p")), new EncodedPath(new Precoded(".."))), Matchers.contains((UriEncoded) IdempotentEncoded.EMPTY, new Encoded("b"), IdempotentEncoded.EMPTY)); assertThat(new Resolved(new EncodedPath(new Precoded("/b/c/d;p")), new EncodedPath(new Precoded("../"))), Matchers.contains((UriEncoded) IdempotentEncoded.EMPTY, new Encoded("b"), IdempotentEncoded.EMPTY)); assertThat(new Resolved(new EncodedPath(new Precoded("/b/c/d;p")), new EncodedPath(new Precoded("../g"))), Matchers.contains((UriEncoded) IdempotentEncoded.EMPTY, new Encoded("b"), new Encoded("g"))); assertThat(new Resolved(new EncodedPath(new Precoded("/b/c/d;p")), new EncodedPath(new Precoded("../.."))), Matchers.contains((UriEncoded) IdempotentEncoded.EMPTY, IdempotentEncoded.EMPTY)); assertThat(new Resolved(new EncodedPath(new Precoded("/b/c/d;p")), new EncodedPath(new Precoded("../../"))), Matchers.contains((UriEncoded) IdempotentEncoded.EMPTY, IdempotentEncoded.EMPTY)); assertThat(new Resolved(new EncodedPath(new Precoded("/b/c/d;p")), new EncodedPath(new Precoded("../../g"))), Matchers.contains((UriEncoded) IdempotentEncoded.EMPTY, new Encoded("g"))); assertThat(new Resolved(new EncodedPath(new Precoded("/b/c/d;p")), new EncodedPath(new Precoded("../../../g"))), Matchers.contains((UriEncoded) IdempotentEncoded.EMPTY, new Encoded("g"))); assertThat(new Resolved(new EncodedPath(new Precoded("/b/c/d;p")), new EncodedPath(new Precoded("../../../../g"))), Matchers.contains((UriEncoded) IdempotentEncoded.EMPTY, new Encoded("g"))); assertThat(new Resolved(new EncodedPath(new Precoded("/b/c/d;p")), new EncodedPath(new Precoded("/./g"))), Matchers.contains((UriEncoded) IdempotentEncoded.EMPTY, new Encoded("g"))); assertThat(new Resolved(new EncodedPath(new Precoded("/b/c/d;p")), new EncodedPath(new Precoded("/../g"))), Matchers.contains((UriEncoded) IdempotentEncoded.EMPTY, new Encoded("g"))); assertThat(new Resolved(new EncodedPath(new Precoded("/b/c/d;p")), new EncodedPath(new Precoded("g."))), Matchers.contains((UriEncoded) IdempotentEncoded.EMPTY, new Encoded("b"), new Encoded("c"), new Encoded("g."))); assertThat(new Resolved(new EncodedPath(new Precoded("/b/c/d;p")), new EncodedPath(new Precoded(".g"))), Matchers.contains((UriEncoded) IdempotentEncoded.EMPTY, new Encoded("b"), new Encoded("c"), new Encoded(".g"))); assertThat(new Resolved(new EncodedPath(new Precoded("/b/c/d;p")), new EncodedPath(new Precoded("g.."))), Matchers.contains((UriEncoded) IdempotentEncoded.EMPTY, new Encoded("b"), new Encoded("c"), new Encoded("g.."))); assertThat(new Resolved(new EncodedPath(new Precoded("/b/c/d;p")), new EncodedPath(new Precoded("..g"))), Matchers.contains((UriEncoded) IdempotentEncoded.EMPTY, new Encoded("b"), new Encoded("c"), new Encoded("..g"))); assertThat(new Resolved(new EncodedPath(new Precoded("/b/c/d;p")), new EncodedPath(new Precoded("./../g"))), Matchers.contains((UriEncoded) IdempotentEncoded.EMPTY, new Encoded("b"), new Encoded("g"))); assertThat(new Resolved(new EncodedPath(new Precoded("/b/c/d;p")), new EncodedPath(new Precoded("./g/."))), Matchers.contains((UriEncoded) IdempotentEncoded.EMPTY, new Encoded("b"), new Encoded("c"), new Encoded("g"), IdempotentEncoded.EMPTY)); assertThat(new Resolved(new EncodedPath(new Precoded("/b/c/d;p")), new EncodedPath(new Precoded("g/./h"))), Matchers.contains((UriEncoded) IdempotentEncoded.EMPTY, new Encoded("b"), new Encoded("c"), new Encoded("g"), new Encoded("h"))); assertThat(new Resolved(new EncodedPath(new Precoded("/b/c/d;p")), new EncodedPath(new Precoded("g/../h"))), Matchers.contains((UriEncoded) IdempotentEncoded.EMPTY, new Encoded("b"), new Encoded("c"), new Encoded("h"))); assertThat(new Resolved(new EncodedPath(new Precoded("/b/c/d;p")), new EncodedPath(new Precoded("g;x=1/./y"))), Matchers.contains((UriEncoded) IdempotentEncoded.EMPTY, new Encoded("b"), new Encoded("c"), new Precoded("g;x=1"), new Encoded("y"))); assertThat(new Resolved(new EncodedPath(new Precoded("/b/c/d;p")), new EncodedPath(new Precoded("g;x=1/../y"))), Matchers.contains((UriEncoded) IdempotentEncoded.EMPTY, new Encoded("b"), new Encoded("c"), new Encoded("y"))); assertThat(new Resolved(new EncodedPath(new Precoded("b/c/d;p")), new EncodedPath(new Precoded("g"))), Matchers.contains((UriEncoded) new Encoded("b"), new Encoded("c"), new Encoded("g"))); assertThat(new Resolved(new EncodedPath(new Precoded("b/c/d;p")), new EncodedPath(new Precoded("./g"))), Matchers.contains((UriEncoded) new Encoded("b"), new Encoded("c"), new Encoded("g"))); assertThat(new Resolved(new EncodedPath(new Precoded("b/c/d;p")), new EncodedPath(new Precoded("g/"))), Matchers.contains((UriEncoded) new Encoded("b"), new Encoded("c"), new Encoded("g"), IdempotentEncoded.EMPTY)); assertThat(new Resolved(new EncodedPath(new Precoded("b/c/d;p")), new EncodedPath(new Precoded("/g"))), Matchers.contains((UriEncoded) IdempotentEncoded.EMPTY, new Encoded("g"))); assertThat(new Resolved(new EncodedPath(new Precoded("b/c/d;p")), new EncodedPath(new Precoded(";x"))), Matchers.contains((UriEncoded) new Encoded("b"), new Encoded("c"), new Precoded(";x"))); assertThat(new Resolved(new EncodedPath(new Precoded("b/c/d;p")), new EncodedPath(new Precoded(""))), Matchers.contains((UriEncoded) new Encoded("b"), new Encoded("c"), new Precoded("d;p"))); assertThat(new Resolved(new EncodedPath(new Precoded("b/c/d;p")), new EncodedPath(new Precoded("."))), Matchers.contains((UriEncoded) new Encoded("b"), new Encoded("c"), IdempotentEncoded.EMPTY)); assertThat(new Resolved(new EncodedPath(new Precoded("b/c/d;p")), new EncodedPath(new Precoded("./"))), Matchers.contains((UriEncoded) new Encoded("b"), new Encoded("c"), IdempotentEncoded.EMPTY)); assertThat(new Resolved(new EncodedPath(new Precoded("b/c/d;p")), new EncodedPath(new Precoded(".."))), Matchers.contains((UriEncoded) new Encoded("b"), IdempotentEncoded.EMPTY)); assertThat(new Resolved(new EncodedPath(new Precoded("b/c/d;p")), new EncodedPath(new Precoded("../"))), Matchers.contains((UriEncoded) new Encoded("b"), IdempotentEncoded.EMPTY)); assertThat(new Resolved(new EncodedPath(new Precoded("b/c/d;p")), new EncodedPath(new Precoded("../g"))), Matchers.contains((UriEncoded) new Encoded("b"), new Encoded("g"))); assertThat(new Resolved(new EncodedPath(new Precoded("b/c/d;p")), new EncodedPath(new Precoded("../.."))), Matchers.contains((UriEncoded) IdempotentEncoded.CURRENT, IdempotentEncoded.EMPTY)); assertThat(new Resolved(new EncodedPath(new Precoded("b/c/d;p")), new EncodedPath(new Precoded("../../"))), Matchers.contains((UriEncoded) IdempotentEncoded.CURRENT, IdempotentEncoded.EMPTY)); assertThat(new Resolved(new EncodedPath(new Precoded("b/c/d;p")), new EncodedPath(new Precoded("../../g"))), Matchers.contains((UriEncoded) new Encoded("g"))); assertThat(new Resolved(new EncodedPath(new Precoded("b/c/d;p")), new EncodedPath(new Precoded("../../../g"))), Matchers.contains((UriEncoded) IdempotentEncoded.PARENT, new Encoded("g"))); assertThat(new Resolved(new EncodedPath(new Precoded("b/c/d;p")), new EncodedPath(new Precoded("../../../../g"))), Matchers.contains((UriEncoded) IdempotentEncoded.PARENT, IdempotentEncoded.PARENT, new Encoded("g"))); assertThat(new Resolved(new EncodedPath(new Precoded("b/c/d;p")), new EncodedPath(new Precoded("/./g"))), Matchers.contains((UriEncoded) IdempotentEncoded.EMPTY, new Encoded("g"))); assertThat(new Resolved(new EncodedPath(new Precoded("b/c/d;p")), new EncodedPath(new Precoded("/../g"))), Matchers.contains((UriEncoded) IdempotentEncoded.EMPTY, new Encoded("g"))); assertThat(new Resolved(new EncodedPath(new Precoded("b/c/d;p")), new EncodedPath(new Precoded("g."))), Matchers.contains((UriEncoded) new Encoded("b"), new Encoded("c"), new Encoded("g."))); assertThat(new Resolved(new EncodedPath(new Precoded("b/c/d;p")), new EncodedPath(new Precoded(".g"))), Matchers.contains((UriEncoded) new Encoded("b"), new Encoded("c"), new Encoded(".g"))); assertThat(new Resolved(new EncodedPath(new Precoded("b/c/d;p")), new EncodedPath(new Precoded("g.."))), Matchers.contains((UriEncoded) new Encoded("b"), new Encoded("c"), new Encoded("g.."))); assertThat(new Resolved(new EncodedPath(new Precoded("b/c/d;p")), new EncodedPath(new Precoded("..g"))), Matchers.contains((UriEncoded) new Encoded("b"), new Encoded("c"), new Encoded("..g"))); assertThat(new Resolved(new EncodedPath(new Precoded("b/c/d;p")), new EncodedPath(new Precoded("./../g"))), Matchers.contains((UriEncoded) new Encoded("b"), new Encoded("g"))); assertThat(new Resolved(new EncodedPath(new Precoded("b/c/d;p")), new EncodedPath(new Precoded("./g/."))), Matchers.contains((UriEncoded) new Encoded("b"), new Encoded("c"), new Encoded("g"), IdempotentEncoded.EMPTY)); assertThat(new Resolved(new EncodedPath(new Precoded("b/c/d;p")), new EncodedPath(new Precoded("g/./h"))), Matchers.contains((UriEncoded) new Encoded("b"), new Encoded("c"), new Encoded("g"), new Encoded("h"))); assertThat(new Resolved(new EncodedPath(new Precoded("b/c/d;p")), new EncodedPath(new Precoded("g/../h"))), Matchers.contains((UriEncoded) new Encoded("b"), new Encoded("c"), new Encoded("h"))); assertThat(new Resolved(new EncodedPath(new Precoded("b/c/d;p")), new EncodedPath(new Precoded("g;x=1/./y"))), Matchers.contains((UriEncoded) new Encoded("b"), new Encoded("c"), new Precoded("g;x=1"), new Encoded("y"))); assertThat(new Resolved(new EncodedPath(new Precoded("b/c/d;p")), new EncodedPath(new Precoded("g;x=1/../y"))), Matchers.contains((UriEncoded) new Encoded("b"), new Encoded("c"), new Encoded("y"))); }
@Override public Iterator<UriEncoded> iterator() { if (mReference.isEmpty()) { return Collections.unmodifiableList(normalize(mBase.iterator())).iterator(); } if (mReference.isAbsolute()) { return Collections.unmodifiableList(normalize(mReference.iterator())).iterator(); } LinkedList<UriEncoded> segments = normalize(mBase.iterator()); if (!segments.isEmpty()) { UriEncoded last = segments.getLast(); if (!IdempotentEncoded.EMPTY.equals(last) && !IdempotentEncoded.CURRENT.equals(last) && !IdempotentEncoded.PARENT.equals(last)) { segments.removeLast(); } } return Collections.unmodifiableList(normalize(new SerialIterator<>(segments.iterator(), mReference.iterator()))).iterator(); }
Resolved implements Path { @Override public Iterator<UriEncoded> iterator() { if (mReference.isEmpty()) { return Collections.unmodifiableList(normalize(mBase.iterator())).iterator(); } if (mReference.isAbsolute()) { return Collections.unmodifiableList(normalize(mReference.iterator())).iterator(); } LinkedList<UriEncoded> segments = normalize(mBase.iterator()); if (!segments.isEmpty()) { UriEncoded last = segments.getLast(); if (!IdempotentEncoded.EMPTY.equals(last) && !IdempotentEncoded.CURRENT.equals(last) && !IdempotentEncoded.PARENT.equals(last)) { segments.removeLast(); } } return Collections.unmodifiableList(normalize(new SerialIterator<>(segments.iterator(), mReference.iterator()))).iterator(); } }
Resolved implements Path { @Override public Iterator<UriEncoded> iterator() { if (mReference.isEmpty()) { return Collections.unmodifiableList(normalize(mBase.iterator())).iterator(); } if (mReference.isAbsolute()) { return Collections.unmodifiableList(normalize(mReference.iterator())).iterator(); } LinkedList<UriEncoded> segments = normalize(mBase.iterator()); if (!segments.isEmpty()) { UriEncoded last = segments.getLast(); if (!IdempotentEncoded.EMPTY.equals(last) && !IdempotentEncoded.CURRENT.equals(last) && !IdempotentEncoded.PARENT.equals(last)) { segments.removeLast(); } } return Collections.unmodifiableList(normalize(new SerialIterator<>(segments.iterator(), mReference.iterator()))).iterator(); } Resolved(Path base, Path reference); }
Resolved implements Path { @Override public Iterator<UriEncoded> iterator() { if (mReference.isEmpty()) { return Collections.unmodifiableList(normalize(mBase.iterator())).iterator(); } if (mReference.isAbsolute()) { return Collections.unmodifiableList(normalize(mReference.iterator())).iterator(); } LinkedList<UriEncoded> segments = normalize(mBase.iterator()); if (!segments.isEmpty()) { UriEncoded last = segments.getLast(); if (!IdempotentEncoded.EMPTY.equals(last) && !IdempotentEncoded.CURRENT.equals(last) && !IdempotentEncoded.PARENT.equals(last)) { segments.removeLast(); } } return Collections.unmodifiableList(normalize(new SerialIterator<>(segments.iterator(), mReference.iterator()))).iterator(); } Resolved(Path base, Path reference); @Override boolean isEmpty(); @Override boolean isAbsolute(); @Override Iterator<UriEncoded> iterator(); }
Resolved implements Path { @Override public Iterator<UriEncoded> iterator() { if (mReference.isEmpty()) { return Collections.unmodifiableList(normalize(mBase.iterator())).iterator(); } if (mReference.isAbsolute()) { return Collections.unmodifiableList(normalize(mReference.iterator())).iterator(); } LinkedList<UriEncoded> segments = normalize(mBase.iterator()); if (!segments.isEmpty()) { UriEncoded last = segments.getLast(); if (!IdempotentEncoded.EMPTY.equals(last) && !IdempotentEncoded.CURRENT.equals(last) && !IdempotentEncoded.PARENT.equals(last)) { segments.removeLast(); } } return Collections.unmodifiableList(normalize(new SerialIterator<>(segments.iterator(), mReference.iterator()))).iterator(); } Resolved(Path base, Path reference); @Override boolean isEmpty(); @Override boolean isAbsolute(); @Override Iterator<UriEncoded> iterator();  }