Coverage Report - org.apache.commons.collections.primitives.adapters.AbstractFloatCollectionCollection
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractFloatCollectionCollection
100%
27/27
100%
8/8
1.267
 
 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.lang.reflect.Array;
 20  
 import java.util.Collection;
 21  
 import java.util.Iterator;
 22  
 
 23  
 import org.apache.commons.collections.primitives.FloatCollection;
 24  
 
 25  
 /**
 26  
  * @since Commons Primitives 1.0
 27  
  * @version $Revision: 480462 $ $Date: 2006-11-29 03:15:00 -0500 (Wed, 29 Nov 2006) $
 28  
  * @author Rodney Waldhoff 
 29  
  */
 30  1482
 abstract class AbstractFloatCollectionCollection implements Collection {
 31  
     
 32  
     public boolean add(Object element) {
 33  148
         return getFloatCollection().add(((Number)element).floatValue());
 34  
     }
 35  
 
 36  
     public boolean addAll(Collection c) {
 37  670
         return getFloatCollection().addAll(CollectionFloatCollection.wrap(c));
 38  
     }
 39  
         
 40  
     public void clear() {
 41  10
         getFloatCollection().clear();
 42  10
     }
 43  
 
 44  
     public boolean contains(Object element) {
 45  969
         return getFloatCollection().contains(((Number)element).floatValue());
 46  
     }
 47  
    
 48  
     
 49  
     public boolean containsAll(Collection c) {
 50  35
         return getFloatCollection().containsAll(CollectionFloatCollection.wrap(c));
 51  
     }        
 52  
         
 53  
     public String toString() {
 54  10
         return getFloatCollection().toString();
 55  
     }
 56  
     
 57  
     public boolean isEmpty() {
 58  2076
         return getFloatCollection().isEmpty();
 59  
     }
 60  
     
 61  
     /**
 62  
      * {@link FloatIteratorIterator#wrap wraps} the 
 63  
      * {@link org.apache.commons.collections.primitives.FloatIterator FloatIterator}
 64  
      * returned by my underlying 
 65  
      * {@link FloatCollection FloatCollection}, 
 66  
      * if any.
 67  
      */
 68  
     public Iterator iterator() {
 69  6309
         return FloatIteratorIterator.wrap(getFloatCollection().iterator());
 70  
     }
 71  
      
 72  
     public boolean remove(Object element) {
 73  222
         return getFloatCollection().removeElement(((Number)element).floatValue());
 74  
     }
 75  
     
 76  
     public boolean removeAll(Collection c) {
 77  30
         return getFloatCollection().removeAll(CollectionFloatCollection.wrap(c));
 78  
     }
 79  
     
 80  
     public boolean retainAll(Collection c) {
 81  35
         return getFloatCollection().retainAll(CollectionFloatCollection.wrap(c));
 82  
     }
 83  
     
 84  
     public int size() {
 85  4903
         return getFloatCollection().size();
 86  
     }
 87  
     
 88  
     public Object[] toArray() {
 89  2375
         float[] a = getFloatCollection().toArray();
 90  2375
         Object[] A = new Object[a.length];
 91  37251
         for(int i=0;i<a.length;i++) {
 92  34876
             A[i] = new Float(a[i]);
 93  
         }
 94  2375
         return A;
 95  
     }
 96  
     
 97  
     public Object[] toArray(Object[] A) {
 98  25
         float[] a = getFloatCollection().toArray();
 99  25
         if(A.length < a.length) {
 100  15
             A = (Object[])(Array.newInstance(A.getClass().getComponentType(), a.length));
 101  
         }
 102  168
         for(int i=0;i<a.length;i++) {
 103  153
             A[i] = new Float(a[i]);
 104  
         }
 105  15
         if(A.length > a.length) {
 106  5
             A[a.length] = null;
 107  
         }
 108  
 
 109  15
         return A;
 110  
     }
 111  
 
 112  
     protected abstract FloatCollection getFloatCollection();            
 113  
 }