1 17 package org.apache.commons.collections.primitives.adapters; 18 19 import java.util.Collection ; 20 import java.util.Iterator ; 21 import java.util.List ; 22 import java.util.ListIterator ; 23 24 import org.apache.commons.collections.primitives.LongCollection; 25 import org.apache.commons.collections.primitives.LongList; 26 27 32 abstract class AbstractLongListList extends AbstractLongCollectionCollection implements List { 33 34 public void add(int index, Object element) { 35 getLongList().add(index,((Number )element).longValue()); 36 } 37 38 public boolean addAll(int index, Collection c) { 39 return getLongList().addAll(index,CollectionLongCollection.wrap(c)); 40 } 41 42 public Object get(int index) { 43 return new Long (getLongList().get(index)); 44 } 45 46 public int indexOf(Object element) { 47 return getLongList().indexOf(((Number )element).longValue()); 48 } 49 50 public int lastIndexOf(Object element) { 51 return getLongList().lastIndexOf(((Number )element).longValue()); 52 } 53 54 61 public ListIterator listIterator() { 62 return LongListIteratorListIterator.wrap(getLongList().listIterator()); 63 } 64 65 72 public ListIterator listIterator(int index) { 73 return LongListIteratorListIterator.wrap(getLongList().listIterator(index)); 74 } 75 76 public Object remove(int index) { 77 return new Long (getLongList().removeElementAt(index)); 78 } 79 80 public Object set(int index, Object element) { 81 return new Long (getLongList().set(index, ((Number )element).longValue() )); 82 } 83 84 public List subList(int fromIndex, int toIndex) { 85 return LongListList.wrap(getLongList().subList(fromIndex,toIndex)); 86 } 87 88 public boolean equals(Object obj) { 89 if(obj instanceof List ) { 90 List that = (List )obj; 91 if(this == that) { 92 return true; 93 } else if(this.size() != that.size()) { 94 return false; 95 } else { 96 Iterator thisiter = iterator(); 97 Iterator thatiter = that.iterator(); 98 while(thisiter.hasNext()) { 99 Object thiselt = thisiter.next(); 100 Object thatelt = thatiter.next(); 101 if(null == thiselt ? null != thatelt : !(thiselt.equals(thatelt))) { 102 return false; 103 } 104 } 105 return true; 106 } 107 } else { 108 return false; 109 } 110 } 111 112 public int hashCode() { 113 return getLongList().hashCode(); 114 } 115 116 protected final LongCollection getLongCollection() { 117 return getLongList(); 118 } 119 120 protected abstract LongList getLongList(); 121 122 123 } 124 | Popular Tags |