Package com.github.underscore
Class Underscore<T>
java.lang.Object
com.github.underscore.Underscore<T>
- Direct Known Subclasses:
U
Underscore-java17 is a java port of Underscore.js.
- Author:
- Valentyn Kolesnikov
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic interfacestatic classprivate static final classstatic interfacestatic interfaceprivate static final classprivate static final class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Stringprivate static final longprivate static final longprivate static final longprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Patternprivate static final Stringprivate static final intprivate static final Stringprivate static final AtomicInteger -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <E> Supplier<E>static <E> booleanbooleanstatic <T> Predicate<T>static <E> booleanbooleanstatic <K,E> Map<K, E> associateBy(Iterable<E> iterable, Function<E, K> func) <K,E> Map<K, E> associateBy(Function<E, K> func) static <E> Supplier<E>static <E extends Comparable<E>>
intbinarySearch(E[] array, E key) static <E extends Comparable<E>>
intbinarySearch(Iterable<E> iterable, E key) static <T,F> Function<F, T> chain()static Underscore.Chain<Integer>chain(int[] array) static <T> Underscore.Chain<T>static <T> Underscore.Chain<T>static <T> Underscore.Chain<T>static Underscore.Chain<Map<String,Object>> static <T> Underscore.Chain<T>chain(T... array) static <T> TcheckNotNull(T reference) static <T> TcheckNotNull(T reference, Object errorMessage) static <T> List<T>checkNotNullElements(List<T> references) chunk(int size) chunk(int size, int step) static voidclearInterval(ScheduledFuture scheduledFuture) static voidclearTimeout(ScheduledFuture<?> scheduledFuture) static <E> E[]clone(E... iterable) static Objectstatic <T,E> List<T> static <T,E> Set<T> compact()static <E> E[]compact(E... array) static <E> E[]compact(E[] array, E falsyValue) static <E> List<E>static <E> List<E>compactList(List<E> list, E falsyValue) static <T> Function<T,T> static <T> List<T>static <T> T[]concat(T[] first, T[]... other) concatWith(Iterable<T>... other) static <E> Supplier<E>constant(E value) static <E> booleanstatic <E> booleanbooleanstatic <E> booleancontainsAtLeast(Iterable<E> iterable, E value, int count) booleancontainsAtLeast(T value, int count) static <E> booleancontainsAtMost(Iterable<E> iterable, E value, int count) booleancontainsAtMost(T value, int count) static <E> booleancontainsWith(Iterable<E> iterable, E elem) booleancontainsWith(T elem) copyOf()static <T> List<T>copyOfRange(int start, int end) static <T> List<T>copyOfRange(Iterable<T> iterable, int start, int end) static <E> intintcountBy()cycle(int times) static <T> List<T>static <T> Supplier<T>static <K,V> Map<K, V> static <T> TdefaultTo(T value, T defaultValue) static ScheduledFuture<Void>static <T> ScheduledFuture<T>static <T> ScheduledFuture<T>static <E> Optional<E>static <E> E[]difference(E[]... arrays) static <E> List<E>difference(List<E> list1, List<E> list2) static <E> List<E>difference(List<E> list, List<E>... lists) differenceWith(List<T>... lists) static <E> E[]distinct(E... array) static <E> List<E>static <K,E> E[] distinctBy(E[] array, Function<E, K> func) static <K,E> Collection<E> distinctBy(Iterable<E> iterable, Function<E, K> func) private static <E> voidstatic <E> E[]drop(E... array) static <E> E[]drop(E[] array, int n) static <E> List<E>static <E> List<E>static <T> voidvoidstatic <T> voideachIndexed(Iterable<T> iterable, BiConsumer<Integer, ? super T> func) static <T> voidvoidelementAt(int index) static <T> TelementAtOrElse(int index, T defaultValue) static <T> TelementAtOrElse(List<T> list, int index, T defaultValue) elementAtOrNull(int index) static <T> TelementAtOrNull(List<T> list, int index) static Stringstatic <E> booleanbooleanstatic <K,V> Map<K, V> static <E> List<E>static <E> List<E>static <E> Set<E>filterFalse(Predicate<T> pred) static <E> List<E>filterFalse(List<E> list, Predicate<E> pred) static <E> Set<E>filterFalse(Set<E> set, Predicate<E> pred) static <E> List<E>filterIndexed(List<E> list, Underscore.PredicateIndexed<E> pred) static <E> Optional<E>static <E> intstatic <E> intstatic <E> Estatic <E> Estatic <E> Optional<E>static <E> intfindLastIndex(E[] array, Predicate<E> pred) static <E> intfindLastIndex(List<E> list, Predicate<E> pred) static <E> EfindLastKey(E[] array, Predicate<E> pred) static <E> EfindLastKey(List<E> list, Predicate<E> pred) static <T,E> Optional<E> first()first(int n) static <E> Efirst(E... array) static <E> Estatic <E> Estatic <E> List<E>static <E> List<E>static <E> EfirstOrNull(Iterable<E> iterable) static <E> EfirstOrNull(Iterable<E> iterable, Predicate<E> pred) firstOrNull(Predicate<T> pred) flatten()flatten(boolean shallow) static <E> List<E>static <E> List<E>private static <E> voidstatic <T,E> E foldl(Iterable<T> iterable, BiFunction<E, T, E> func, E zeroElem) static <T,E> E foldr(Iterable<T> iterable, BiFunction<E, T, E> func, E zeroElem) static <T> voidvoidstatic <T> voidforEachIndexed(Iterable<T> iterable, BiConsumer<Integer, ? super T> func) voidforEachIndexed(BiConsumer<Integer, ? super T> func) static <T> voidforEachRight(Iterable<T> iterable, Consumer<? super T> func) voidforEachRight(Consumer<? super T> func) static Stringget(int index) static <T> TgroupBy(Iterable<E> iterable, Function<E, K> func, BinaryOperator<E> binaryOperator) groupBy(Function<E, K> func, BinaryOperator<E> binaryOperator) static <K,V> boolean head()head(int n) static <E> Ehead(E... array) static <E> Estatic <E> List<E>static <E> Eidentity(E value) static <E> booleanstatic <E> intindexOf(E[] array, E value) static <E> intinitial()initial(int n) static <E> E[]initial(E... array) static <E> E[]initial(E[] array, int n) static <E> List<E>static <E> List<E>static <T,E> E inject(Iterable<T> iterable, BiFunction<E, T, E> func, E zeroElem) static <T> List<T>interposeByList(Iterable<T> interIter) static <T> List<T>interposeByList(Iterable<T> iterable, Iterable<T> interIter) static <E> E[]intersection(E[]... arrays) static <E> List<E>intersection(List<E> list1, List<E> list2) static <E> List<E>intersection(List<E> list, List<E>... lists) intersectionWith(List<T>... lists) static <E> List<E>static <E> List<E>static booleanstatic booleanstatic booleanbooleanisEmpty()static <T> booleanstatic <K,V> boolean static booleanstatic booleanstatic booleanisFunction(Object object) static <K,V> boolean booleanstatic <T> booleanisNotEmpty(Iterable<T> iterable) static <K,V> boolean isNotEmpty(Map<K, V> object) static booleanstatic booleanstatic booleanstatic booleanstatic booleanstatic <T> Iterable<T>iterate(T seed, UnaryOperator<T> unaryOperator) iteratee(K key) join()static <T> Stringstatic <T> Stringstatic <T> Stringjoin(T[] array) static <T> Stringstatic <T> StringjoinToString(Iterable<T> iterable, String separator, String prefix, String postfix, int limit, String truncated, Function<T, String> transform) private static voidjoinToStringPostfix(String postfix, int limit, String truncated, int index, StringBuilder sb) static <K,V> Set<K> last()last(int n) static <E> Elast(E... array) static <E> Estatic <E> List<E>static <E> Estatic intlastIndex(int[] array) static <T> intstatic <T> intlastIndex(T[] array) static <E> intlastIndexOf(E[] array, E value) static <E> intlastIndexOf(List<E> list, E value) lastOrNull(Predicate<T> pred) static <E> ElastOrNull(List<E> list) static <E> ElastOrNull(List<E> list, Predicate<E> pred) static voidstatic <T> List<T><F> List<F>static <T,E> List<T> static <T,E> Set<T> <F> List<F>mapIndexed(BiFunction<Integer, ? super T, F> func) static <T,E> List<T> mapIndexed(List<E> list, BiFunction<Integer, ? super E, T> func) static <T,E> List<T> mapMulti(List<E> list, BiConsumer<? super E, ? super Consumer<T>> mapper) max()static <E extends Comparable<? super E>>
Emax(Collection<E> collection) static <E,F extends Comparable>
Emax(Collection<E> collection, Function<E, F> func) <F extends Comparable<? super F>>
Tstatic <T,F> Function<F, T> min()static <E extends Comparable<? super E>>
Emin(Collection<E> collection) static <E,F extends Comparable>
Emin(Collection<E> collection, Function<E, F> func) <F extends Comparable<? super F>>
Tstatic voidmixin(String funcName, UnaryOperator<String> func) static <E> Predicate<E>protected static <T> List<T>newArrayList(Iterable<T> iterable) protected static <T> List<T>newArrayList(Iterable<T> iterable, int size) protected static <T> List<T>newArrayList(T object) protected static <T> List<T>newArrayListWithExpectedSize(int size) newIntegerList(int... array) protected static <T> Set<T>newLinkedHashSet(Iterable<T> iterable) protected static <T> Set<T>newLinkedHashSetWithExpectedSize(int size) static booleanstatic longnow()of()static Underscore.Chain<Integer>of(int[] array) static <T> Underscore.Chain<T>static <T> Underscore.Chain<T>static <T> Underscore.Chain<T>static <T> Underscore.Chain<T>of(T... array) static <T> Supplier<T>static <T> Predicate<T>static <E> List<E>[]pop()property(K key) static <K,V> Function<K, V> propertyOf(Map<K, V> object) static <T> List<T>static intrandom(int max) static intrandom(int min, int max) range(char stop) range(char start, char stop) range(char start, char stop, int step) range(int stop) range(int start, int stop) range(int start, int stop, int step) static <E> Ereduce(int[] array, BiFunction<E, ? super Integer, E> func, E zeroElem) 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 <T,E> E reduce(T[] array, BiFunction<E, T, E> func, E zeroElem) static <E> EreduceRight(int[] array, BiFunction<E, ? super Integer, 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 <T,E> E reduceRight(T[] array, BiFunction<E, T, E> func, E zeroElem) static <E> List<E>static <E> Set<E>static <E> List<E>rejectIndexed(List<E> list, Underscore.PredicateIndexed<E> pred) static <T> List<T>repeat(T element, int times) static <T> List<T>replaceIndexed(Underscore.PredicateIndexed<T> pred, T value) static <T> List<T>replaceIndexed(Iterable<T> iter, Underscore.PredicateIndexed<T> pred, T value) rest()rest(int n) static <E> E[]rest(E... array) static <E> E[]rest(E[] array, int n) static <E> List<E>static <E> List<E>static <E> Objectreverse()reverse(int[] array) static <T> List<T>static <T> T[]reverse(T... array) sample()static <E> Estatic <E> Set<E>static <E> List<E>static <E> Set<E>static <T> ScheduledFuturesetInterval(Supplier<T> function, int delayMilliseconds) private static voidsetTemplateKey(Map<String, String> templateSettings, String key) static <T> ScheduledFuture<T>setTimeout(Supplier<T> function, int delayMilliseconds) shift()shuffle()static <E> List<E>static <E> EsingleOrNull(Iterable<E> iterable) static <E> EsingleOrNull(Iterable<E> iterable, Predicate<E> pred) singleOrNull(Predicate<T> pred) intsize()static <E> intsize(E... array) static intslice(int start) slice(int start, int end) static <T> List<T>static <T> List<T>static <T> T[]slice(T[] array, int start) static <T> T[]slice(T[] array, int start, int end) static <E> booleanbooleansort()static <T extends Comparable<T>>
List<T>static <T extends Comparable<T>>
T[]sort(T... array) static <E,T extends Comparable<? super T>>
List<E>static <K,V extends Comparable<? super V>>
List<Map<K,V>> <E,V extends Comparable<? super V>>
List<E>static <E extends Comparable<E>>
intsortedIndex(E[] array, E value) static <E extends Comparable<E>>
intsortedIndex(E[] array, E value, String propertyName) static <E extends Comparable<E>>
intsortedIndex(List<E> list, E value) static <E extends Comparable<E>>
intsortedIndex(List<E> list, E value, String propertyName) static <T extends Comparable<? super T>>
List<T>sortWith(Iterable<T> iterable, Comparator<T> comparator) <E extends Comparable<? super E>>
List<E>sortWith(Comparator<E> comparator) splitAt(int position) splitAt(T[] array, int position) tail()tail(int n) static <E> E[]tail(E... array) static <E> E[]tail(E[] array, int n) static <E> List<E>static <E> List<E>takeSkipping(int stepSize) static <T> List<T>takeSkipping(Iterable<T> iterable, int stepSize) static <T> List<T>takeSkipping(T[] array, int stepSize) static <T> voidstatic <K,V> Underscore.Template<Map<K, V>> static voidtemplateSettings(Map<String, String> templateSettings) static <T> Supplier<T>static void<E> E[]toArray()static <E> E[]toCardinalityMap(Iterable<K> iterable) <K,V> Map<K, V> toMap()static <K,V> Map<K, V> static <K,V> Map<K, V> static Stringstatic <E> E[]union(E[]... arrays) static <E> List<E>static <E> E[]uniq(E... array) static <K,E> E[] static <K,E> Collection<E> static <E> List<E>static Stringstatic Stringstatic <T> List<T>value()static <K,V> Collection<V> static <T,E> List<E> static <T,E> Set<E> static <E> E[]without(E[] array, E... values) static <E> List<E>wrap(UnaryOperator<T> function, Function<UnaryOperator<T>, T> wrapper)
-
Field Details
-
FUNCTIONS
-
TEMPLATE_SETTINGS
-
MIN_PASSWORD_LENGTH_8
private static final int MIN_PASSWORD_LENGTH_8- See Also:
-
CAPACITY_SIZE_5
private static final long CAPACITY_SIZE_5- See Also:
-
CAPACITY_COEFF_2
private static final long CAPACITY_COEFF_2- See Also:
-
CAPACITY_SIZE_16
private static final long CAPACITY_SIZE_16- See Also:
-
UNIQUE_ID
-
ALL_SYMBOLS
- See Also:
-
EVALUATE
- See Also:
-
INTERPOLATE
- See Also:
-
ESCAPE
- See Also:
-
S_Q
- See Also:
-
E_S
- See Also:
-
FORMAT_PATTERN
-
ESCAPES
-
iterable
-
string
-
-
Constructor Details
-
Underscore
-
Underscore
-
-
Method Details
-
setTemplateKey
-
templateSettings
-
iteratee
-
each
-
eachIndexed
-
each
-
eachRight
-
eachRight
-
forEach
-
forEachIndexed
-
forEach
-
forEachIndexed
-
forEachRight
-
forEachRight
-
map
-
mapMulti
public static <T,E> List<T> mapMulti(List<E> list, BiConsumer<? super E, ? super Consumer<T>> mapper) -
map
-
map
-
map
-
mapIndexed
-
replace
-
replace
-
replaceIndexed
public static <T> List<T> replaceIndexed(Iterable<T> iter, Underscore.PredicateIndexed<T> pred, T value) -
replaceIndexed
-
mapIndexed
-
collect
-
collect
-
reduce
-
reduce
-
reduce
-
reduce
-
foldl
-
inject
-
reduceRight
-
reduceRight
-
reduceRight
-
reduceRight
-
foldr
-
find
-
detect
-
findLast
-
filter
-
filter
-
filter
-
filterIndexed
-
filter
-
select
-
select
-
reject
-
reject
-
rejectIndexed
-
reject
-
filterFalse
-
filterFalse
-
filterFalse
-
every
-
every
-
all
-
all
-
some
-
some
-
any
-
any
-
count
-
count
-
contains
-
contains
-
containsWith
-
containsWith
-
contains
-
containsAtLeast
-
containsAtMost
-
containsAtLeast
-
containsAtMost
-
include
-
invoke
-
doInvoke
-
invoke
-
invoke
-
invoke
-
pluck
-
pluck
-
pluck
-
where
-
where
-
where
-
findWhere
-
findWhere
-
max
-
max
-
max
-
max
-
min
-
min
-
min
-
min
-
shuffle
-
shuffle
-
sample
-
sample
-
sample
-
sortWith
public static <T extends Comparable<? super T>> List<T> sortWith(Iterable<T> iterable, Comparator<T> comparator) -
sortWith
-
sortBy
public static <E,T extends Comparable<? super T>> List<E> sortBy(Iterable<E> iterable, Function<E, T> func) -
sortBy
-
sortBy
public static <K,V extends Comparable<? super V>> List<Map<K,V>> sortBy(Iterable<Map<K, V>> iterable, K key) -
groupBy
-
groupBy
-
groupBy
public static <K,E> Map<K,Optional<E>> groupBy(Iterable<E> iterable, Function<E, K> func, BinaryOperator<E> binaryOperator) -
groupBy
-
associateBy
-
associateBy
-
indexBy
-
indexBy
-
countBy
-
countBy
-
countBy
-
countBy
-
toArray
-
toArray
public <E> E[] toArray() -
toMap
-
toMap
-
toMap
-
toCardinalityMap
-
toCardinalityMap
-
size
-
size
public int size() -
size
public static <E> int size(E... array) -
partition
-
partition
-
singleOrNull
-
singleOrNull
-
singleOrNull
-
singleOrNull
-
first
-
first
public static <E> E first(E... array) -
first
-
first
-
first
-
first
-
first
-
first
-
first
-
firstOrNull
-
firstOrNull
-
firstOrNull
-
firstOrNull
-
head
-
head
public static <E> E head(E... array) -
head
-
head
-
head
-
initial
-
initial
-
initial
public static <E> E[] initial(E... array) -
initial
public static <E> E[] initial(E[] array, int n) -
initial
-
initial
-
last
public static <E> E last(E... array) -
last
-
last
-
last
-
last
-
last
-
last
-
lastOrNull
-
lastOrNull
-
lastOrNull
-
lastOrNull
-
rest
-
rest
-
rest
public static <E> E[] rest(E... array) -
rest
public static <E> E[] rest(E[] array, int n) -
rest
-
rest
-
tail
-
tail
-
tail
public static <E> E[] tail(E... array) -
tail
public static <E> E[] tail(E[] array, int n) -
tail
-
tail
-
drop
-
drop
-
drop
public static <E> E[] drop(E... array) -
drop
public static <E> E[] drop(E[] array, int n) -
compact
-
compact
public static <E> E[] compact(E... array) -
compactList
-
compact
public static <E> E[] compact(E[] array, E falsyValue) -
compact
-
compact
-
flatten
-
flatten
-
flatten
-
flatten
-
flatten
-
without
-
without
public static <E> E[] without(E[] array, E... values) -
uniq
-
uniq
public static <E> E[] uniq(E... array) -
uniq
-
uniq
-
distinct
-
distinct
public static <E> E[] distinct(E... array) -
distinctBy
-
distinctBy
-
union
-
unionWith
-
union
public static <E> E[] union(E[]... arrays) -
intersection
-
intersection
-
intersectionWith
-
intersection
public static <E> E[] intersection(E[]... arrays) -
difference
-
difference
-
differenceWith
-
difference
public static <E> E[] difference(E[]... arrays) -
zip
-
unzip
-
object
-
findIndex
-
findIndex
-
findLastIndex
-
findLastIndex
-
binarySearch
-
binarySearch
-
sortedIndex
-
sortedIndex
-
sortedIndex
-
sortedIndex
-
indexOf
-
indexOf
public static <E> int indexOf(E[] array, E value) -
lastIndexOf
-
lastIndexOf
public static <E> int lastIndexOf(E[] array, E value) -
range
-
range
-
range
-
range
-
range
-
range
-
chunk
-
chunk
-
chunkFill
-
chunkFill
-
chunk
-
chunk
-
chunkFill
-
chunkFill
-
cycle
-
cycle
-
repeat
-
interpose
-
interposeByList
-
interpose
-
interposeByList
-
bind
-
memoize
-
delay
-
defer
-
defer
-
throttle
-
debounce
-
wrap
public static <T> Function<Void,T> wrap(UnaryOperator<T> function, Function<UnaryOperator<T>, T> wrapper) -
negate
-
compose
-
after
-
before
-
once
-
keys
-
values
-
mapObject
-
pairs
-
invert
-
functions
-
methods
-
extend
-
findKey
-
findKey
-
findLastKey
-
findLastKey
-
pick
-
pick
-
omit
-
omit
-
defaults
-
clone
-
clone
public static <E> E[] clone(E... iterable) -
tap
-
isMatch
-
isEqual
-
isEmpty
-
isEmpty
-
isEmpty
public boolean isEmpty() -
isNotEmpty
-
isNotEmpty
-
isNotEmpty
public boolean isNotEmpty() -
isArray
-
isObject
-
isFunction
-
isString
-
isNumber
-
isDate
-
isRegExp
-
isError
-
isBoolean
-
isNull
-
has
-
identity
public static <E> E identity(E value) -
constant
-
property
-
propertyOf
-
matcher
-
times
-
random
public static int random(int min, int max) -
random
public static int random(int max) -
now
public static long now() -
escape
-
unescape
-
result
-
uniqueId
-
uniquePassword
-
template
-
format
-
iterate
-
chain
-
chain
-
chain
-
chain
-
chain
-
chain
-
chain
-
of
-
of
-
of
-
of
-
of
-
of
-
mixin
-
call
-
sort
-
sort
-
sort
-
join
-
joinToString
-
joinToStringPostfix
private static void joinToStringPostfix(String postfix, int limit, String truncated, int index, StringBuilder sb) -
join
-
join
-
join
-
join
-
join
-
push
-
push
-
pop
-
pop
-
unshift
-
unshift
-
shift
-
shift
-
concat
public static <T> T[] concat(T[] first, T[]... other) -
concat
-
concatWith
-
slice
-
slice
public static <T> T[] slice(T[] array, int start) -
slice
-
slice
-
slice
public static <T> T[] slice(T[] array, int start, int end) -
slice
-
splitAt
-
splitAt
-
splitAt
-
takeSkipping
-
takeSkipping
-
takeSkipping
-
reverse
-
reverse
public static <T> T[] reverse(T... array) -
reverse
-
reverse
-
getIterable
-
value
-
getString
-
setTimeout
-
clearTimeout
-
setInterval
-
clearInterval
-
copyOf
-
copyOf
-
copyOfRange
-
copyOfRange
-
elementAt
-
elementAt
-
get
-
get
-
set
-
set
-
elementAtOrElse
-
elementAtOrElse
-
elementAtOrNull
-
elementAtOrNull
-
lastIndex
-
lastIndex
public static <T> int lastIndex(T[] array) -
lastIndex
public static int lastIndex(int[] array) -
checkNotNull
public static <T> T checkNotNull(T reference) -
checkNotNullElements
-
checkNotNull
-
nonNull
-
defaultTo
public static <T> T defaultTo(T value, T defaultValue) -
newArrayList
-
newArrayList
-
newArrayList
-
newIntegerList
-
newArrayListWithExpectedSize
-
newLinkedHashSet
-
newLinkedHashSetWithExpectedSize
-
and
-
or
-
main
-