Package org.eclipse.xtext.xbase.lib
Class Conversions
- java.lang.Object
-
- org.eclipse.xtext.xbase.lib.Conversions
-
@GwtIncompatible("reflection") public final class Conversions extends java.lang.Object
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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Conversions.WrappedArray<T>
A list that is completely backed by an array and that provides access to that array.static class
Conversions.WrappedBooleanArray
A list that is completely backed by an array of primitives and that provides access to that array.static class
Conversions.WrappedByteArray
A list that is completely backed by an array of primitives and that provides access to that array.static class
Conversions.WrappedCharacterArray
A list that is completely backed by an array of primitives and that provides access to that array.static class
Conversions.WrappedDoubleArray
A list that is completely backed by an array of primitives and that provides access to that array.static class
Conversions.WrappedFloatArray
A list that is completely backed by an array of primitives and that provides access to that array.static class
Conversions.WrappedIntegerArray
A list that is completely backed by an array of primitives and that provides access to that array.static class
Conversions.WrappedLongArray
A list that is completely backed by an array of primitives and that provides access to that array.static class
Conversions.WrappedShortArray
A list that is completely backed by an array of primitives and that provides access to that array.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.Object
doWrapArray(java.lang.Object object)
Wrapsobject
in a list if and only ifobject
is an array.static java.lang.Object
unwrapArray(java.lang.Object value)
Unwrapsobject
to extract the original array if and only ifobject
was previously created bydoWrapArray(Object)
.static java.lang.Object
unwrapArray(java.lang.Object value, java.lang.Class<?> componentType)
Unwrapsobject
to extract the original array if and only ifobject
was previously created bydoWrapArray(Object)
.
-
-
-
Method Detail
-
doWrapArray
@Pure public static java.lang.Object doWrapArray(java.lang.Object object)
Wrapsobject
in a list if and only ifobject
is 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
null
if the object wasnull
.
-
unwrapArray
@Pure public static java.lang.Object unwrapArray(java.lang.Object value)
Unwrapsobject
to extract the original array if and only ifobject
was previously created bydoWrapArray(Object)
. If the array's component type cannot be determined at runtime,Object
is 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
null
if the value wasnull
.
-
unwrapArray
@Pure public static java.lang.Object unwrapArray(java.lang.Object value, java.lang.Class<?> componentType)
Unwrapsobject
to extract the original array if and only ifobject
was 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
null
if the value wasnull
. - Throws:
java.lang.ArrayStoreException
- if the expected runtimecomponentType
does not match the actual runtime component type.
-
-