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 Predicate<Resource> |
always()
Deprecated.
since 6.1 use concise lambdas with better parameter 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()
Deprecated.
since 6.1 use static
Comparator.comparing(Function) with Resource.getPath() method reference |
static Function<ResourceOrigin,Resource> |
getByPath(String path)
Deprecated.
since 6.1 use
ResourceOrigin.getByPath(String) and lambdas |
static Function<Resource,Resource> |
getParent()
Deprecated.
since 6.1 use
Resource.getParent() method reference |
static Function<Resource,String> |
getPath()
Deprecated.
since 6.1 use
Resource.getPath() method reference |
static Function<ResourceOrigin,Resource> |
getRoot()
Deprecated.
since 6.1 use
ResourceOrigin.getRoot() method reference |
static Predicate<ResourceOrigin> |
hasPath(String path)
Deprecated.
since 6.1 use
ResourceOrigin.hasPath(java.lang.String) and lambdas |
static Predicate<Resource> |
isDirectory()
Deprecated.
since 6.1 use
Resource.isDirectory() method reference |
static Predicate<Resource> |
isFile()
Deprecated.
since 6.1 use
Resource.isFile() method reference |
static Predicate<Resource> |
never()
Deprecated.
since 6.1 use concise lambdas with better parameter name
|
static Predicate<Resource> |
pathEquals(CharSequence path) |
static Predicate<Resource> |
pathMatches(Pattern pattern)
Matches if the input
Resource 's handle matches the given pattern. |
static Predicate<Resource> |
pathMatches(Predicate<CharSequence> predicate) |
static Predicate<Resource> |
pathMatches(String pattern) |
static Predicate<Resource> |
pathStartsWith(CharSequence pathPrefix) |
@Deprecated public static Predicate<ResourceOrigin> hasPath(String path)
ResourceOrigin.hasPath(java.lang.String)
and lambdaspublic static Predicate<Resource> pathEquals(CharSequence path)
public static Predicate<Resource> pathStartsWith(CharSequence pathPrefix)
public static Predicate<Resource> pathMatches(String pattern)
pathMatches(Pattern)
,
pathMatches(Predicate)
public static 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 Predicate<Resource> pathMatches(Predicate<CharSequence> predicate)
pathMatches(String)
,
pathMatches(Pattern)
@Deprecated public static Predicate<Resource> isDirectory()
Resource.isDirectory()
method reference@Deprecated public static Predicate<Resource> isFile()
Resource.isFile()
method reference@Deprecated public static Predicate<Resource> always()
@Deprecated public static Predicate<Resource> never()
@Deprecated public static Function<ResourceOrigin,Resource> getByPath(String path)
ResourceOrigin.getByPath(String)
and lambdas@Deprecated public static Function<ResourceOrigin,Resource> getRoot()
ResourceOrigin.getRoot()
method reference@Deprecated public static Function<Resource,String> getPath()
Resource.getPath()
method reference@Deprecated public static Function<Resource,Resource> getParent()
Resource.getParent()
method referencepublic static <T> Functions.CollectorFunction<T> collector(Collection<T> target)
Functions.CollectorFunction.getTarget()
public static <T> Functions.CollectorFunction<T> collector()
Functions.CollectorFunction.getTarget()
@Deprecated public static <R extends Resource> Comparator<R> compareByHandle()
Comparator.comparing(Function)
with Resource.getPath()
method referenceCopyright © 2003–2020 Magnolia International Ltd.. All rights reserved.