Clover coverage report - PLT Utilities Test Coverage (plt-20120304-r5436)
Coverage timestamp: Sat Mar 3 2012 22:01:56 CST
file stats: LOC: 106   Methods: 32
NCLOC: 48   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
ImmutableCollection.java - 12.5% 12.5% 12.5%
coverage coverage
 1    /*BEGIN_COPYRIGHT_BLOCK*
 2   
 3    PLT Utilities BSD License
 4   
 5    Copyright (c) 2007-2010 JavaPLT group at Rice University
 6    All rights reserved.
 7   
 8    Developed by: Java Programming Languages Team
 9    Rice University
 10    http://www.cs.rice.edu/~javaplt/
 11   
 12    Redistribution and use in source and binary forms, with or without modification, are permitted
 13    provided that the following conditions are met:
 14   
 15    - Redistributions of source code must retain the above copyright notice, this list of conditions
 16    and the following disclaimer.
 17    - Redistributions in binary form must reproduce the above copyright notice, this list of
 18    conditions and the following disclaimer in the documentation and/or other materials provided
 19    with the distribution.
 20    - Neither the name of the JavaPLT group, Rice University, nor the names of the library's
 21    contributors may be used to endorse or promote products derived from this software without
 22    specific prior written permission.
 23   
 24    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
 25    IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
 26    FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND
 27    CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 28    DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 29    DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
 30    IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 31    OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 32   
 33    *END_COPYRIGHT_BLOCK*/
 34   
 35    package edu.rice.cs.plt.collect;
 36   
 37    import java.util.Iterator;
 38    import java.util.Collection;
 39    import java.util.AbstractCollection;
 40    import java.io.Serializable;
 41    import edu.rice.cs.plt.iter.SizedIterable;
 42    import edu.rice.cs.plt.iter.IterUtil;
 43    import edu.rice.cs.plt.iter.ImmutableIterator;
 44    import edu.rice.cs.plt.object.Composite;
 45    import edu.rice.cs.plt.object.ObjectUtil;
 46   
 47    /**
 48    * Wraps a collection in an immutable interface. Similar to
 49    * {@link java.util.Collections#unmodifiableCollection}; defined here to allow subclassing.
 50    * Since instances of this class must <em>not</em> be equal to some collections (such as {@code Set}s
 51    * and {@code List}s -- allowing the equivalence would violate symmetry), the {@code equals()} and
 52    * {@code hashCode()} methods are not implemented, and inherit the {@link Object} defaults.
 53    * Subclasses can also invoke the overridden methods in {@link AbstractCollection} to use the
 54    * default implementations there by invoking, for example, {@link #abstractCollectionAddAll}
 55    * (see {@link java.util.AbstractCollection} for details on the default implementations).
 56    */
 57    public class ImmutableCollection<T> extends AbstractCollection<T>
 58    implements SizedIterable<T>, Composite, Serializable {
 59   
 60    protected Collection<? extends T> _delegate;
 61   
 62  80 public ImmutableCollection(Collection<? extends T> collection) { _delegate = collection; }
 63   
 64  0 public int compositeHeight() { return ObjectUtil.compositeHeight(_delegate) + 1; }
 65  0 public int compositeSize() { return ObjectUtil.compositeSize(_delegate) + 1; }
 66   
 67  1 public Iterator<T> iterator() { return ImmutableIterator.make(_delegate.iterator()); }
 68   
 69  0 @Override public boolean isEmpty() { return _delegate.isEmpty(); }
 70  1 public int size() { return _delegate.size(); }
 71  0 public int size(int bound) { return IterUtil.sizeOf(_delegate, bound); }
 72  0 public boolean isInfinite() { return IterUtil.isInfinite(_delegate); }
 73  0 public boolean hasFixedSize() { return IterUtil.hasFixedSize(_delegate); }
 74  0 public boolean isStatic() { return IterUtil.isStatic(_delegate); }
 75   
 76  0 @Override public boolean contains(Object o) { return _delegate.contains(o); }
 77  0 @Override public boolean containsAll(Collection<?> c) { return _delegate.containsAll(c); }
 78  0 @Override public Object[] toArray() { return _delegate.toArray(); }
 79  0 @Override public <S> S[] toArray(S[] a) { return _delegate.toArray(a); }
 80   
 81  0 @Override public boolean add(T o) { throw new UnsupportedOperationException(); }
 82  0 @Override public boolean addAll(Collection<? extends T> c) { throw new UnsupportedOperationException(); }
 83  0 @Override public boolean remove(Object o) { throw new UnsupportedOperationException(); }
 84  0 @Override public boolean retainAll(Collection<?> c) { throw new UnsupportedOperationException(); }
 85  0 @Override public boolean removeAll(Collection<?> c) { throw new UnsupportedOperationException(); }
 86  0 @Override public void clear() { throw new UnsupportedOperationException(); }
 87   
 88  0 protected boolean abstractCollectionIsEmpty() { return super.isEmpty(); }
 89  0 protected boolean abstractCollectionContains(Object o) { return super.contains(o); }
 90  0 protected Object[] abstractCollectionToArray() { return super.toArray(); }
 91  0 protected <S> S[] abstractCollectionToArray(S[] a) { return super.toArray(a); }
 92  0 protected boolean abstractCollectionRemove(T o) { return super.remove(o); }
 93  0 protected boolean abstractCollectionContainsAll(Collection<?> c) { return super.containsAll(c); }
 94  0 protected boolean abstractCollectionAddAll(Collection<? extends T> c) { return super.addAll(c); }
 95  0 protected boolean abstractCollectionRetainAll(Collection<?> c) { return super.retainAll(c); }
 96  0 protected boolean abstractCollectionRemoveAll(Collection<?> c) { return super.removeAll(c); }
 97  0 protected void abstractCollectionClear() { super.clear(); }
 98   
 99  6 @Override public String toString() { return _delegate.toString(); }
 100   
 101    /** Call the constructor (allows {@code T} to be inferred). */
 102  0 public static <T> ImmutableCollection<T> make(Collection<? extends T> collection) {
 103  0 return new ImmutableCollection<T>(collection);
 104    }
 105   
 106    }