Package com.hp.lft.sdk.java.util
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>
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);
-
Field Summary
Fields inherited from class java.util.AbstractList
modCount
-
Method Summary
Modifier and TypeMethodDescriptionget
(int index) Not usedstatic Class<?>
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).static <E> Class<ListWrapper<List<E>,
E>> Gets the Class object specifically for List interfaceint
size()
Not usedMethods inherited from class java.util.AbstractList
add, add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subList
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods inherited from interface java.util.List
addAll, contains, containsAll, isEmpty, remove, removeAll, replaceAll, retainAll, sort, spliterator, toArray, toArray
-
Method Details
-
of
Gets the Class object specifically for List interface- Parameters:
classOfElements
- the type of the list items- Returns:
- Class reference of
ListWrapper.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 interfaceCollection<K>
- Specified by:
size
in interfaceList<K>
- Specified by:
size
in classAbstractCollection<E>
-
get
Not used
-