Class ExtendedArray<T>

  • Type Parameters:
    T - Object type
    All Implemented Interfaces:
    ArrayAdapter<T,​ExtendedArray<T>>

    public class ExtendedArray<T>
    extends java.lang.Object
    implements ArrayAdapter<T,​ExtendedArray<T>>
    Class to extend an array with a single element virtually.
    Since:
    0.5.0
    Author:
    Erich Schubert
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) java.lang.Object array
      The array
      (package private) T extra
      The extra element
      (package private) ArrayAdapter<T,​java.lang.Object> getter
      The array adapter
      (package private) int size
      Our size
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected ExtendedArray​(java.lang.Object array, ArrayAdapter<T,​java.lang.Object> getter, T extra)
      Constructor.
    • Field Detail

      • array

        final java.lang.Object array
        The array
      • getter

        final ArrayAdapter<T,​java.lang.Object> getter
        The array adapter
      • extra

        final T extra
        The extra element
      • size

        final int size
        Our size
    • Constructor Detail

      • ExtendedArray

        protected ExtendedArray​(java.lang.Object array,
                                ArrayAdapter<T,​java.lang.Object> getter,
                                T extra)
        Constructor.
        Parameters:
        array - Original array
        getter - Adapter for array
        extra - Extra element
    • Method Detail

      • get

        public T get​(ExtendedArray<T> array,
                     int off)
        Description copied from interface: ArrayAdapter
        Get the off'th item from the array.
        Specified by:
        get in interface ArrayAdapter<T,​ExtendedArray<T>>
        Parameters:
        array - Array to get from
        off - Offset
        Returns:
        Item at offset off
      • extend

        public static <T,​A> ExtendedArray<T> extend​(A array,
                                                          ArrayAdapter<T,​A> getter,
                                                          T extra)
        Static wrapper that has a nicer generics signature.
        Parameters:
        array - Array to extend
        getter - Getter for array
        extra - Extra element
        Returns:
        Extended array