1 17 package org.apache.commons.collections.primitives; 18 19 import org.apache.commons.collections.primitives.decorators.UnmodifiableShortIterator; 20 import org.apache.commons.collections.primitives.decorators.UnmodifiableShortList; 21 import org.apache.commons.collections.primitives.decorators.UnmodifiableShortListIterator; 22 23 34 public final class ShortCollections { 35 36 41 public static ShortList singletonShortList(short value) { 42 ShortList list = new ArrayShortList(1); 44 list.add(value); 45 return UnmodifiableShortList.wrap(list); 46 } 47 48 53 public static ShortIterator singletonShortIterator(short value) { 54 return singletonShortList(value).iterator(); 55 } 56 57 62 public static ShortListIterator singletonShortListIterator(short value) { 63 return singletonShortList(value).listIterator(); 64 } 65 66 73 public static ShortList unmodifiableShortList(ShortList list) throws NullPointerException { 74 if(null == list) { 75 throw new NullPointerException (); 76 } 77 return UnmodifiableShortList.wrap(list); 78 } 79 80 87 public static ShortIterator unmodifiableShortIterator(ShortIterator iter) { 88 if(null == iter) { 89 throw new NullPointerException (); 90 } 91 return UnmodifiableShortIterator.wrap(iter); 92 } 93 94 101 public static ShortListIterator unmodifiableShortListIterator(ShortListIterator iter) { 102 if(null == iter) { 103 throw new NullPointerException (); 104 } 105 return UnmodifiableShortListIterator.wrap(iter); 106 } 107 108 113 public static ShortList getEmptyShortList() { 114 return EMPTY_SHORT_LIST; 115 } 116 117 122 public static ShortIterator getEmptyShortIterator() { 123 return EMPTY_SHORT_ITERATOR; 124 } 125 126 131 public static ShortListIterator getEmptyShortListIterator() { 132 return EMPTY_SHORT_LIST_ITERATOR; 133 } 134 135 139 public static final ShortList EMPTY_SHORT_LIST = unmodifiableShortList(new ArrayShortList(0)); 140 141 145 public static final ShortIterator EMPTY_SHORT_ITERATOR = unmodifiableShortIterator(EMPTY_SHORT_LIST.iterator()); 146 147 151 public static final ShortListIterator EMPTY_SHORT_LIST_ITERATOR = unmodifiableShortListIterator(EMPTY_SHORT_LIST.listIterator()); 152 } 153 | Popular Tags |