Clover coverage report - PLT Utilities Test Coverage (plt-20120304-r5436)
Coverage timestamp: Sat Mar 3 2012 22:01:56 CST
file stats: LOC: 110   Methods: 21
NCLOC: 55   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
ImmutableRelation.java 0% 0% 0% 0%
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.Collection;
 38    import edu.rice.cs.plt.tuple.Pair;
 39   
 40    /**
 41    * Wraps a relation in an immutable interface. Analogous to {@link java.util.Collections#unmodifiableMap}.
 42    * Note that only only <em>this</em> interface with the data is immutable -- if the original data
 43    * structure is mutable, a client with direct access to that structure can still mutate it.
 44    * Subclasses can invoke the overridden methods in {@link java.util.AbstractCollection} to use the
 45    * default implementations there by invoking, for example, {@link #abstractCollectionAddAll}
 46    * (see {@link java.util.AbstractCollection} for details on the default implementations).
 47    */
 48    public class ImmutableRelation<T1, T2> extends DelegatingRelation<T1, T2> {
 49   
 50    private ImmutableRelation<T2, T1> _inverse; // may be null if not yet created
 51   
 52  0 public ImmutableRelation(Relation<T1, T2> relation) { super(relation); _inverse = null; }
 53   
 54  0 private ImmutableRelation(Relation<T1, T2> relation, ImmutableRelation<T2, T1> inverse) {
 55  0 super(relation);
 56  0 _inverse = inverse;
 57    }
 58   
 59  0 public boolean add(Pair<T1, T2> o) { throw new UnsupportedOperationException(); }
 60  0 public boolean remove(Object o) { throw new UnsupportedOperationException(); }
 61  0 public boolean addAll(Collection<? extends Pair<T1, T2>> c) { throw new UnsupportedOperationException(); }
 62  0 public boolean retainAll(Collection<?> c) { throw new UnsupportedOperationException(); }
 63  0 public boolean removeAll(Collection<?> c) { throw new UnsupportedOperationException(); }
 64  0 public void clear() { throw new UnsupportedOperationException(); }
 65   
 66  0 public boolean contains(T1 first, T2 second) {
 67  0 return _delegate.contains(first, second);
 68    }
 69  0 public boolean add(T1 first, T2 second) { throw new UnsupportedOperationException(); }
 70  0 public boolean remove(T1 first, T2 second) { throw new UnsupportedOperationException(); }
 71   
 72  0 public Relation<T2, T1> inverse() {
 73  0 if (_inverse == null) {
 74  0 _inverse = new ImmutableRelation<T2, T1>(_delegate.inverse(), this);
 75    }
 76  0 return _inverse;
 77    }
 78   
 79  0 public PredicateSet<T1> firstSet() {
 80  0 return new ImmutableSet<T1>(_delegate.firstSet());
 81    }
 82  0 public boolean containsFirst(T1 first) {
 83  0 return _delegate.containsFirst(first);
 84    }
 85  0 public PredicateSet<T2> matchFirst(T1 first) {
 86  0 return new ImmutableSet<T2>(_delegate.matchFirst(first));
 87    }
 88  0 public PredicateSet<T2> excludeFirsts() {
 89  0 return new ImmutableSet<T2>(_delegate.excludeFirsts());
 90    }
 91   
 92  0 public PredicateSet<T2> secondSet() {
 93  0 return new ImmutableSet<T2>(_delegate.secondSet());
 94    }
 95  0 public boolean containsSecond(T2 second) {
 96  0 return _delegate.containsSecond(second);
 97    }
 98  0 public PredicateSet<T1> matchSecond(T2 second) {
 99  0 return new ImmutableSet<T1>(_delegate.matchSecond(second));
 100    }
 101  0 public PredicateSet<T1> excludeSeconds() {
 102  0 return new ImmutableSet<T1>(_delegate.excludeSeconds());
 103    }
 104   
 105    /** Call the constructor (allows {@code T1} and {@code T2} to be inferred). */
 106  0 public static <T1, T2> ImmutableRelation<T1, T2> make(Relation<T1, T2> relation) {
 107  0 return new ImmutableRelation<T1, T2>(relation);
 108    }
 109   
 110    }