Propagate @Nonnull and @Nullable annotations
[yangtools.git] / common / util / src / main / java / org / opendaylight / yangtools / util / UnmodifiableCollection.java
index dc090a4c5bb90dd9f4f18e9cfa2980c340072470..96895025b03766a5f5696a7ec9b04b9ee21b953e 100644 (file)
@@ -24,10 +24,9 @@ import javax.annotation.Nonnull;
  * {@link Collections#unmodifiableCollection(Collection)}, this class checks its
  * argument to ensure multiple encapsulation does not occur.
  *
- * this class checks
+ * <p>This class checks
  * the argument so it prevents multiple encapsulation. Subclasses of
  * {@link ImmutableCollection} are also recognized and not encapsulated.
- * An attempt is also made to identi
  *
  * @param <E> the type of elements in this collection
  */
@@ -37,7 +36,7 @@ public final class UnmodifiableCollection<E> implements Collection<E>, Serializa
     private static final Collection<Class<?>> SINGLETON_CLASSES;
 
     static {
-        UNMODIFIABLE_COLLECTION_CLASS = Collections.unmodifiableCollection(new ArrayList<Object>()).getClass();
+        UNMODIFIABLE_COLLECTION_CLASS = Collections.unmodifiableCollection(new ArrayList<>()).getClass();
 
         final Builder<Class<?>> b = ImmutableSet.builder();
         b.add(Collections.singleton(null).getClass());
@@ -69,6 +68,7 @@ public final class UnmodifiableCollection<E> implements Collection<E>, Serializa
         return new UnmodifiableCollection<>(collection);
     }
 
+    @Nonnull
     @Override
     public Iterator<E> iterator() {
         return Iterators.unmodifiableIterator(delegate.iterator());
@@ -95,12 +95,12 @@ public final class UnmodifiableCollection<E> implements Collection<E>, Serializa
     }
 
     @Override
-    public <T> T[] toArray(final T[] a) {
+    public <T> T[] toArray(@Nonnull final T[] a) {
         return delegate.toArray(a);
     }
 
     @Override
-    public boolean containsAll(final Collection<?> c) {
+    public boolean containsAll(@Nonnull final Collection<?> c) {
         return delegate.containsAll(c);
     }
 
@@ -110,7 +110,7 @@ public final class UnmodifiableCollection<E> implements Collection<E>, Serializa
     }
 
     @Override
-    public boolean addAll(final Collection<? extends E> c) {
+    public boolean addAll(@Nonnull final Collection<? extends E> c) {
         throw new UnsupportedOperationException();
     }
 
@@ -120,12 +120,12 @@ public final class UnmodifiableCollection<E> implements Collection<E>, Serializa
     }
 
     @Override
-    public boolean removeAll(final Collection<?> c) {
+    public boolean removeAll(@Nonnull final Collection<?> c) {
         throw new UnsupportedOperationException();
     }
 
     @Override
-    public boolean retainAll(final Collection<?> c) {
+    public boolean retainAll(@Nonnull final Collection<?> c) {
         throw new UnsupportedOperationException();
     }
 
@@ -136,8 +136,6 @@ public final class UnmodifiableCollection<E> implements Collection<E>, Serializa
 
     @Override
     public String toString() {
-        final StringBuffer sb = new StringBuffer("UnmodifiableCollection{");
-        sb.append(delegate);
-        return sb.toString();
+        return "UnmodifiableCollection{" + delegate + "}";
     }
 }