CONTAINER - the type of containerpublic static interface ValueFormatters.Extractor<CONTAINER>
extends java.util.function.Predicate<java.lang.Object>, java.util.function.BiFunction<java.lang.Object,java.util.function.Function<java.lang.Object,java.lang.String>,java.lang.String>
BiFunction aiming at producing a customized String
representation of a container type and its contained elements, each element being
potentially itself converted to String using a ValueFormatters.ToStringConverter:
getTargetClass()matches(Object)String.valueOf(Object)
on non-matching containersValueFormatters.ToStringConverter to the content, passed as the second
parameter of the BiFunctionString representation of the container by
exploding it and then joining
it with {#code ", "} delimiter, as well as custom prefix(Object) and suffix(Object)| Modifier and Type | Method and Description |
|---|---|
default java.lang.String |
apply(java.lang.Object target,
java.util.function.Function<java.lang.Object,java.lang.String> contentFormatter)
Given an arbitrary object and a
ValueFormatters.ToStringConverter, if the object passes
the test(Object), extract elements from it and convert them using the
ValueFormatters.ToStringConverter, joining the result together to obtain a customized
String representation of both the container and its contents. |
java.util.stream.Stream<java.lang.Object> |
explode(CONTAINER original)
Explode the container into a
Stream of Object, each of which
is a candidate for individual String conversion by a ValueFormatters.ToStringConverter
when applied as a BiFunction. |
java.lang.Class<CONTAINER> |
getTargetClass()
Return the targeted container
Class. |
default boolean |
matches(CONTAINER value)
An additional test to perform on a matching container to further decide to convert
it or not.
|
default java.lang.String |
prefix(CONTAINER original)
Return the prefix to use in the container's
String representation, given
the original container. |
default java.lang.String |
suffix(CONTAINER original)
Return the suffix to use in the container's
String representation, given
the original container. |
default boolean |
test(java.lang.Object o)
Test if an object is a container that can be extracted and converted by this
ValueFormatters.Extractor. |
java.lang.Class<CONTAINER> getTargetClass()
Class. The BiFunction shouldn't be
applied to objects that are not of that class, although it will default to using
String.valueOf(Object) on them. This verification is included in test(Object).Classdefault boolean matches(CONTAINER value)
BiFunction shouldn't be applied to container that do not
match that predicate, although it will default to using String.valueOf(Object)
on them. This verification is included in test(Object).
Defaults to always matching instances of the target Class.
value - the candidate containerdefault java.lang.String prefix(CONTAINER original)
String representation, given
the original container.
Defaults to "[".
original - the original containerdefault java.lang.String suffix(CONTAINER original)
String representation, given
the original container.
Defaults to "]".
original - the original containerjava.util.stream.Stream<java.lang.Object> explode(CONTAINER original)
Stream of Object, each of which
is a candidate for individual String conversion by a ValueFormatters.ToStringConverter
when applied as a BiFunction.original - the container to extract contents fromStream of elements contained in the containerdefault boolean test(java.lang.Object o)
ValueFormatters.Extractor. Defaults to testing getTargetClass() and matches(Object).
The BiFunction shouldn't be applied to objects that do not match this
test, although it will default to using String.valueOf(Object) on them.test in interface java.util.function.Predicate<java.lang.Object>o - the arbitrary object to test.String@Nullable default java.lang.String apply(java.lang.Object target, java.util.function.Function<java.lang.Object,java.lang.String> contentFormatter)
ValueFormatters.ToStringConverter, if the object passes
the test(Object), extract elements from it and convert them using the
ValueFormatters.ToStringConverter, joining the result together to obtain a customized
String representation of both the container and its contents.
Any object that doesn't match this ValueFormatters.Extractor is naively transformed
using String.valueOf(Object), use test(Object) to avoid that
when choosing between multiple ValueFormatters.Extractor.apply in interface java.util.function.BiFunction<java.lang.Object,java.util.function.Function<java.lang.Object,java.lang.String>,java.lang.String>target - the arbitrary object to potentially convert.contentFormatter - the ValueFormatters.ToStringConverter to apply on each element
contained in the targetString representation of the target, customized as needed