Coverage Report - org.dishevelled.graph.impl.AbstractMapDecorator
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractMapDecorator
54%
12/22
50%
1/2
1.125
 
 1  
 /*
 2  
 
 3  
     dsh-graph  Directed graph interface and implementation.
 4  
     Copyright (c) 2004-2013 held jointly by the individual authors.
 5  
 
 6  
     This library is free software; you can redistribute it and/or modify it
 7  
     under the terms of the GNU Lesser General Public License as published
 8  
     by the Free Software Foundation; either version 3 of the License, or (at
 9  
     your option) any later version.
 10  
 
 11  
     This library is distributed in the hope that it will be useful, but WITHOUT
 12  
     ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
 13  
     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
 14  
     License for more details.
 15  
 
 16  
     You should have received a copy of the GNU Lesser General Public License
 17  
     along with this library;  if not, write to the Free Software Foundation,
 18  
     Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA.
 19  
 
 20  
     > http://www.fsf.org/licensing/licenses/lgpl.html
 21  
     > http://www.opensource.org/licenses/lgpl-license.php
 22  
 
 23  
 */
 24  
 package org.dishevelled.graph.impl;
 25  
 
 26  
 import java.util.Collection;
 27  
 import java.util.Map;
 28  
 import java.util.Set;
 29  
 
 30  
 /**
 31  
  * Abstract map that decorates an instance of <code>Map</code>.
 32  
  *
 33  
  * @param <K> map key type
 34  
  * @param <V> map value type
 35  
  * @author  Michael Heuer
 36  
  * @version $Revision$ $Date$
 37  
  */
 38  
 abstract class AbstractMapDecorator<K, V>
 39  
     implements Map<K, V>
 40  
 {
 41  
     /** Map this decorator decorates. */
 42  
     private final Map<K, V> map;
 43  
 
 44  
 
 45  
     /**
 46  
      * Create a new abstract map that
 47  
      * decorates the specified map.
 48  
      *
 49  
      * @param map map to decorate, must not be null
 50  
      */
 51  
     protected AbstractMapDecorator(final Map<K, V> map)
 52  135
     {
 53  135
         if (map == null)
 54  
         {
 55  0
             throw new IllegalArgumentException("map must not be null");
 56  
         }
 57  135
         this.map = map;
 58  135
     }
 59  
 
 60  
 
 61  
     /**
 62  
      * Return a reference to the map this decorator decorates.
 63  
      *
 64  
      * @return a reference to the map this decorator decorates
 65  
      */
 66  
     protected final Map<K, V> getMap()
 67  
     {
 68  0
         return map;
 69  
     }
 70  
 
 71  
     /** {@inheritDoc} */
 72  
     public void clear()
 73  
     {
 74  0
         map.clear();
 75  0
     }
 76  
 
 77  
     /** {@inheritDoc} */
 78  
     public boolean containsKey(final Object key)
 79  
     {
 80  9
         return map.containsKey(key);
 81  
     }
 82  
 
 83  
     /** {@inheritDoc} */
 84  
     public boolean containsValue(final Object value)
 85  
     {
 86  0
         return map.containsValue(value);
 87  
     }
 88  
 
 89  
     /** {@inheritDoc} */
 90  
     public Set<Map.Entry<K, V>> entrySet()
 91  
     {
 92  14
         return map.entrySet();
 93  
     }
 94  
 
 95  
     /** {@inheritDoc} */
 96  
     public boolean equals(final Object o)
 97  
     {
 98  0
         return map.equals(o);
 99  
     }
 100  
 
 101  
     /** {@inheritDoc} */
 102  
     public V get(final Object key)
 103  
     {
 104  84
         return map.get(key);
 105  
     }
 106  
 
 107  
     /** {@inheritDoc} */
 108  
     public int hashCode()
 109  
     {
 110  0
         return map.hashCode();
 111  
     }
 112  
 
 113  
     /** {@inheritDoc} */
 114  
     public boolean isEmpty()
 115  
     {
 116  12
         return map.isEmpty();
 117  
     }
 118  
 
 119  
     /** {@inheritDoc} */
 120  
     public Set<K> keySet()
 121  
     {
 122  24
         return map.keySet();
 123  
     }
 124  
 
 125  
     /** {@inheritDoc} */
 126  
     public V put(final K key, final V value)
 127  
     {
 128  38
         return map.put(key, value);
 129  
     }
 130  
 
 131  
     /** {@inheritDoc} */
 132  
     public void putAll(final Map<? extends K, ? extends V> m)
 133  
     {
 134  0
         map.putAll(m);
 135  0
     }
 136  
 
 137  
     /** {@inheritDoc} */
 138  
     public V remove(final Object key)
 139  
     {
 140  0
         return map.remove(key);
 141  
     }
 142  
 
 143  
     /** {@inheritDoc} */
 144  
     public int size()
 145  
     {
 146  12
         return map.size();
 147  
     }
 148  
 
 149  
     /** {@inheritDoc} */
 150  
     public Collection<V> values()
 151  
     {
 152  24
         return map.values();
 153  
     }
 154  
 }