Class Conversions.WrappedArray<T>

java.lang.Object
java.util.AbstractCollection<T>
java.util.AbstractList<T>
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, SequencedCollection<T>
Enclosing class:
Conversions

public static final 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.
  • Constructor Details

    • WrappedArray

      protected 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 Details

    • 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>
    • set

      public T set(int index, T element)
      Specified by:
      set in interface List<T>
      Overrides:
      set in class AbstractList<T>
    • 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.