org.eclipse.xtext.xbase.lib
Class Conversions.WrappedArray<T>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<T>
          extended by org.eclipse.xtext.xbase.lib.Conversions.WrappedArray<T>
Type Parameters:
T - the type if the list elements.
All Implemented Interfaces:
Iterable<T>, Collection<T>, List<T>, RandomAccess
Enclosing class:
Conversions

public static class Conversions.WrappedArray<T>
extends AbstractList<T>
implements RandomAccess

A list that is completely backed by an array and that provides access to that array. Only for internal use.


Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
protected Conversions.WrappedArray(T[] array)
          Internal constructor for Conversions.WrappedArray.
 
Method Summary
static
<T> Conversions.WrappedArray<T>
create(T[] array)
          Creates a new Conversions.WrappedArray that is backed by the given array.
 T get(int index)
          
 T[] internalToArray()
          Returns the underlying array in an unsafe manner.
 T set(int index, T element)
          
 int size()
          
 Object[] toArray()
           
 
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
 

Constructor Detail

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.
Method Detail

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 List<T>
Specified by:
get in class AbstractList<T>
Throws:
NullPointerException - if the wrapped array was null.
IndexOutOfBoundsException

set

public T set(int index,
             T element)

Specified by:
set in interface List<T>
Overrides:
set in class AbstractList<T>
Throws:
NullPointerException - if the wrapped array was null.
ClassCastException
NullPointerException
IllegalArgumentException
IndexOutOfBoundsException

size

public int size()

Specified by:
size in interface Collection<T>
Specified by:
size in interface List<T>
Specified by:
size in class AbstractCollection<T>
Throws:
NullPointerException - if the wrapped array was null.

toArray

public Object[] toArray()
Specified by:
toArray in interface Collection<T>
Specified by:
toArray in interface List<T>
Overrides:
toArray in class 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.


Copyright © 2012. All Rights Reserved.