Coverage Report - org.apache.commons.collections.primitives.adapters.AbstractCollectionLongCollection
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractCollectionLongCollection
100%
26/26
100%
6/6
1.188
 
 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one or more
 3  
  * contributor license agreements.  See the NOTICE file distributed with
 4  
  * this work for additional information regarding copyright ownership.
 5  
  * The ASF licenses this file to You under the Apache License, Version 2.0
 6  
  * (the "License"); you may not use this file except in compliance with
 7  
  * the License.  You may obtain a copy of the License at
 8  
  *
 9  
  *     http://www.apache.org/licenses/LICENSE-2.0
 10  
  *
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 package org.apache.commons.collections.primitives.adapters;
 18  
 
 19  
 import java.util.Collection;
 20  
 
 21  
 import org.apache.commons.collections.primitives.LongCollection;
 22  
 import org.apache.commons.collections.primitives.LongIterator;
 23  
 
 24  
 /**
 25  
  * @since Commons Primitives 1.0
 26  
  * @version $Revision: 480462 $ $Date: 2006-11-29 03:15:00 -0500 (Wed, 29 Nov 2006) $
 27  
  * @author Rodney Waldhoff 
 28  
  */
 29  
 abstract class AbstractCollectionLongCollection implements LongCollection {
 30  1670
     protected AbstractCollectionLongCollection() {
 31  1670
     }
 32  
 
 33  
     public boolean add(long element) {
 34  1654
         return getCollection().add(new Long(element));
 35  
     }
 36  
         
 37  
     public boolean addAll(LongCollection c) {
 38  284
         return getCollection().addAll(LongCollectionCollection.wrap(c));
 39  
     }
 40  
     
 41  
     public void clear() {
 42  5
         getCollection().clear();
 43  5
     }
 44  
 
 45  
     public boolean contains(long element) {
 46  952
         return getCollection().contains(new Long(element));
 47  
     }
 48  
     
 49  
     public boolean containsAll(LongCollection c) {
 50  14
         return getCollection().containsAll(LongCollectionCollection.wrap(c));
 51  
     }        
 52  
     
 53  
     public String toString() {
 54  4
         return getCollection().toString();
 55  
     }
 56  
 
 57  
     public boolean isEmpty() {
 58  927
         return getCollection().isEmpty();
 59  
     }
 60  
     
 61  
     /**
 62  
      * {@link IteratorLongIterator#wrap wraps} the 
 63  
      * {@link java.util.Iterator Iterator}
 64  
      * returned by my underlying 
 65  
      * {@link Collection Collection}, 
 66  
      * if any.
 67  
      */
 68  
     public LongIterator iterator() {
 69  3631
         return IteratorLongIterator.wrap(getCollection().iterator());
 70  
     }
 71  
      
 72  
     public boolean removeElement(long element) {
 73  96
         return getCollection().remove(new Long(element));
 74  
     }
 75  
     
 76  
     public boolean removeAll(LongCollection c) {
 77  12
         return getCollection().removeAll(LongCollectionCollection.wrap(c));
 78  
     }
 79  
         
 80  
     public boolean retainAll(LongCollection c) {
 81  14
         return getCollection().retainAll(LongCollectionCollection.wrap(c));
 82  
     }
 83  
     
 84  
     public int size() {
 85  3644
         return getCollection().size();
 86  
     }
 87  
     
 88  
     public long[] toArray() {
 89  1230
         Object[] src = getCollection().toArray();
 90  1230
         long[] dest = new long[src.length];
 91  20660
         for(int i=0;i<src.length;i++) {
 92  19430
             dest[i] = ((Number)(src[i])).longValue();
 93  
         }
 94  1230
         return dest;
 95  
     }
 96  
     
 97  
     public long[] toArray(long[] dest) {
 98  3
         Object[] src = getCollection().toArray();
 99  3
         if(dest.length < src.length) {
 100  1
             dest = new long[src.length];
 101  
         }
 102  60
         for(int i=0;i<src.length;i++) {
 103  57
             dest[i] = ((Number)(src[i])).longValue();
 104  
         }
 105  3
         return dest;
 106  
     }
 107  
     
 108  
     protected abstract Collection getCollection();
 109  
     
 110  
 }