mirror of
https://github.com/corda/corda.git
synced 2025-06-13 04:38:19 +00:00
Added more to the avian classpath for the collection interface as well as the list interface
Added to collection: public boolean containsAll(Collection<?> c); public boolean removeAll(Collection<?> c); Added to list: public boolean addAll(int startIndex, Collection<? extends T> c); Also where possible for inner classes I made them extend the abstract version instead of just implement the interface. This helps reduce code duplication where possible. These changes were necessary to support protobuf 2.5.0
This commit is contained in:
@ -91,36 +91,15 @@ public class Arrays {
|
||||
}
|
||||
|
||||
public static <T> List<T> asList(final T ... array) {
|
||||
return new List<T>() {
|
||||
public String toString() {
|
||||
return Collections.toString(this);
|
||||
}
|
||||
|
||||
return new AbstractList<T>() {
|
||||
public int size() {
|
||||
return array.length;
|
||||
}
|
||||
|
||||
public boolean add(T element) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public boolean addAll(Collection<? extends T> collection) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public void add(int index, T element) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public boolean contains(Object element) {
|
||||
for (int i = 0; i < array.length; ++i) {
|
||||
if (equal(element, array[i])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public int indexOf(Object element) {
|
||||
for (int i = 0; i < array.length; ++i) {
|
||||
if (equal(element, array[i])) {
|
||||
@ -138,7 +117,7 @@ public class Arrays {
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
public T get(int index) {
|
||||
return array[index];
|
||||
}
|
||||
@ -147,41 +126,13 @@ public class Arrays {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public Object[] toArray() {
|
||||
return toArray(new Object[size()]);
|
||||
}
|
||||
|
||||
public <S> S[] toArray(S[] a) {
|
||||
return (S[])array;
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return size() == 0;
|
||||
}
|
||||
|
||||
public T remove(int index) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public boolean remove(Object element) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public Iterator<T> iterator() {
|
||||
return listIterator();
|
||||
}
|
||||
|
||||
public ListIterator<T> listIterator(int index) {
|
||||
return new Collections.ArrayListIterator(this, index);
|
||||
}
|
||||
|
||||
public ListIterator<T> listIterator() {
|
||||
return listIterator(0);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user