Package org.csstudio.ui.util
Class AdapterUtil
java.lang.Object
org.csstudio.ui.util.AdapterUtil
Utilities for using adapters, particularly against selections.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Object
Adapts an object to the desired type.static <T> T[]
convert
(ISelection selection, Class<T> clazz) Returns the current selection converted to an array of the desired type, or to an empty array if not possible.static String[]
getAdaptableTypes
(Class<?> clazz) Returns all class names that an object of that class can be converted to.
-
Constructor Details
-
AdapterUtil
public AdapterUtil()
-
-
Method Details
-
getAdaptableTypes
Returns all class names that an object of that class can be converted to.- Parameters:
clazz
- a class- Returns:
- all the class names with registered adapterFactories
-
convert
Returns the current selection converted to an array of the desired type, or to an empty array if not possible.- Type Parameters:
T
- requested type- Parameters:
selection
- a selectionclazz
- the desired type- Returns:
- an array of the desired type
-
convert
Adapts an object to the desired type. This method, on top of the standard adapter facility, adds support for arrays. If any of the arguments represents an array, it will use object to object adaptation to create it.- Parameters:
obj
- Object to adapttargetClass
- Desired class name- Returns:
- Object that matches the
targetClass
ornull
-