Coverage Report - org.apache.commons.collections.primitives.DoubleCollections
 
Classes in this File Line Coverage Branch Coverage Complexity
DoubleCollections
95%
20/21
100%
6/6
1.667
 
 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;
 18  
 
 19  
 import org.apache.commons.collections.primitives.decorators.UnmodifiableDoubleIterator;
 20  
 import org.apache.commons.collections.primitives.decorators.UnmodifiableDoubleList;
 21  
 import org.apache.commons.collections.primitives.decorators.UnmodifiableDoubleListIterator;
 22  
 
 23  
 /**
 24  
  * This class consists exclusively of static methods that operate on or
 25  
  * return DoubleCollections.
 26  
  * <p>
 27  
  * The methods of this class all throw a NullPoDoubleerException if the 
 28  
  * provided collection is null.
 29  
  * 
 30  
  * @version $Revision: 480460 $ $Date: 2006-11-29 03:14:21 -0500 (Wed, 29 Nov 2006) $
 31  
  * 
 32  
  * @author Rodney Waldhoff 
 33  
  */
 34  0
 public final class DoubleCollections {
 35  
 
 36  
     /**
 37  
      * Returns an unmodifiable DoubleList containing only the specified element.
 38  
      * @param value the single value
 39  
      * @return an unmodifiable DoubleList containing only the specified element.
 40  
      */    
 41  
     public static DoubleList singletonDoubleList(double value) {
 42  
         // TODO: a specialized implementation of DoubleList may be more performant
 43  3
         DoubleList list = new ArrayDoubleList(1);
 44  3
         list.add(value);
 45  3
         return UnmodifiableDoubleList.wrap(list);
 46  
     }
 47  
 
 48  
     /**
 49  
      * Returns an unmodifiable DoubleIterator containing only the specified element.
 50  
      * @param value the single value
 51  
      * @return an unmodifiable DoubleIterator containing only the specified element.
 52  
      */    
 53  
     public static DoubleIterator singletonDoubleIterator(double value) {
 54  1
         return singletonDoubleList(value).iterator();
 55  
     }
 56  
 
 57  
     /**
 58  
      * Returns an unmodifiable DoubleListIterator containing only the specified element.
 59  
      * @param value the single value
 60  
      * @return an unmodifiable DoubleListIterator containing only the specified element.
 61  
      */    
 62  
     public static DoubleListIterator singletonDoubleListIterator(double value) {
 63  1
         return singletonDoubleList(value).listIterator();
 64  
     }
 65  
 
 66  
     /**
 67  
      * Returns an unmodifiable version of the given non-null DoubleList.
 68  
      * @param list the non-null DoubleList to wrap in an unmodifiable decorator
 69  
      * @return an unmodifiable version of the given non-null DoubleList
 70  
      * @throws NullPointerException if the given DoubleList is null
 71  
      * @see org.apache.commons.collections.primitives.decorators.UnmodifiableDoubleList#wrap
 72  
      */    
 73  
     public static DoubleList unmodifiableDoubleList(DoubleList list) throws NullPointerException {
 74  2
         if(null == list) {
 75  1
             throw new NullPointerException();
 76  
         }
 77  1
         return UnmodifiableDoubleList.wrap(list);
 78  
     }
 79  
     
 80  
     /**
 81  
      * Returns an unmodifiable version of the given non-null DoubleIterator.
 82  
      * @param iter the non-null DoubleIterator to wrap in an unmodifiable decorator
 83  
      * @return an unmodifiable version of the given non-null DoubleIterator
 84  
      * @throws NullPointerException if the given DoubleIterator is null
 85  
      * @see org.apache.commons.collections.primitives.decorators.UnmodifiableDoubleIterator#wrap
 86  
      */    
 87  
     public static DoubleIterator unmodifiableDoubleIterator(DoubleIterator iter) {
 88  2
         if(null == iter) {
 89  1
             throw new NullPointerException();
 90  
         }
 91  1
         return UnmodifiableDoubleIterator.wrap(iter);
 92  
     }
 93  
         
 94  
     /**
 95  
      * Returns an unmodifiable version of the given non-null DoubleListIterator.
 96  
      * @param iter the non-null DoubleListIterator to wrap in an unmodifiable decorator
 97  
      * @return an unmodifiable version of the given non-null DoubleListIterator
 98  
      * @throws NullPointerException if the given DoubleListIterator is null
 99  
      * @see org.apache.commons.collections.primitives.decorators.UnmodifiableDoubleListIterator#wrap
 100  
      */    
 101  
     public static DoubleListIterator unmodifiableDoubleListIterator(DoubleListIterator iter) {
 102  2
         if(null == iter) {
 103  1
             throw new NullPointerException();
 104  
         }
 105  1
         return UnmodifiableDoubleListIterator.wrap(iter);
 106  
     }
 107  
     
 108  
     /**
 109  
      * Returns an unmodifiable, empty DoubleList.
 110  
      * @return an unmodifiable, empty DoubleList.
 111  
      * @see #EMPTY_DOUBLE_LIST
 112  
      */    
 113  
     public static DoubleList getEmptyDoubleList() {
 114  1
         return EMPTY_DOUBLE_LIST;
 115  
     }
 116  
     
 117  
     /**
 118  
      * Returns an unmodifiable, empty DoubleIterator
 119  
      * @return an unmodifiable, empty DoubleIterator.
 120  
      * @see #EMPTY_DOUBLE_ITERATOR
 121  
      */    
 122  
     public static DoubleIterator getEmptyDoubleIterator() {
 123  1
         return EMPTY_DOUBLE_ITERATOR;
 124  
     }
 125  
     
 126  
     /**
 127  
      * Returns an unmodifiable, empty DoubleListIterator
 128  
      * @return an unmodifiable, empty DoubleListIterator.
 129  
      * @see #EMPTY_DOUBLE_LIST_ITERATOR
 130  
      */    
 131  
     public static DoubleListIterator getEmptyDoubleListIterator() {
 132  1
         return EMPTY_DOUBLE_LIST_ITERATOR;
 133  
     }    
 134  
 
 135  
     /**
 136  
      * An unmodifiable, empty DoubleList
 137  
      * @see #getEmptyDoubleList
 138  
      */    
 139  1
     public static final DoubleList EMPTY_DOUBLE_LIST = unmodifiableDoubleList(new ArrayDoubleList(0));
 140  
 
 141  
     /**
 142  
      * An unmodifiable, empty DoubleIterator
 143  
      * @see #getEmptyDoubleIterator
 144  
      */    
 145  1
     public static final DoubleIterator EMPTY_DOUBLE_ITERATOR = unmodifiableDoubleIterator(EMPTY_DOUBLE_LIST.iterator());
 146  
 
 147  
     /**
 148  
      * An unmodifiable, empty DoubleListIterator
 149  
      * @see #getEmptyDoubleListIterator
 150  
      */    
 151  1
     public static final DoubleListIterator EMPTY_DOUBLE_LIST_ITERATOR = unmodifiableDoubleListIterator(EMPTY_DOUBLE_LIST.listIterator());
 152  
 }