Package org.array.utils
Interface ArrayUtils
public interface ArrayUtils
-
Method Summary
Modifier and TypeMethodDescriptionstatic <E, I, T extends Collection<I>>
Tbuild(T array, BiConsumer<T,E> consumer, Iterable<E> collection)
static <X, T> T[]
buildArray(Class<T> clazz, Function<X,T[]> function, Iterable<X> collection)
static <X, T> T[]
buildArray(Class<T> clazz, Function<X,T[]> function, X... array)
static <A, B> boolean
contains(A[] a, B[] b)
static <E, T> T[]
Converts the array into another arraystatic <E, I> List<I>
Converts the array into another arraystatic <A, E, I, T extends Collection<E>>
TConverts the array into another arraystatic <E, I, T extends Collection<I>>
TConverts the array into another arraystatic String[]
static String[]
static <T> Optional<T>
Gets the "best" element from the provided arraygetBest(Function<T,N> function, BiPredicate<N,N> compare, Iterable<T> collection)
Gets the "best" element from the provided arraygetBests(Function<T,N> function, BiPredicate<N,N> compare, BiPredicate<N,N> equal, Iterable<T> collection)
Gets the "best" values from the collectiongetBests(Function<T,N> function, BiPredicate<N,N> compare, BiPredicate<N,N> equal, T... array)
Gets the "best" values from the collectionstatic <O, T> Set<T>
static <O, T> Set<T>
static <T> T[]
static <T> T[]
static <T> Set<T>
ofSet(T... values)
static String[]
splitBy(String toSplit, int startWith, boolean combineStartWith, Predicate<? super Character> splitBy)
static <K, V> Map<K,V>
toMappedKeys(Function<K,V> toKey, Collection<K> keys)
static <K, V> Map<K,V>
toMappedValues(Function<V,K> toKey, Collection<V> keys)
static <T> String
toString(String split, Function<T,String> toString, Collection<T> collection)
Deprecated.static String[]
-
Method Details
-
ofSet
-
contains
static <A, B> boolean contains(A[] a, B[] b) -
getCommon
@SafeVarargs static <O, T> Set<T> getCommon(Function<O,T> function, Function<T,String> toID, O... collection) -
getCommon
-
build
static <E, I, T extends Collection<I>> T build(T array, BiConsumer<T,E> consumer, Iterable<E> collection) -
convert
static <A, E, I, T extends Collection<E>> T convert(Collector<E,I,T> collector, Function<A,E> consumer, Iterable<A> collection)Converts the array into another array- Type Parameters:
A
- The original array element typeE
- The new array element typeI
- The supplierT
- The supplier- Parameters:
collector
- The return collection typeconsumer
- Convert element from the original to the newcollection
- The original array- Returns:
- The new array
-
convert
Converts the array into another array- Type Parameters:
E
- The original array elementT
- The new array element- Parameters:
clazz
- The new array typefunction
- convert the original element to the newarray
- the original array- Returns:
- The new array
-
convert
Converts the array into another array- Type Parameters:
E
- The original collection elementI
- The new collection element type- Parameters:
function
- how to convert the elementcollection
- the original collection- Returns:
- The new list
-
convert
static <E, I, T extends Collection<I>> T convert(T array, Function<E,I> function, Iterable<E> collection)Converts the array into another array- Type Parameters:
E
- original array elementI
- new array element typeT
- collection type- Parameters:
array
- array to add tofunction
- convert element to the othercollection
- the original array- Returns:
- the provided new collection
-
toMappedValues
-
toMappedKeys
-
toString
@Deprecated static <T> String toString(String split, Function<T,String> toString, Collection<T> collection)Deprecated. -
getBest
@SafeVarargs static <T> Optional<T> getBest(Function<T,Integer> function, BiPredicate<Integer,Integer> compare, T... array)Gets the "best" element from the provided array- Type Parameters:
T
- element type- Parameters:
function
- convert element to valuecompare
- compare two valuesarray
- original array- Returns:
- the "best" element - optional if no best can be found
-
getBest
static <T, N extends Number> Optional<T> getBest(Function<T,N> function, BiPredicate<N,N> compare, Iterable<T> collection)Gets the "best" element from the provided array- Type Parameters:
T
- element type- Parameters:
function
- convert element to valuecompare
- compare two valuescollection
- original array- Returns:
- the "best" element - optional if no best can be found
-
getBests
@SafeVarargs static <T, N extends Number> Set<T> getBests(Function<T,N> function, BiPredicate<N,N> compare, BiPredicate<N,N> equal, T... array)Gets the "best" values from the collection- Type Parameters:
T
- element typeN
- The value to compare- Parameters:
function
- convert element to valuecompare
- compare two values (current best > comparison)equal
- checks the two value are equalarray
- the original array- Returns:
- the best elements
-
getBests
static <T, N extends Number> Set<T> getBests(Function<T,N> function, BiPredicate<N,N> compare, BiPredicate<N,N> equal, Iterable<T> collection)Gets the "best" values from the collection- Type Parameters:
T
- element typeN
- The value to compare- Parameters:
function
- convert element to valuecompare
- compare two values (current best > comparison)equal
- checks the two value are equalcollection
- the original array- Returns:
- the best elements
-
trim
-
filter
-
filterOut
-
buildArray
-
buildArray
-
join
-
join
-
splitBy
-