Package com.github.underscore
Class Underscore
-
- All Implemented Interfaces:
public class Underscore<T>
Underscore-java is a java port of Underscore.js.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public class
Underscore.Chain
public interface
Underscore.Function3
public abstract class
Underscore.MemoizeFunction
public interface
Underscore.PredicateIndexed
public interface
Underscore.Template
-
Constructor Summary
Constructors Constructor Description Underscore(Iterable<T> iterable)
Underscore(String string)
-
Method Summary
Modifier and Type Method Description Iterable<T>
getIterable()
Optional<String>
getString()
static void
templateSettings(Map<String, String> templateSettings)
static <K, V> Function<Map<K, V>, V>
iteratee(K key)
static <T> void
each(Iterable<T> iterable, Consumer<out Object> func)
static <T> void
eachIndexed(Iterable<T> iterable, BiConsumer<Integer, out Object> func)
void
each(Consumer<out Object> func)
static <T> void
eachRight(Iterable<T> iterable, Consumer<out Object> func)
void
eachRight(Consumer<out Object> func)
static <T> void
forEach(Iterable<T> iterable, Consumer<out Object> func)
static <T> void
forEachIndexed(Iterable<T> iterable, BiConsumer<Integer, out Object> func)
void
forEach(Consumer<out Object> func)
void
forEachIndexed(BiConsumer<Integer, out Object> func)
static <T> void
forEachRight(Iterable<T> iterable, Consumer<out Object> func)
void
forEachRight(Consumer<out Object> func)
static <T, E> List<T>
map(List<E> list, Function<out Object, T> func)
static <T, E> List<T>
mapMulti(List<E> list, BiConsumer<out Object, out Object> mapper)
<F> List<F>
map(Function<out Object, F> func)
static <T> List<T>
map(Array<int> array, Function<out Object, T> func)
static <T, E> Set<T>
map(Set<E> set, Function<out Object, T> func)
static <T, E> List<T>
mapIndexed(List<E> list, BiFunction<Integer, out Object, T> func)
static <T> List<T>
replace(Iterable<T> iter, Predicate<T> pred, T value)
List<T>
replace(Predicate<T> pred, T value)
static <T> List<T>
replaceIndexed(Iterable<T> iter, Underscore.PredicateIndexed<T> pred, T value)
List<T>
replaceIndexed(Underscore.PredicateIndexed<T> pred, T value)
<F> List<F>
mapIndexed(BiFunction<Integer, out Object, F> func)
static <T, E> List<T>
collect(List<E> list, Function<out Object, T> func)
static <T, E> Set<T>
collect(Set<E> set, Function<out Object, T> func)
static <T, E> E
reduce(Iterable<T> iterable, BiFunction<E, T, E> func, E zeroElem)
static <T> Optional<T>
reduce(Iterable<T> iterable, BinaryOperator<T> func)
static <E> E
reduce(Array<int> array, BiFunction<E, out Object, E> func, E zeroElem)
static <T, E> E
reduce(Array<T> array, BiFunction<E, T, E> func, E zeroElem)
static <T, E> E
foldl(Iterable<T> iterable, BiFunction<E, T, E> func, E zeroElem)
static <T, E> E
inject(Iterable<T> iterable, BiFunction<E, T, E> func, E zeroElem)
static <T, E> E
reduceRight(Iterable<T> iterable, BiFunction<E, T, E> func, E zeroElem)
static <T> Optional<T>
reduceRight(Iterable<T> iterable, BinaryOperator<T> func)
static <E> E
reduceRight(Array<int> array, BiFunction<E, out Object, E> func, E zeroElem)
static <T, E> E
reduceRight(Array<T> array, BiFunction<E, T, E> func, E zeroElem)
static <T, E> E
foldr(Iterable<T> iterable, BiFunction<E, T, E> func, E zeroElem)
static <E> Optional<E>
find(Iterable<E> iterable, Predicate<E> pred)
static <E> Optional<E>
detect(Iterable<E> iterable, Predicate<E> pred)
static <E> Optional<E>
findLast(Iterable<E> iterable, Predicate<E> pred)
static <E> List<E>
filter(Iterable<E> iterable, Predicate<E> pred)
static <E> List<E>
filter(List<E> list, Predicate<E> pred)
List<T>
filter(Predicate<T> pred)
static <E> List<E>
filterIndexed(List<E> list, Underscore.PredicateIndexed<E> pred)
static <E> Set<E>
filter(Set<E> set, Predicate<E> pred)
static <E> List<E>
select(List<E> list, Predicate<E> pred)
static <E> Set<E>
select(Set<E> set, Predicate<E> pred)
static <E> List<E>
reject(List<E> list, Predicate<E> pred)
List<T>
reject(Predicate<T> pred)
static <E> List<E>
rejectIndexed(List<E> list, Underscore.PredicateIndexed<E> pred)
static <E> Set<E>
reject(Set<E> set, Predicate<E> pred)
static <E> List<E>
filterFalse(List<E> list, Predicate<E> pred)
List<T>
filterFalse(Predicate<T> pred)
static <E> Set<E>
filterFalse(Set<E> set, Predicate<E> pred)
static <E> boolean
every(Iterable<E> iterable, Predicate<E> pred)
boolean
every(Predicate<T> pred)
static <E> boolean
all(Iterable<E> iterable, Predicate<E> pred)
boolean
all(Predicate<T> pred)
static <E> boolean
some(Iterable<E> iterable, Predicate<E> pred)
boolean
some(Predicate<T> pred)
static <E> boolean
any(Iterable<E> iterable, Predicate<E> pred)
boolean
any(Predicate<T> pred)
static <E> int
count(Iterable<E> iterable, Predicate<E> pred)
int
count(Predicate<T> pred)
static <E> boolean
contains(Iterable<E> iterable, E elem)
boolean
contains(T elem)
static <E> boolean
containsWith(Iterable<E> iterable, E elem)
boolean
containsWith(T elem)
static <E> boolean
contains(Iterable<E> iterable, E elem, int fromIndex)
boolean
containsAtLeast(T value, int count)
boolean
containsAtMost(T value, int count)
static <E> boolean
containsAtLeast(Iterable<E> iterable, E value, int count)
static <E> boolean
containsAtMost(Iterable<E> iterable, E value, int count)
static <E> boolean
include(Iterable<E> iterable, E elem)
static <E> List<E>
invoke(Iterable<E> iterable, String methodName, List<Object> args)
List<T>
invoke(String methodName, List<Object> args)
static <E> List<E>
invoke(Iterable<E> iterable, String methodName)
List<T>
invoke(String methodName)
static <E> List<Object>
pluck(List<E> list, String propertyName)
List<Object>
pluck(String propertyName)
static <E> Set<Object>
pluck(Set<E> set, String propertyName)
static <T, E> List<E>
where(List<E> list, List<Map.Entry<String, T>> properties)
<E> List<T>
where(List<Map.Entry<String, E>> properties)
static <T, E> Set<E>
where(Set<E> set, List<Map.Entry<String, T>> properties)
static <T, E> Optional<E>
findWhere(Iterable<E> iterable, List<Map.Entry<String, T>> properties)
<E> Optional<T>
findWhere(List<Map.Entry<String, E>> properties)
static <E extends Comparable<out Object>> E
max(Collection<E> collection)
T
max()
static <E, F extends Comparable> E
max(Collection<E> collection, Function<E, F> func)
<F extends Comparable<out Object>> T
max(Function<T, F> func)
static <E extends Comparable<out Object>> E
min(Collection<E> collection)
T
min()
static <E, F extends Comparable> E
min(Collection<E> collection, Function<E, F> func)
<F extends Comparable<out Object>> T
min(Function<T, F> func)
static <E> List<E>
shuffle(Iterable<E> iterable)
List<T>
shuffle()
static <E> E
sample(Iterable<E> iterable)
T
sample()
static <E> Set<E>
sample(List<E> list, int howMany)
static <T extends Comparable<out Object>> List<T>
sortWith(Iterable<T> iterable, Comparator<T> comparator)
<E extends Comparable<out Object>> List<E>
sortWith(Comparator<E> comparator)
static <E, T extends Comparable<out Object>> List<E>
sortBy(Iterable<E> iterable, Function<E, T> func)
<E, V extends Comparable<out Object>> List<E>
sortBy(Function<E, V> func)
static <K, V extends Comparable<out Object>> List<Map<K, V>>
sortBy(Iterable<Map<K, V>> iterable, K key)
static <K, E> Map<K, List<E>>
groupBy(Iterable<E> iterable, Function<E, K> func)
<K, E> Map<K, List<E>>
groupBy(Function<E, K> func)
static <K, E> Map<K, Optional<E>>
groupBy(Iterable<E> iterable, Function<E, K> func, BinaryOperator<E> binaryOperator)
<K, E> Map<K, Optional<E>>
groupBy(Function<E, K> func, BinaryOperator<E> binaryOperator)
static <K, E> Map<K, List<E>>
indexBy(Iterable<E> iterable, String property)
<K, E> Map<K, List<E>>
indexBy(String property)
static <K, E> Map<K, Integer>
countBy(Iterable<E> iterable, Function<E, K> func)
static <K> Map<K, Integer>
countBy(Iterable<K> iterable)
<K, E> Map<K, Integer>
countBy(Function<E, K> func)
<K> Map<K, Integer>
countBy()
static <E> Array<E>
toArray(Iterable<E> iterable)
<E> Array<E>
toArray()
static <K, V> Map<K, V>
toMap(Iterable<Map.Entry<K, V>> iterable)
<K, V> Map<K, V>
toMap()
static <K, V> Map<K, V>
toMap(List<Map.Entry<K, V>> tuples)
Map<T, Integer>
toCardinalityMap()
static <K> Map<K, Integer>
toCardinalityMap(Iterable<K> iterable)
static int
size(Iterable<out Object> iterable)
int
size()
static <E> int
size(Array<E> array)
static <E> List<List<E>>
partition(Iterable<E> iterable, Predicate<E> pred)
static <E> Array<List<E>>
partition(Array<E> iterable, Predicate<E> pred)
T
singleOrNull()
T
singleOrNull(Predicate<T> pred)
static <E> E
singleOrNull(Iterable<E> iterable)
static <E> E
singleOrNull(Iterable<E> iterable, Predicate<E> pred)
static <E> E
first(Iterable<E> iterable)
static <E> E
first(Array<E> array)
static <E> List<E>
first(List<E> list, int n)
T
first()
List<T>
first(int n)
static <E> E
first(Iterable<E> iterable, Predicate<E> pred)
static <E> List<E>
first(Iterable<E> iterable, Predicate<E> pred, int n)
T
first(Predicate<T> pred)
List<T>
first(Predicate<T> pred, int n)
static <E> E
firstOrNull(Iterable<E> iterable)
T
firstOrNull()
static <E> E
firstOrNull(Iterable<E> iterable, Predicate<E> pred)
T
firstOrNull(Predicate<T> pred)
static <E> E
head(Iterable<E> iterable)
static <E> E
head(Array<E> array)
static <E> List<E>
head(List<E> list, int n)
T
head()
List<T>
head(int n)
static <E> List<E>
initial(List<E> list)
static <E> List<E>
initial(List<E> list, int n)
static <E> Array<E>
initial(Array<E> array)
static <E> Array<E>
initial(Array<E> array, int n)
List<T>
initial()
List<T>
initial(int n)
static <E> E
last(Array<E> array)
static <E> E
last(List<E> list)
static <E> List<E>
last(List<E> list, int n)
T
last()
List<T>
last(int n)
static <E> E
last(List<E> list, Predicate<E> pred)
T
last(Predicate<T> pred)
static <E> E
lastOrNull(List<E> list)
T
lastOrNull()
static <E> E
lastOrNull(List<E> list, Predicate<E> pred)
T
lastOrNull(Predicate<T> pred)
static <E> List<E>
rest(List<E> list)
static <E> List<E>
rest(List<E> list, int n)
static <E> Array<E>
rest(Array<E> array)
static <E> Array<E>
rest(Array<E> array, int n)
List<T>
rest()
List<T>
rest(int n)
static <E> List<E>
tail(List<E> list)
static <E> List<E>
tail(List<E> list, int n)
static <E> Array<E>
tail(Array<E> array)
static <E> Array<E>
tail(Array<E> array, int n)
List<T>
tail()
List<T>
tail(int n)
static <E> List<E>
drop(List<E> list)
static <E> List<E>
drop(List<E> list, int n)
static <E> Array<E>
drop(Array<E> array)
static <E> Array<E>
drop(Array<E> array, int n)
static <E> List<E>
compact(List<E> list)
static <E> Array<E>
compact(Array<E> array)
static <E> List<E>
compact(List<E> list, E falsyValue)
static <E> Array<E>
compact(Array<E> array, E falsyValue)
List<T>
compact()
List<T>
compact(T falsyValue)
static <E> List<E>
flatten(List<out Object> list)
static <E> List<E>
flatten(List<out Object> list, boolean shallow)
List<T>
flatten()
List<T>
flatten(boolean shallow)
static <E> List<E>
without(List<E> list, Array<E> values)
static <E> Array<E>
without(Array<E> array, Array<E> values)
static <E> List<E>
uniq(List<E> list)
static <E> Array<E>
uniq(Array<E> array)
static <K, E> Collection<E>
uniq(Iterable<E> iterable, Function<E, K> func)
static <K, E> Array<E>
uniq(Array<E> array, Function<E, K> func)
static <E> List<E>
distinct(List<E> list)
static <E> Array<E>
distinct(Array<E> array)
static <K, E> Collection<E>
distinctBy(Iterable<E> iterable, Function<E, K> func)
static <K, E> Array<E>
distinctBy(Array<E> array, Function<E, K> func)
static <E> List<E>
union(List<E> list, Array<List<E>> lists)
List<T>
unionWith(Array<List<T>> lists)
static <E> Array<E>
union(Array<Array<E>> arrays)
static <E> List<E>
intersection(List<E> list1, List<E> list2)
static <E> List<E>
intersection(List<E> list, Array<List<E>> lists)
List<T>
intersectionWith(Array<List<T>> lists)
static <E> Array<E>
intersection(Array<Array<E>> arrays)
static <E> List<E>
difference(List<E> list1, List<E> list2)
static <E> List<E>
difference(List<E> list, Array<List<E>> lists)
List<T>
differenceWith(Array<List<T>> lists)
static <E> Array<E>
difference(Array<Array<E>> arrays)
static <T> List<List<T>>
zip(Array<List<T>> lists)
static <T> List<List<T>>
unzip(Array<List<T>> lists)
static <K, V> List<Map.Entry<K, V>>
object(List<K> keys, List<V> values)
static <E> int
findIndex(List<E> list, Predicate<E> pred)
static <E> int
findIndex(Array<E> array, Predicate<E> pred)
static <E> int
findLastIndex(List<E> list, Predicate<E> pred)
static <E> int
findLastIndex(Array<E> array, Predicate<E> pred)
static <E extends Comparable<E>> int
binarySearch(Iterable<E> iterable, E key)
static <E extends Comparable<E>> int
binarySearch(Array<E> array, E key)
static <E extends Comparable<E>> int
sortedIndex(List<E> list, E value)
static <E extends Comparable<E>> int
sortedIndex(Array<E> array, E value)
static <E extends Comparable<E>> int
sortedIndex(List<E> list, E value, String propertyName)
static <E extends Comparable<E>> int
sortedIndex(Array<E> array, E value, String propertyName)
static <E> int
indexOf(List<E> list, E value)
static <E> int
indexOf(Array<E> array, E value)
static <E> int
lastIndexOf(List<E> list, E value)
static <E> int
lastIndexOf(Array<E> array, E value)
static List<Integer>
range(int stop)
static List<Integer>
range(int start, int stop)
static List<Integer>
range(int start, int stop, int step)
static List<Character>
range(char stop)
static List<Character>
range(char start, char stop)
static List<Character>
range(char start, char stop, int step)
static <T> List<List<T>>
chunk(Iterable<T> iterable, int size)
static <T> List<List<T>>
chunk(Iterable<T> iterable, int size, int step)
static <T> List<List<T>>
chunkFill(Iterable<T> iterable, int size, T fillValue)
static <T> List<List<T>>
chunkFill(Iterable<T> iterable, int size, int step, T fillValue)
List<List<T>>
chunk(int size)
List<List<T>>
chunk(int size, int step)
List<List<T>>
chunkFill(int size, T fillvalue)
List<List<T>>
chunkFill(int size, int step, T fillvalue)
static <T> List<T>
cycle(Iterable<T> iterable, int times)
List<T>
cycle(int times)
static <T> List<T>
repeat(T element, int times)
static <T> List<T>
interpose(Iterable<T> iterable, T interElement)
static <T> List<T>
interposeByList(Iterable<T> iterable, Iterable<T> interIter)
List<T>
interpose(T element)
List<T>
interposeByList(Iterable<T> interIter)
static <T, F> Function<F, T>
bind(Function<F, T> function)
static <T, F> Function<F, T>
memoize(Function<F, T> function)
static <T> ScheduledFuture<T>
delay(Supplier<T> function, int delayMilliseconds)
static <T> ScheduledFuture<T>
defer(Supplier<T> function)
static ScheduledFuture<Void>
defer(Runnable runnable)
static <T> Supplier<T>
throttle(Supplier<T> function, int waitMilliseconds)
static <T> Supplier<T>
debounce(Supplier<T> function, int delayMilliseconds)
static <T> Function<Void, T>
wrap(UnaryOperator<T> function, Function<UnaryOperator<T>, T> wrapper)
static <E> Predicate<E>
negate(Predicate<E> pred)
static <T> Function<T, T>
compose(Array<Function<T, T>> func)
static <E> Supplier<E>
after(int count, Supplier<E> function)
static <E> Supplier<E>
before(int count, Supplier<E> function)
static <T> Supplier<T>
once(Supplier<T> function)
static <K, V> Set<K>
keys(Map<K, V> object)
static <K, V> Collection<V>
values(Map<K, V> object)
static <K, V> List<Map.Entry<K, V>>
mapObject(Map<K, V> object, Function<out Object, V> func)
static <K, V> List<Map.Entry<K, V>>
pairs(Map<K, V> object)
static <K, V> List<Map.Entry<V, K>>
invert(Map<K, V> object)
static List<String>
functions(Object object)
static List<String>
methods(Object object)
static <K, V> Map<K, V>
extend(Map<K, V> destination, Array<Map<K, V>> sources)
static <E> E
findKey(List<E> list, Predicate<E> pred)
static <E> E
findKey(Array<E> array, Predicate<E> pred)
static <E> E
findLastKey(List<E> list, Predicate<E> pred)
static <E> E
findLastKey(Array<E> array, Predicate<E> pred)
static <K, V> List<Map.Entry<K, V>>
pick(Map<K, V> object, Array<K> keys)
static <K, V> List<Map.Entry<K, V>>
pick(Map<K, V> object, Predicate<V> pred)
static <K, V> List<Map.Entry<K, V>>
omit(Map<K, V> object, Array<K> keys)
static <K, V> List<Map.Entry<K, V>>
omit(Map<K, V> object, Predicate<V> pred)
static <K, V> Map<K, V>
defaults(Map<K, V> object, Map<K, V> defaults)
static Object
clone(Object obj)
static <E> Array<E>
clone(Array<E> iterable)
static <T> void
tap(Iterable<T> iterable, Consumer<out Object> func)
static <K, V> boolean
isMatch(Map<K, V> object, Map<K, V> properties)
static boolean
isEqual(Object object, Object other)
static <K, V> boolean
isEmpty(Map<K, V> object)
static <T> boolean
isEmpty(Iterable<T> iterable)
boolean
isEmpty()
static <K, V> boolean
isNotEmpty(Map<K, V> object)
static <T> boolean
isNotEmpty(Iterable<T> iterable)
boolean
isNotEmpty()
static boolean
isArray(Object object)
static boolean
isObject(Object object)
static boolean
isFunction(Object object)
static boolean
isString(Object object)
static boolean
isNumber(Object object)
static boolean
isDate(Object object)
static boolean
isRegExp(Object object)
static boolean
isError(Object object)
static boolean
isBoolean(Object object)
static boolean
isNull(Object object)
static <K, V> boolean
has(Map<K, V> object, K key)
static <E> E
identity(E value)
static <E> Supplier<E>
constant(E value)
static <K, V> Function<Map<K, V>, V>
property(K key)
static <K, V> Function<K, V>
propertyOf(Map<K, V> object)
static <K, V> Predicate<Map<K, V>>
matcher(Map<K, V> object)
static void
times(int count, Runnable runnable)
static int
random(int min, int max)
static int
random(int max)
static long
now()
static String
escape(String value)
static String
unescape(String value)
static <E> Object
result(Iterable<E> iterable, Predicate<E> pred)
static String
uniqueId(String prefix)
static String
uniquePassword()
static <K, V> Underscore.Template<Map<K, V>>
template(String template)
static String
format(String template, Array<Object> params)
static <T> Iterable<T>
iterate(T seed, UnaryOperator<T> unaryOperator)
static <T> Underscore.Chain<T>
chain(List<T> list)
static Underscore.Chain<Map<String, Object>>
chain(Map<String, Object> map)
static <T> Underscore.Chain<T>
chain(Iterable<T> iterable)
static <T> Underscore.Chain<T>
chain(Iterable<T> iterable, int size)
static <T> Underscore.Chain<T>
chain(Array<T> array)
static Underscore.Chain<Integer>
chain(Array<int> array)
Underscore.Chain<T>
chain()
static <T> Underscore.Chain<T>
of(List<T> list)
static <T> Underscore.Chain<T>
of(Iterable<T> iterable)
static <T> Underscore.Chain<T>
of(Iterable<T> iterable, int size)
static <T> Underscore.Chain<T>
of(Array<T> array)
static Underscore.Chain<Integer>
of(Array<int> array)
Underscore.Chain<T>
of()
static void
mixin(String funcName, UnaryOperator<String> func)
Optional<String>
call(String funcName)
static <T extends Comparable<T>> List<T>
sort(Iterable<T> iterable)
static <T extends Comparable<T>> Array<T>
sort(Array<T> array)
List<Comparable>
sort()
static <T> String
join(Iterable<T> iterable, String separator)
static <T> String
join(Iterable<T> iterable)
static <T> String
join(Array<T> array, String separator)
static <T> String
join(Array<T> array)
String
join(String separator)
String
join()
static <T> List<T>
push(List<T> list, Array<T> values)
List<T>
push(Array<T> values)
static <T> Map.Entry<T, List<T>>
pop(List<T> list)
Map.Entry<T, List<T>>
pop()
static <T> List<T>
unshift(List<T> list, Array<T> values)
List<T>
unshift(Array<T> values)
static <T> Map.Entry<T, List<T>>
shift(List<T> list)
Map.Entry<T, List<T>>
shift()
static <T> Array<T>
concat(Array<T> first, Array<Array<T>> other)
static <T> List<T>
concat(Iterable<T> first, Array<Iterable<T>> other)
List<T>
concatWith(Array<Iterable<T>> other)
static <T> List<T>
slice(Iterable<T> iterable, int start)
static <T> Array<T>
slice(Array<T> array, int start)
List<T>
slice(int start)
static <T> List<T>
slice(Iterable<T> iterable, int start, int end)
static <T> Array<T>
slice(Array<T> array, int start, int end)
List<T>
slice(int start, int end)
static <T> List<List<T>>
splitAt(Iterable<T> iterable, int position)
static <T> List<List<T>>
splitAt(Array<T> array, int position)
List<List<T>>
splitAt(int position)
static <T> List<T>
takeSkipping(Iterable<T> iterable, int stepSize)
static <T> List<T>
takeSkipping(Array<T> array, int stepSize)
List<T>
takeSkipping(int stepSize)
static <T> List<T>
reverse(Iterable<T> iterable)
static <T> Array<T>
reverse(Array<T> array)
static List<Integer>
reverse(Array<int> array)
List<T>
reverse()
Iterable<T>
value()
static <T> ScheduledFuture<T>
setTimeout(Supplier<T> function, int delayMilliseconds)
static void
clearTimeout(ScheduledFuture<out Object> scheduledFuture)
static <T> ScheduledFuture
setInterval(Supplier<T> function, int delayMilliseconds)
static void
clearInterval(ScheduledFuture scheduledFuture)
static <T> List<T>
copyOf(Iterable<T> iterable)
List<T>
copyOf()
static <T> List<T>
copyOfRange(Iterable<T> iterable, int start, int end)
List<T>
copyOfRange(int start, int end)
static <T> T
elementAt(List<T> list, int index)
T
elementAt(int index)
static <T> T
get(List<T> list, int index)
T
get(int index)
static <T> Map.Entry<T, List<T>>
set(List<T> list, int index, T value)
Map.Entry<T, List<T>>
set(int index, T value)
static <T> T
elementAtOrElse(List<T> list, int index, T defaultValue)
T
elementAtOrElse(int index, T defaultValue)
static <T> T
elementAtOrNull(List<T> list, int index)
T
elementAtOrNull(int index)
static <T> int
lastIndex(Iterable<T> iterable)
static <T> int
lastIndex(Array<T> array)
static int
lastIndex(Array<int> array)
static <T> T
checkNotNull(T reference)
static <T> List<T>
checkNotNullElements(List<T> references)
static <T> T
checkNotNull(T reference, Object errorMessage)
static boolean
nonNull(Object obj)
static <T> T
defaultTo(T value, T defaultValue)
static <T> Predicate<T>
and(Predicate<out Object> pred1, Predicate<out Object> pred2, Array<Predicate<out Object>> rest)
static <T> Predicate<T>
or(Predicate<out Object> pred1, Predicate<out Object> pred2, Array<Predicate<out Object>> rest)
static void
main(Array<String> args)
-
-
Method Detail
-
getIterable
Iterable<T> getIterable()
-
templateSettings
static void templateSettings(Map<String, String> templateSettings)
-
eachIndexed
static <T> void eachIndexed(Iterable<T> iterable, BiConsumer<Integer, out Object> func)
-
forEachIndexed
static <T> void forEachIndexed(Iterable<T> iterable, BiConsumer<Integer, out Object> func)
-
forEachIndexed
void forEachIndexed(BiConsumer<Integer, out Object> func)
-
forEachRight
static <T> void forEachRight(Iterable<T> iterable, Consumer<out Object> func)
-
forEachRight
void forEachRight(Consumer<out Object> func)
-
mapIndexed
static <T, E> List<T> mapIndexed(List<E> list, BiFunction<Integer, out Object, T> func)
-
replaceIndexed
static <T> List<T> replaceIndexed(Iterable<T> iter, Underscore.PredicateIndexed<T> pred, T value)
-
replaceIndexed
List<T> replaceIndexed(Underscore.PredicateIndexed<T> pred, T value)
-
mapIndexed
<F> List<F> mapIndexed(BiFunction<Integer, out Object, F> func)
-
reduceRight
static <T, E> E reduceRight(Iterable<T> iterable, BiFunction<E, T, E> func, E zeroElem)
-
reduceRight
static <T> Optional<T> reduceRight(Iterable<T> iterable, BinaryOperator<T> func)
-
reduceRight
static <E> E reduceRight(Array<int> array, BiFunction<E, out Object, E> func, E zeroElem)
-
reduceRight
static <T, E> E reduceRight(Array<T> array, BiFunction<E, T, E> func, E zeroElem)
-
filterIndexed
static <E> List<E> filterIndexed(List<E> list, Underscore.PredicateIndexed<E> pred)
-
rejectIndexed
static <E> List<E> rejectIndexed(List<E> list, Underscore.PredicateIndexed<E> pred)
-
filterFalse
List<T> filterFalse(Predicate<T> pred)
-
containsWith
static <E> boolean containsWith(Iterable<E> iterable, E elem)
-
containsWith
boolean containsWith(T elem)
-
containsAtLeast
boolean containsAtLeast(T value, int count)
-
containsAtMost
boolean containsAtMost(T value, int count)
-
containsAtLeast
static <E> boolean containsAtLeast(Iterable<E> iterable, E value, int count)
-
containsAtMost
static <E> boolean containsAtMost(Iterable<E> iterable, E value, int count)
-
findWhere
static <T, E> Optional<E> findWhere(Iterable<E> iterable, List<Map.Entry<String, T>> properties)
-
max
static <E extends Comparable<out Object>> E max(Collection<E> collection)
-
max
static <E, F extends Comparable> E max(Collection<E> collection, Function<E, F> func)
-
min
static <E extends Comparable<out Object>> E min(Collection<E> collection)
-
min
static <E, F extends Comparable> E min(Collection<E> collection, Function<E, F> func)
-
sortWith
static <T extends Comparable<out Object>> List<T> sortWith(Iterable<T> iterable, Comparator<T> comparator)
-
sortWith
<E extends Comparable<out Object>> List<E> sortWith(Comparator<E> comparator)
-
sortBy
static <E, T extends Comparable<out Object>> List<E> sortBy(Iterable<E> iterable, Function<E, T> func)
-
sortBy
static <K, V extends Comparable<out Object>> List<Map<K, V>> sortBy(Iterable<Map<K, V>> iterable, K key)
-
groupBy
static <K, E> Map<K, Optional<E>> groupBy(Iterable<E> iterable, Function<E, K> func, BinaryOperator<E> binaryOperator)
-
toCardinalityMap
Map<T, Integer> toCardinalityMap()
-
size
int size()
-
singleOrNull
T singleOrNull()
-
singleOrNull
T singleOrNull(Predicate<T> pred)
-
singleOrNull
static <E> E singleOrNull(Iterable<E> iterable)
-
firstOrNull
static <E> E firstOrNull(Iterable<E> iterable)
-
firstOrNull
T firstOrNull()
-
firstOrNull
T firstOrNull(Predicate<T> pred)
-
lastOrNull
static <E> E lastOrNull(List<E> list)
-
lastOrNull
T lastOrNull()
-
lastOrNull
T lastOrNull(Predicate<T> pred)
-
distinctBy
static <K, E> Collection<E> distinctBy(Iterable<E> iterable, Function<E, K> func)
-
findLastIndex
static <E> int findLastIndex(List<E> list, Predicate<E> pred)
-
findLastIndex
static <E> int findLastIndex(Array<E> array, Predicate<E> pred)
-
binarySearch
static <E extends Comparable<E>> int binarySearch(Iterable<E> iterable, E key)
-
binarySearch
static <E extends Comparable<E>> int binarySearch(Array<E> array, E key)
-
sortedIndex
static <E extends Comparable<E>> int sortedIndex(List<E> list, E value)
-
sortedIndex
static <E extends Comparable<E>> int sortedIndex(Array<E> array, E value)
-
sortedIndex
static <E extends Comparable<E>> int sortedIndex(List<E> list, E value, String propertyName)
-
sortedIndex
static <E extends Comparable<E>> int sortedIndex(Array<E> array, E value, String propertyName)
-
lastIndexOf
static <E> int lastIndexOf(List<E> list, E value)
-
lastIndexOf
static <E> int lastIndexOf(Array<E> array, E value)
-
interposeByList
List<T> interposeByList(Iterable<T> interIter)
-
delay
static <T> ScheduledFuture<T> delay(Supplier<T> function, int delayMilliseconds)
-
defer
static <T> ScheduledFuture<T> defer(Supplier<T> function)
-
defer
static ScheduledFuture<Void> defer(Runnable runnable)
-
wrap
static <T> Function<Void, T> wrap(UnaryOperator<T> function, Function<UnaryOperator<T>, T> wrapper)
-
mapObject
static <K, V> List<Map.Entry<K, V>> mapObject(Map<K, V> object, Function<out Object, V> func)
-
isEmpty
boolean isEmpty()
-
isNotEmpty
static <K, V> boolean isNotEmpty(Map<K, V> object)
-
isNotEmpty
static <T> boolean isNotEmpty(Iterable<T> iterable)
-
isNotEmpty
boolean isNotEmpty()
-
isFunction
static boolean isFunction(Object object)
-
random
static int random(int min, int max)
-
random
static int random(int max)
-
now
static long now()
-
uniquePassword
static String uniquePassword()
-
chain
static <T> Underscore.Chain<T> chain(List<T> list)
-
chain
static <T> Underscore.Chain<T> chain(Iterable<T> iterable)
-
chain
static <T> Underscore.Chain<T> chain(Iterable<T> iterable, int size)
-
chain
static <T> Underscore.Chain<T> chain(Array<T> array)
-
chain
static Underscore.Chain<Integer> chain(Array<int> array)
-
chain
Underscore.Chain<T> chain()
-
of
static <T> Underscore.Chain<T> of(List<T> list)
-
of
static <T> Underscore.Chain<T> of(Iterable<T> iterable)
-
of
static <T> Underscore.Chain<T> of(Iterable<T> iterable, int size)
-
of
static <T> Underscore.Chain<T> of(Array<T> array)
-
of
static Underscore.Chain<Integer> of(Array<int> array)
-
of
Underscore.Chain<T> of()
-
mixin
static void mixin(String funcName, UnaryOperator<String> func)
-
sort
List<Comparable> sort()
-
takeSkipping
static <T> List<T> takeSkipping(Iterable<T> iterable, int stepSize)
-
takeSkipping
static <T> List<T> takeSkipping(Array<T> array, int stepSize)
-
takeSkipping
List<T> takeSkipping(int stepSize)
-
setTimeout
static <T> ScheduledFuture<T> setTimeout(Supplier<T> function, int delayMilliseconds)
-
clearTimeout
static void clearTimeout(ScheduledFuture<out Object> scheduledFuture)
-
setInterval
static <T> ScheduledFuture setInterval(Supplier<T> function, int delayMilliseconds)
-
clearInterval
static void clearInterval(ScheduledFuture scheduledFuture)
-
copyOfRange
static <T> List<T> copyOfRange(Iterable<T> iterable, int start, int end)
-
copyOfRange
List<T> copyOfRange(int start, int end)
-
elementAtOrElse
static <T> T elementAtOrElse(List<T> list, int index, T defaultValue)
-
elementAtOrElse
T elementAtOrElse(int index, T defaultValue)
-
elementAtOrNull
static <T> T elementAtOrNull(List<T> list, int index)
-
elementAtOrNull
T elementAtOrNull(int index)
-
checkNotNull
static <T> T checkNotNull(T reference)
-
checkNotNullElements
static <T> List<T> checkNotNullElements(List<T> references)
-
checkNotNull
static <T> T checkNotNull(T reference, Object errorMessage)
-
and
static <T> Predicate<T> and(Predicate<out Object> pred1, Predicate<out Object> pred2, Array<Predicate<out Object>> rest)
-
or
static <T> Predicate<T> or(Predicate<out Object> pred1, Predicate<out Object> pred2, Array<Predicate<out Object>> rest)
-
-
-
-