Class ListWrapper<K,E>

java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<E>
com.hp.lft.sdk.java.util.ListWrapper<K,E>
All Implemented Interfaces:
Iterable<E>, Collection<E>, List<E>

public class ListWrapper<K,E> extends AbstractList<E>
Java doesn't yet provide a native way to represent generic types in the format: List<E>.class, due to type erasure mechanism triggered at compile time. This class is dedicated for use with NativeObject and invokeMethod function, which expects the parameter Class<T> returnType It allows to capture the type/class of the elements at runtime for a generic list List<E> The type of elements E must be one of the following types: Float, Integer, Short, Byte, Boolean (also known as wrappers of primitive types). For List<Double> is not required to use ListWrapper.of(Double.class), you can directly use List.class. NOTE: Currently List<Long> is not supported, nor can ListWrapper.of(Long.class) be used. Code Example: Window win = Desktop.describe(Window.class, new WindowDescription.Builder().title("JavaFrameApp").build()); List<Integer> list = win.getNativeObject().invokeMethod("getListOfIntegers", ListWrapper.of(Integer.class), null);
  • Method Details

    • of

      public static <E> Class<ListWrapper<List<E>,E>> of(Class<E> classOfElements)
      Gets the Class object specifically for List interface
      Parameters:
      classOfElements - the type of the list items
      Returns:
      Class reference of ListWrapper.class
    • getTypeOfItems

      public static Class<?> getTypeOfItems()
      Get the type of the items in the list NOTE: The type of items must be one of the following types: Float, Integer, Short, Byte, Boolean (also known as wrappers of primitive types).
    • size

      public int size()
      Not used
      Specified by:
      size in interface Collection<K>
      Specified by:
      size in interface List<K>
      Specified by:
      size in class AbstractCollection<E>
    • get

      public E get(int index)
      Not used
      Specified by:
      get in interface List<K>
      Specified by:
      get in class AbstractList<E>