java.lang.Object
org.eclipse.xtext.xbase.lib.Conversions
This is a library used to convert arrays to lists and vice versa in a way that keeps the identity of the
to-be-converted object. That is, changes in the array will be reflected by the list and changes to the list will be
reflected by the array for both kinds of conversion.
The utilities in this class should only be used by the Xbase compiler.
- Author:
- Sebastian Zarnekow - Initial contribution and API, Sven Efftinge, Facundo Etchezar - Initial implementation of the type-specific primitive array wrappers
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classA list that is completely backed by an array and that provides access to that array.static final classA list that is completely backed by an array of primitives and that provides access to that array.static final classA list that is completely backed by an array of primitives and that provides access to that array.static final classA list that is completely backed by an array of primitives and that provides access to that array.static final classA list that is completely backed by an array of primitives and that provides access to that array.static final classA list that is completely backed by an array of primitives and that provides access to that array.static final classA list that is completely backed by an array of primitives and that provides access to that array.static final classA list that is completely backed by an array of primitives and that provides access to that array.static final classA list that is completely backed by an array of primitives and that provides access to that array. -
Method Summary
Modifier and TypeMethodDescriptionstatic ObjectdoWrapArray(Object object) Wrapsobjectin a list if and only ifobjectis an array.static ObjectunwrapArray(Object value) Unwrapsobjectto extract the original array if and only ifobjectwas previously created bydoWrapArray(Object).static ObjectunwrapArray(Object value, Class<?> componentType) Unwrapsobjectto extract the original array if and only ifobjectwas previously created bydoWrapArray(Object).
-
Method Details
-
doWrapArray
Wrapsobjectin a list if and only ifobjectis an array. Works for primitive and object-component types.- Parameters:
object- the object to be wrapped. May benull.- Returns:
- a list if the given object was an array. Otherwise the unmodified given object. May return
nullif the object wasnull.
-
unwrapArray
Unwrapsobjectto extract the original array if and only ifobjectwas previously created bydoWrapArray(Object). If the array's component type cannot be determined at runtime,Objectis used.- Parameters:
value- the object to be unwrapped. May benull.- Returns:
- the previously wrapped array if the given value represents such. Otherwise returns the value unmodified.
May return
nullif the value wasnull.
-
unwrapArray
Unwrapsobjectto extract the original array if and only ifobjectwas previously created bydoWrapArray(Object).- Parameters:
value- the object to be unwrapped. May benull.componentType- the expected component type of the array. May not benull.- Returns:
- the previously wrapped array if the given value represents such. Otherwise returns the value unmodified.
May return
nullif the value wasnull. - Throws:
ArrayStoreException- if the expected runtimecomponentTypedoes not match the actual runtime component type.
-