org.eclipse.xtext.xbase.lib
Class Conversions.WrappedArray<T>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<T>
org.eclipse.xtext.xbase.lib.Conversions.WrappedArray<T>
- Type Parameters:
T
- the type if the list elements.
- All Implemented Interfaces:
- java.lang.Iterable<T>, java.util.Collection<T>, java.util.List<T>, java.util.RandomAccess
- Enclosing class:
- Conversions
public static class Conversions.WrappedArray<T>
- extends java.util.AbstractList<T>
- implements java.util.RandomAccess
A list that is completely backed by an array and that provides access to that array. Only for internal use.
Fields inherited from class java.util.AbstractList |
modCount |
Methods inherited from class java.util.AbstractList |
add, add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, subList |
Methods inherited from class java.util.AbstractCollection |
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toString |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.List |
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray |
Conversions.WrappedArray
protected Conversions.WrappedArray(T[] array)
- Internal constructor for
Conversions.WrappedArray
.
- Parameters:
array
- the to-be-wrapped array. May be null
which will cause any method on the created
object to fail with a NullPointerException
.
create
public static <T> Conversions.WrappedArray<T> create(T[] array)
- Creates a new
Conversions.WrappedArray
that is backed by the given array
.
- Type Parameters:
T
- the element type of the created list.- Parameters:
array
- the to-be-wrapped array. May be null
which will cause any method on the result object
to fail with a NullPointerException
.
- Returns:
- the wrapped array. Never
null
.
get
public T get(int index)
-
- Specified by:
get
in interface java.util.List<T>
- Specified by:
get
in class java.util.AbstractList<T>
- Throws:
java.lang.NullPointerException
- if the wrapped array was null
.
java.lang.IndexOutOfBoundsException
set
public T set(int index,
T element)
-
- Specified by:
set
in interface java.util.List<T>
- Overrides:
set
in class java.util.AbstractList<T>
- Throws:
java.lang.NullPointerException
- if the wrapped array was null
.
java.lang.ClassCastException
java.lang.NullPointerException
java.lang.IllegalArgumentException
java.lang.IndexOutOfBoundsException
size
public int size()
-
- Specified by:
size
in interface java.util.Collection<T>
- Specified by:
size
in interface java.util.List<T>
- Specified by:
size
in class java.util.AbstractCollection<T>
- Throws:
java.lang.NullPointerException
- if the wrapped array was null
.
toArray
public java.lang.Object[] toArray()
- Specified by:
toArray
in interface java.util.Collection<T>
- Specified by:
toArray
in interface java.util.List<T>
- Overrides:
toArray
in class java.util.AbstractCollection<T>
internalToArray
public T[] internalToArray()
- Returns the underlying array in an unsafe manner. That is, modification of the array will be reflected by
this list and vice versa.
- Returns:
- the underlying array. May be
null
if the list was created
with
a null argument.