Use Guava's UnmodifiableIterator 58/26558/2
authorRobert Varga <rovarga@cisco.com>
Sat, 5 Sep 2015 20:13:59 +0000 (22:13 +0200)
committerGerrit Code Review <gerrit@opendaylight.org>
Mon, 7 Sep 2015 08:03:36 +0000 (08:03 +0000)
It saves a bit of code, so let's use to get the code reduction.

Change-Id: I8b515539bd40ee5f684489a4bff8d96534bf82be
Signed-off-by: Robert Varga <rovarga@cisco.com>
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/SchemaPath.java

index cc8f6feebd684e317a80085ad86822a431b97d8b..352221c98742e4cf906383f66b80a3cf74fc4cbc 100644 (file)
@@ -12,6 +12,7 @@ import com.google.common.base.MoreObjects.ToStringHelper;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Iterables;
+import com.google.common.collect.UnmodifiableIterator;
 import java.util.Arrays;
 import java.util.Iterator;
 import java.util.List;
@@ -245,7 +246,7 @@ public abstract class SchemaPath implements Immutable {
         return new Iterable<QName>() {
             @Override
             public Iterator<QName> iterator() {
-                return new Iterator<QName>() {
+                return new UnmodifiableIterator<QName>() {
                     private SchemaPath current = SchemaPath.this;
 
                     @Override
@@ -263,11 +264,6 @@ public abstract class SchemaPath implements Immutable {
                             throw new NoSuchElementException("No more elements available");
                         }
                     }
-
-                    @Override
-                    public void remove() {
-                        throw new UnsupportedOperationException("Component removal not supported");
-                    }
                 };
             }
         };