public class Functions extends Object
Function
, Predicate
and Comparator
implementations that are useful when working with ResourceOrigin
and Resource
, and some more useful ones that had no better place for now.
They are used to implement LayeredResourceOrigin
, but could be reused for filtering and other purposes.
// TODO consistent naming -- handle or path
Most of this would be completely redundant with Java 8, since all these do is delegate to a given method of the input object: simple method references as lambdas would suffice.Modifier and Type | Class and Description |
---|---|
static class |
Functions.CollectorFunction<T>
A simple Function which aggregates arguments from all its invocations.
|
Constructor and Description |
---|
Functions() |
Modifier and Type | Method and Description |
---|---|
static com.google.common.base.Predicate<Resource> |
always()
Convenient Predicate which simply delegates to
Predicates.alwaysTrue() , avoids verbose type parameter declaration and provides a (debatably) better name. |
static <T> Functions.CollectorFunction<T> |
collector()
This Function simply collects all input into a new collection.
|
static <T> Functions.CollectorFunction<T> |
collector(Collection<T> target)
This Function simply collects all input into the given target collection.
|
static <R extends Resource> |
compareByHandle() |
static com.google.common.base.Function<ResourceOrigin,Resource> |
getByPath(String path) |
static com.google.common.base.Function<Resource,Resource> |
getParent() |
static com.google.common.base.Function<Resource,String> |
getPath() |
static com.google.common.base.Function<ResourceOrigin,Resource> |
getRoot() |
static com.google.common.base.Predicate<ResourceOrigin> |
hasPath(String path) |
static com.google.common.base.Predicate<Resource> |
isDirectory() |
static com.google.common.base.Predicate<Resource> |
isFile() |
static com.google.common.base.Predicate<Resource> |
never()
Convenient Predicate which simply delegates to
Predicates.alwaysFalse() , avoids verbose type parameter declaration, and provides a (debatably) better name. |
static com.google.common.base.Predicate<Resource> |
pathEquals(CharSequence path) |
static com.google.common.base.Predicate<Resource> |
pathMatches(Pattern pattern)
Matches if the input
Resource 's handle matches the given pattern. |
static com.google.common.base.Predicate<Resource> |
pathMatches(com.google.common.base.Predicate<CharSequence> predicate) |
static com.google.common.base.Predicate<Resource> |
pathMatches(String pattern) |
static com.google.common.base.Predicate<Resource> |
pathStartsWith(CharSequence pathPrefix) |
public static com.google.common.base.Predicate<ResourceOrigin> hasPath(String path)
public static com.google.common.base.Predicate<Resource> pathEquals(CharSequence path)
public static com.google.common.base.Predicate<Resource> pathStartsWith(CharSequence pathPrefix)
public static com.google.common.base.Predicate<Resource> pathMatches(String pattern)
pathMatches(Pattern)
,
pathMatches(Predicate)
public static com.google.common.base.Predicate<Resource> pathMatches(Pattern pattern)
Resource
's handle matches the given pattern.
Matches incomplete strings by default, e.g /bar
pattern will match the /foo/bar/qux
resource,
while ^/bar
won't.pathMatches(String)
,
pathMatches(Predicate)
public static com.google.common.base.Predicate<Resource> pathMatches(com.google.common.base.Predicate<CharSequence> predicate)
pathMatches(String)
,
pathMatches(Pattern)
public static com.google.common.base.Predicate<Resource> isDirectory()
public static com.google.common.base.Predicate<Resource> isFile()
public static com.google.common.base.Predicate<Resource> always()
Predicates.alwaysTrue()
, avoids verbose type parameter declaration and provides a (debatably) better name.public static com.google.common.base.Predicate<Resource> never()
Predicates.alwaysFalse()
, avoids verbose type parameter declaration, and provides a (debatably) better name.public static com.google.common.base.Function<ResourceOrigin,Resource> getByPath(String path)
public static com.google.common.base.Function<ResourceOrigin,Resource> getRoot()
public static <T> Functions.CollectorFunction<T> collector(Collection<T> target)
Functions.CollectorFunction.getTarget()
public static <T> Functions.CollectorFunction<T> collector()
Functions.CollectorFunction.getTarget()
public static <R extends Resource> Comparator<R> compareByHandle()
Copyright © 2003–2017 Magnolia International Ltd.. All rights reserved.