|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.omnaest.utils.structure.array.ArrayUtils
public class ArrayUtils
Helper methods for arrays.
CollectionUtils| Constructor Summary | |
|---|---|
ArrayUtils()
|
|
| Method Summary | ||
|---|---|---|
static
|
arrayType(Class<E> componentType)
Returns an array type based on the element type |
|
static Class<?> |
componentType(Class<?> arrayType)
Returns the component type of a given array type. |
|
static
|
convertArray(FROM[] arrayFrom,
Class<TO> arrayToType,
ElementConverter<FROM,? extends TO> elementConverter)
Converts a given array into a new array with a new element type. |
|
static
|
convertArray(FROM[] arrayFrom,
TO[] arrayTo,
ElementConverter<FROM,? extends TO> elementConverter)
Similar to convertArray(Object[], Class, ElementConverter) but uses the given target array if the size fits
otherwise it will construct a new array with the same component type |
|
static
|
convertArrayExcludingNullElements(FROM[] arrayFrom,
TO[] arrayTo,
ElementConverter<FROM,TO> elementConverter)
Converts a given array into a new list with a new element type, whereby all elements which convert to null will be excluded in the target list. |
|
static
|
differenceBitSet(E[] elements1,
E[] elements2)
Calculates a BitSet which has its bits set to true at the same index where the related element from one array to the
other array is not Object.equals(Object) |
|
static boolean |
isArray(Object object)
Returns true if the object is an Array |
|
static boolean |
isArrayType(Class<?> type)
Returns true if the given type is not null and Class.isArray() is true |
|
static int |
length(Object arrayObject)
Returns the length of a given array instance or -1 if the given instance is not an array instance. |
|
static
|
merge(E[]... elementArrays)
Returns an Array containing all elements of each of the given Arrays. |
|
static int |
sumOf(int... values)
Return the sum of all given Integer values |
|
static Object[] |
toObject(Object primitiveArray)
Returns a non primitive Array for a primitive one |
|
static String[] |
trimStringArrayTokens(String[] stringArray)
Returns a new array with all tokens of the given string array being trimmed |
|
static
|
valueOf(Class<E> type,
E... elements)
|
|
static
|
valueOf(Collection<? extends E> collection,
Class<E> type)
Returns an typed Array based on the given Collection and the given array component typeIf null is given as Collection null is returned, too. |
|
static
|
valueOf(E... elements)
Returns a new Array instance based on the Class types of the given elements. |
|
static
|
valueOf(Iterable<? extends E> iterable,
Class<E> type)
Returns an typed Array based on the given Iterable and the given array component typeIf null is given as Iterable null is returned, too. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ArrayUtils()
| Method Detail |
|---|
public static <E> E[] merge(E[]... elementArrays)
Array containing all elements of each of the given Arrays. If any given Array is null, it
will be ignored.Array instance is given this function returns an Array instance itself. If no
Array instance is available null will be returned.
elementArrays -
public static <TO,FROM> TO[] convertArray(FROM[] arrayFrom,
Class<TO> arrayToType,
ElementConverter<FROM,? extends TO> elementConverter)
arrayFrom - arrayToType - elementConverter - ElementConverter
public static <TO,FROM> TO[] convertArray(FROM[] arrayFrom,
TO[] arrayTo,
ElementConverter<FROM,? extends TO> elementConverter)
convertArray(Object[], Class, ElementConverter) but uses the given target array if the size fits
otherwise it will construct a new array with the same component type
arrayFrom - arrayTo - : instance of the array later returned. Use the return value to set this list. The array will not be necessarily
changed only by the call as parameter.elementConverter - ElementConverter
public static <TO,FROM> TO[] convertArrayExcludingNullElements(FROM[] arrayFrom,
TO[] arrayTo,
ElementConverter<FROM,TO> elementConverter)
arrayFrom - arrayTo - elementConverter -
public static String[] trimStringArrayTokens(String[] stringArray)
stringArray -
public static Object[] toObject(Object primitiveArray)
Array for a primitive one
primitiveArray -
public static boolean isArrayType(Class<?> type)
Class.isArray() is true
type -
public static boolean isArray(Object object)
Array
object -
public static Class<?> componentType(Class<?> arrayType)
arrayType -
arrayType(Class)public static int length(Object arrayObject)
arrayObject -
public static <E> E[] valueOf(Collection<? extends E> collection,
Class<E> type)
Array based on the given Collection and the given array component typeCollection null is returned, too. If the given type is null, Object is used as component
type.
collection - Collectiontype - Class
Array instanceCollection.toArray(Object[])
public static <E> E[] valueOf(Iterable<? extends E> iterable,
Class<E> type)
Array based on the given Iterable and the given array component typeIterable null is returned, too. If the given type is null, Object is used as component
type.
iterable - Collectiontype - Class
Array instanceCollection.toArray(Object[])public static <E> E[] valueOf(E... elements)
Array instance based on the Class types of the given elements. The first shared type which can
be cast to the expected return type is used.
elements -
valueOf(Class, Object...)
public static <E> E[] valueOf(Class<E> type,
E... elements)
elements -
public static int sumOf(int... values)
Integer values
values -
public static <E> BitSet differenceBitSet(E[] elements1,
E[] elements2)
BitSet which has its bits set to true at the same index where the related element from one array to the
other array is not Object.equals(Object)
elements1 - elements2 -
BitSet with modified index bits set to truepublic static <E> Class<E[]> arrayType(Class<E> componentType)
componentType -
componentType(Class)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||