Class ArrayUtil
java.lang.Object
org.eclipse.milo.opcua.stack.core.util.ArrayUtil
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ObjectIf the provided Object is a primitive array, return a boxed array of the same type, otherwise return the original Object.static ObjectFlatten a multi-dimensional array into a one-dimensional array.static Class<?>getBoxedType(Object array) Get the (boxed) base component type for the provided array.static int[]getDimensions(Object array) static Class<?>Get the base component type for the provided array.static intgetValueRank(Object array) Get the ValueRank of an Object that may or may not be an array.static <F,T> Object transformArray(Object array, Function<F, T> transform, Class<T> toType) Transform the values in an array from one type to another using a transformation function.static ObjectUn-flatten a one-dimensional array into an multi-dimensional array based on the provided dimensions.
-
Constructor Details
-
ArrayUtil
public ArrayUtil()
-
-
Method Details
-
flatten
Flatten a multi-dimensional array into a one-dimensional array.- Parameters:
array- the array to flatten.- Returns:
- a 1-dimensional array.
-
unflatten
Un-flatten a one-dimensional array into an multi-dimensional array based on the provided dimensions.- Parameters:
array- the 1-dimensional array to un-flatten.dimensions- the dimensions to un-flatten to.- Returns:
- a multi-dimensional array of the provided dimensions.
-
getDimensions
-
getValueRank
Get the ValueRank of an Object that may or may not be an array.The return value is either -1 (scalar) or the number of dimensions (>=1).
- Parameters:
array- the Object to check.- Returns:
- the ValueRank of the object.
-
getType
Get the base component type for the provided array.- Parameters:
array- the array whose base component type is to be determined.- Returns:
- the
Classobject representing the base component type of the array.
-
getBoxedType
Get the (boxed) base component type for the provided array.- Parameters:
array- the array whose (boxed) base component type is to be determined.- Returns:
- the
Classobject representing the (boxed) base component type of the array.
-
box
If the provided Object is a primitive array, return a boxed array of the same type, otherwise return the original Object.- Parameters:
value- the array to box.- Returns:
- a boxed array of the same type, or the original Object if it is not a primitive array.
-
transformArray
Transform the values in an array from one type to another using a transformation function.Handles multi-dimensional arrays by flattening before the transformation and un-flattening afterwards.
- Parameters:
array- the original array.transform- a function that transforms fromFtoT.toType- the destination type.- Returns:
- a new array of the same size and dimensions with all elements transformed from
FtoTusingtransform.
-