public final class SelectionHelper
extends java.lang.Object
ISelection objects.
All the methods check the selection is a IStructuredSelection.
Selection objects not matching this criteria are treated as empty selections.
ISelection,
IStructuredSelection| Modifier and Type | Method and Description |
|---|---|
static boolean |
contains(ISelection selection,
java.lang.Class<?> cls)
Tells whether the selection contains at least one element of the given type.
|
static boolean |
containsOnly(ISelection selection,
java.lang.Class<?> cls)
Tells whether the selection contains only elements of the given type.
|
static int |
count(ISelection selection,
java.lang.Class<?> cls)
Count in the selection the elements matching the given type.
|
static <T> T |
getFirst(ISelection selection,
java.lang.Class<T> cls)
Get the first element in the selection that matches the given type
|
static <T> java.util.List<T> |
toList(ISelection selection,
java.lang.Class<T> cls)
Convert the selection object to a list of the given type.
|
static <T> java.util.stream.Stream<T> |
toStream(ISelection selection,
java.lang.Class<T> cls)
Convert the selection object to a
Stream of the given type. |
public static boolean contains(ISelection selection,
java.lang.Class<?> cls)
Returns false if the selection is empty.
selection - a selection objectcls - the required typepublic static boolean containsOnly(ISelection selection,
java.lang.Class<?> cls)
Returns false if the selection is empty.
selection - a selection objectcls - the required typepublic static int count(ISelection selection,
java.lang.Class<?> cls)
selection - a selection objectcls - the required typepublic static <T> java.util.List<T> toList(ISelection selection,
java.lang.Class<T> cls)
All selection elements not matching the type are filtered out.
T - the wanted typeselection - the selection objectcls - the wanted typepublic static <T> java.util.stream.Stream<T> toStream(ISelection selection,
java.lang.Class<T> cls)
Stream of the given type.
All selection elements not matching the type are filtered out.
T - the wanted typeselection - the selection objectcls - the wanted typepublic static <T> T getFirst(ISelection selection,
java.lang.Class<T> cls)
T - the required typeselection - the selection objectcls - the required type class