Package org.elasticsearch.painless.api
Class Augmentation
- java.lang.Object
-
- org.elasticsearch.painless.api.Augmentation
-
public class Augmentation extends java.lang.Object
Additional methods added to classes. These must be static methods with receiver as first argument
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> boolean
any(java.lang.Iterable<T> receiver, java.util.function.Predicate<T> predicate)
Iterates over the contents of an iterable, and checks whether a predicate is valid for at least one element.static <T> java.util.Collection<T>
asCollection(java.lang.Iterable<T> receiver)
Converts this Iterable to a Collection.static <T> java.util.List<T>
asList(java.lang.Iterable<T> receiver)
Converts this Iterable to a List.static <T,U>
java.lang.Objectcollect(java.util.Collection<T> receiver, java.util.Collection<U> collection, java.util.function.Function<T,U> function)
Iterates through this collection transforming each entry into a new value using the function, adding the values to the specified collection.static <T,U>
java.util.List<U>collect(java.util.Collection<T> receiver, java.util.function.Function<T,U> function)
Iterates through this collection transforming each entry into a new value using the function, returning a list of transformed values.static <K,V,T>
java.lang.Objectcollect(java.util.Map<K,V> receiver, java.util.Collection<T> collection, java.util.function.BiFunction<K,V,T> function)
Iterates through this map transforming each entry into a new value using the function, adding the values to the specified collection.static <K,V,T>
java.util.List<T>collect(java.util.Map<K,V> receiver, java.util.function.BiFunction<K,V,T> function)
Iterates through this map transforming each entry into a new value using the function, returning a list of transformed values.static <T> int
count(java.lang.Iterable<T> receiver, java.util.function.Predicate<T> predicate)
Counts the number of occurrences which satisfy the given predicate from inside this Iterable.static <K,V>
intcount(java.util.Map<K,V> receiver, java.util.function.BiPredicate<K,V> predicate)
Counts the number of occurrences which satisfy the given predicate from inside this Mapstatic java.lang.String
decodeBase64(java.lang.String receiver)
Decode some Base64 bytes and build a UTF-8 encoded string.static <T> java.lang.Object
each(java.lang.Iterable<T> receiver, java.util.function.Consumer<T> consumer)
Iterates through an Iterable, passing each item to the given consumer.static <K,V>
java.lang.Objecteach(java.util.Map<K,V> receiver, java.util.function.BiConsumer<K,V> consumer)
Iterates through a Map, passing each item to the given consumer.static <T> java.lang.Object
eachWithIndex(java.lang.Iterable<T> receiver, java.util.function.ObjIntConsumer<T> consumer)
Iterates through an iterable type, passing each item and the item's index (a counter starting at zero) to the given consumer.static java.lang.String
encodeBase64(java.lang.String receiver)
Encode a String in Base64.static <T> boolean
every(java.lang.Iterable<T> receiver, java.util.function.Predicate<T> predicate)
Used to determine if the given predicate is valid (i.e.static <K,V>
booleanevery(java.util.Map<K,V> receiver, java.util.function.BiPredicate<K,V> predicate)
Used to determine if the given predicate is valid (i.e.static <T> T
find(java.util.Collection<T> receiver, java.util.function.Predicate<T> predicate)
Finds the first value matching the predicate, or returns null.static <K,V>
java.util.Map.Entry<K,V>find(java.util.Map<K,V> receiver, java.util.function.BiPredicate<K,V> predicate)
Finds the first entry matching the predicate, or returns null.static <T> java.util.List<T>
findAll(java.util.Collection<T> receiver, java.util.function.Predicate<T> predicate)
Finds all values matching the predicate, returns as a liststatic <K,V>
java.util.Map<K,V>findAll(java.util.Map<K,V> receiver, java.util.function.BiPredicate<K,V> predicate)
Finds all values matching the predicate, returns as a map.static <T,U>
java.lang.ObjectfindResult(java.util.Collection<T> receiver, java.lang.Object defaultResult, java.util.function.Function<T,U> function)
Iterates through the collection calling the given function for each item but stopping once the first non-null result is found and returning that result.static <T,U>
java.lang.ObjectfindResult(java.util.Collection<T> receiver, java.util.function.Function<T,U> function)
Iterates through the collection calling the given function for each item but stopping once the first non-null result is found and returning that result.static <K,V,T>
java.lang.ObjectfindResult(java.util.Map<K,V> receiver, java.lang.Object defaultResult, java.util.function.BiFunction<K,V,T> function)
Iterates through the map calling the given function for each item but stopping once the first non-null result is found and returning that result.static <K,V,T>
java.lang.ObjectfindResult(java.util.Map<K,V> receiver, java.util.function.BiFunction<K,V,T> function)
Iterates through the map calling the given function for each item but stopping once the first non-null result is found and returning that result.static <T,U>
java.util.List<U>findResults(java.lang.Iterable<T> receiver, java.util.function.Function<T,U> filter)
Iterates through the Iterable transforming items using the supplied function and collecting any non-null results.static <K,V,T>
java.util.List<T>findResults(java.util.Map<K,V> receiver, java.util.function.BiFunction<K,V,T> filter)
Iterates through the map transforming items using the supplied function and collecting any non-null results.static <T> int
getLength(java.util.List<T> receiver)
Exposes List.size() as getLength(), so that .length shortcut works on listsstatic <T,U>
java.util.Map<U,java.util.List<T>>groupBy(java.lang.Iterable<T> receiver, java.util.function.Function<T,U> mapper)
Sorts all Iterable members into groups determined by the supplied mapping function.static <K,V,T>
java.util.Map<T,java.util.Map<K,V>>groupBy(java.util.Map<K,V> receiver, java.util.function.BiFunction<K,V,T> mapper)
Sorts all Map members into groups determined by the supplied mapping function.static <T> java.lang.String
join(java.lang.Iterable<T> receiver, java.lang.String separator)
Concatenates the toString() representation of each item in this Iterable, with the given String as a separator between each item.static java.lang.String
namedGroup(java.util.regex.Matcher receiver, java.lang.String name)
Exposes Matcher.group(String) as namedGroup(String), so it doesn't conflict with group(int)static java.lang.String
replaceAll(java.lang.CharSequence receiver, java.util.regex.Pattern pattern, java.util.function.Function<java.util.regex.Matcher,java.lang.String> replacementBuilder)
Replace all matches.static java.lang.String
replaceFirst(java.lang.CharSequence receiver, java.util.regex.Pattern pattern, java.util.function.Function<java.util.regex.Matcher,java.lang.String> replacementBuilder)
Replace the first match.static <T> java.util.List<java.util.List<T>>
split(java.util.Collection<T> receiver, java.util.function.Predicate<T> predicate)
Splits all items into two collections based on the predicate.static <T extends java.lang.Number>
doublesum(java.lang.Iterable<T> receiver)
Sums the result of an Iterablestatic <T> double
sum(java.lang.Iterable<T> receiver, java.util.function.ToDoubleFunction<T> function)
Sums the result of applying a function to each item of an Iterable.
-
-
-
Method Detail
-
getLength
public static <T> int getLength(java.util.List<T> receiver)
Exposes List.size() as getLength(), so that .length shortcut works on lists
-
namedGroup
public static java.lang.String namedGroup(java.util.regex.Matcher receiver, java.lang.String name)
Exposes Matcher.group(String) as namedGroup(String), so it doesn't conflict with group(int)
-
any
public static <T> boolean any(java.lang.Iterable<T> receiver, java.util.function.Predicate<T> predicate)
Iterates over the contents of an iterable, and checks whether a predicate is valid for at least one element.
-
asCollection
public static <T> java.util.Collection<T> asCollection(java.lang.Iterable<T> receiver)
Converts this Iterable to a Collection. Returns the original Iterable if it is already a Collection.
-
asList
public static <T> java.util.List<T> asList(java.lang.Iterable<T> receiver)
Converts this Iterable to a List. Returns the original Iterable if it is already a List.
-
count
public static <T> int count(java.lang.Iterable<T> receiver, java.util.function.Predicate<T> predicate)
Counts the number of occurrences which satisfy the given predicate from inside this Iterable.
-
each
public static <T> java.lang.Object each(java.lang.Iterable<T> receiver, java.util.function.Consumer<T> consumer)
Iterates through an Iterable, passing each item to the given consumer.
-
eachWithIndex
public static <T> java.lang.Object eachWithIndex(java.lang.Iterable<T> receiver, java.util.function.ObjIntConsumer<T> consumer)
Iterates through an iterable type, passing each item and the item's index (a counter starting at zero) to the given consumer.
-
every
public static <T> boolean every(java.lang.Iterable<T> receiver, java.util.function.Predicate<T> predicate)
Used to determine if the given predicate is valid (i.e. returns true for all items in this iterable).
-
findResults
public static <T,U> java.util.List<U> findResults(java.lang.Iterable<T> receiver, java.util.function.Function<T,U> filter)
Iterates through the Iterable transforming items using the supplied function and collecting any non-null results.
-
groupBy
public static <T,U> java.util.Map<U,java.util.List<T>> groupBy(java.lang.Iterable<T> receiver, java.util.function.Function<T,U> mapper)
Sorts all Iterable members into groups determined by the supplied mapping function.
-
join
public static <T> java.lang.String join(java.lang.Iterable<T> receiver, java.lang.String separator)
Concatenates the toString() representation of each item in this Iterable, with the given String as a separator between each item.
-
sum
public static <T extends java.lang.Number> double sum(java.lang.Iterable<T> receiver)
Sums the result of an Iterable
-
sum
public static <T> double sum(java.lang.Iterable<T> receiver, java.util.function.ToDoubleFunction<T> function)
Sums the result of applying a function to each item of an Iterable.
-
collect
public static <T,U> java.util.List<U> collect(java.util.Collection<T> receiver, java.util.function.Function<T,U> function)
Iterates through this collection transforming each entry into a new value using the function, returning a list of transformed values.
-
collect
public static <T,U> java.lang.Object collect(java.util.Collection<T> receiver, java.util.Collection<U> collection, java.util.function.Function<T,U> function)
Iterates through this collection transforming each entry into a new value using the function, adding the values to the specified collection.
-
find
public static <T> T find(java.util.Collection<T> receiver, java.util.function.Predicate<T> predicate)
Finds the first value matching the predicate, or returns null.
-
findAll
public static <T> java.util.List<T> findAll(java.util.Collection<T> receiver, java.util.function.Predicate<T> predicate)
Finds all values matching the predicate, returns as a list
-
findResult
public static <T,U> java.lang.Object findResult(java.util.Collection<T> receiver, java.util.function.Function<T,U> function)
Iterates through the collection calling the given function for each item but stopping once the first non-null result is found and returning that result. If all results are null, null is returned.
-
findResult
public static <T,U> java.lang.Object findResult(java.util.Collection<T> receiver, java.lang.Object defaultResult, java.util.function.Function<T,U> function)
Iterates through the collection calling the given function for each item but stopping once the first non-null result is found and returning that result. If all results are null, defaultResult is returned.
-
split
public static <T> java.util.List<java.util.List<T>> split(java.util.Collection<T> receiver, java.util.function.Predicate<T> predicate)
Splits all items into two collections based on the predicate. The first list contains all items which match the closure expression. The second list all those that don't.
-
collect
public static <K,V,T> java.util.List<T> collect(java.util.Map<K,V> receiver, java.util.function.BiFunction<K,V,T> function)
Iterates through this map transforming each entry into a new value using the function, returning a list of transformed values.
-
collect
public static <K,V,T> java.lang.Object collect(java.util.Map<K,V> receiver, java.util.Collection<T> collection, java.util.function.BiFunction<K,V,T> function)
Iterates through this map transforming each entry into a new value using the function, adding the values to the specified collection.
-
count
public static <K,V> int count(java.util.Map<K,V> receiver, java.util.function.BiPredicate<K,V> predicate)
Counts the number of occurrences which satisfy the given predicate from inside this Map
-
each
public static <K,V> java.lang.Object each(java.util.Map<K,V> receiver, java.util.function.BiConsumer<K,V> consumer)
Iterates through a Map, passing each item to the given consumer.
-
every
public static <K,V> boolean every(java.util.Map<K,V> receiver, java.util.function.BiPredicate<K,V> predicate)
Used to determine if the given predicate is valid (i.e. returns true for all items in this map).
-
find
public static <K,V> java.util.Map.Entry<K,V> find(java.util.Map<K,V> receiver, java.util.function.BiPredicate<K,V> predicate)
Finds the first entry matching the predicate, or returns null.
-
findAll
public static <K,V> java.util.Map<K,V> findAll(java.util.Map<K,V> receiver, java.util.function.BiPredicate<K,V> predicate)
Finds all values matching the predicate, returns as a map.
-
findResult
public static <K,V,T> java.lang.Object findResult(java.util.Map<K,V> receiver, java.util.function.BiFunction<K,V,T> function)
Iterates through the map calling the given function for each item but stopping once the first non-null result is found and returning that result. If all results are null, null is returned.
-
findResult
public static <K,V,T> java.lang.Object findResult(java.util.Map<K,V> receiver, java.lang.Object defaultResult, java.util.function.BiFunction<K,V,T> function)
Iterates through the map calling the given function for each item but stopping once the first non-null result is found and returning that result. If all results are null, defaultResult is returned.
-
findResults
public static <K,V,T> java.util.List<T> findResults(java.util.Map<K,V> receiver, java.util.function.BiFunction<K,V,T> filter)
Iterates through the map transforming items using the supplied function and collecting any non-null results.
-
groupBy
public static <K,V,T> java.util.Map<T,java.util.Map<K,V>> groupBy(java.util.Map<K,V> receiver, java.util.function.BiFunction<K,V,T> mapper)
Sorts all Map members into groups determined by the supplied mapping function.
-
replaceAll
public static java.lang.String replaceAll(java.lang.CharSequence receiver, java.util.regex.Pattern pattern, java.util.function.Function<java.util.regex.Matcher,java.lang.String> replacementBuilder)
Replace all matches. Similar toMatcher.replaceAll(String)
but allows you to customize the replacement based on the match.
-
replaceFirst
public static java.lang.String replaceFirst(java.lang.CharSequence receiver, java.util.regex.Pattern pattern, java.util.function.Function<java.util.regex.Matcher,java.lang.String> replacementBuilder)
Replace the first match. Similar toMatcher.replaceFirst(String)
but allows you to customize the replacement based on the match.
-
encodeBase64
public static java.lang.String encodeBase64(java.lang.String receiver)
Encode a String in Base64. UseBase64.Encoder.encodeToString(byte[])
if you have to encode bytes rather than a string.
-
decodeBase64
public static java.lang.String decodeBase64(java.lang.String receiver)
Decode some Base64 bytes and build a UTF-8 encoded string. UseBase64.Decoder.decode(String)
if you'd prefer bytes to work with bytes.
-
-