public final class Transformers
extends java.lang.Object
Transformer objects.| Modifier and Type | Method and Description |
|---|---|
static Transformer |
compose(Transformer... transformers)
Return a
CompositeTransformer that invokes each of the
transformers in order. |
static Transformer |
composeForEach(Transformer... transformers)
Return a
CompositeTransformer that wrapers each of the
transformers in a forEach(Transformer) transformer} and
invokes each of them in order |
static Transformer |
explode()
|
static Transformer |
forEach(Transformer transformer)
Return a
Transformer that will apply the provided
transformer to every item in a value that is a
sequence or to the value itself if
the value is not a sequence. |
static Transformer |
keyCaseFormat(com.google.common.base.CaseFormat from,
com.google.common.base.CaseFormat to)
Deprecated.
use
keyEnsureCaseFormat(CaseFormat) or
keyConditionalConvertCaseFormat(CaseFormat, CaseFormat)
instead depending on the desired transformation |
static Transformer |
keyConditionalConvertCaseFormat(com.google.common.base.CaseFormat undesired,
com.google.common.base.CaseFormat desired)
Return a
Transformer that converts a key to a CaseFormat
if and only if the key currently matches another undesired
format. |
static Transformer |
keyEnsureCaseFormat(com.google.common.base.CaseFormat format)
Return a
Transformer that ensures a key is in the specified case
format |
static Transformer |
keyMap(java.util.Map<java.lang.String,java.lang.String> map)
Transform keys to other keys using the provided
mapping. |
static Transformer |
keyRemoveInvalidChars(java.util.Collection<java.lang.Character> invalid)
Return a
Transformer that removes all the character in the
invalid collection. |
static Transformer |
keyRemoveInvalidChars(java.util.function.Predicate<java.lang.Character> invalid)
|
static Transformer |
keyRemoveWhitespace()
Return a
Transformer that removes all whitespace characters from
a key. |
static Transformer |
keyReplaceChars(java.util.Map<java.lang.Character,java.lang.Character> replacements)
Return a
Transformer that replaces all the character keys in the
replacements mapping with their associated character values in
each data key. |
static Transformer |
keyStripInvalidChars(com.cinchapi.common.base.validate.Check<java.lang.Character> validator)
Deprecated.
use
keyRemoveInvalidChars(Predicate) which takes a
Predicate that tests whether a character is
invalid. Please note that said functionality
is the inverse of this method, which takes a Check
that tests whether a character is valid. |
static Transformer |
keyToLowerCase()
Return a
Transformer that converts all the characters in a key to
lowercase. |
static Transformer |
keyValueRemoveQuotes()
Return a
Transformer that will remove single and double quotes
from the beginning and end of both the key and value. |
static Transformer |
keyValueStripQuotes()
Deprecated.
use
keyValueRemoveQuotes() which has the exact same
functionality |
static Transformer |
keyWhitespaceToUnderscore()
Return a
Transformer that replaces whitespace characters with an
underscore in keys. |
static Transformer |
noOp()
Return a
Transformer that does not perform any key or value
transformations. |
static Transformer |
nullSafe(Transformer transformer)
Return a
Transformer that only attempts transformation if the
value is not null. |
static Transformer |
removeValuesThatAre(com.cinchapi.common.describe.Adjective adjective)
Deprecated.
use
instead |
static Transformer |
valueAsBoolean()
Return a
Transformer that, For EVERY key, transform values to a
Boolean if possible. |
static Transformer |
valueAsBoolean(java.lang.String... keys)
|
static Transformer |
valueAsNumber()
Return a
Transformer that, For EVERY key, transform values to a
Number if possible. |
static Transformer |
valueAsNumber(java.lang.String... keys)
|
static Transformer |
valueAsResolvableLinkInstruction()
Return a
Transformer that, For EVERY key, transform values to a
resolvable link
instruction if possible. |
static Transformer |
valueAsResolvableLinkInstruction(java.lang.String... keys)
Return a
Transformer that, for each of the keys,
transform values to a
resolvable link
instruction if possible. |
static Transformer |
valueAsTag()
Return a
Transformer that, For EVERY key, transform values to a
Number if possible. |
static Transformer |
valueAsTag(java.lang.String... keys)
|
static Transformer |
valueAsTimestamp()
Return a
Transformer that, For EVERY key, transform values to a
Timestamp if possible. |
static Transformer |
valueAsTimestamp(java.lang.String... keys)
|
static Transformer |
valueNullifyIfEmpty()
|
static Transformer |
valueNullifyIfEmpty(com.cinchapi.common.describe.Empty empty)
|
static Transformer |
valueRemoveIf(com.cinchapi.common.describe.Adjective adjective)
Return a
Transformer that will cause a key/value pair to be
"removed" if the value is described by the provided adjective. |
static Transformer |
valueRemoveIfEmpty() |
static Transformer |
valueSplitOnDelimiter(char delimiter,
com.cinchapi.concourse.util.SplitOption... options)
Deprecated.
|
static Transformer |
valueStringSplitOnDelimiter(char delimiter,
com.cinchapi.concourse.util.SplitOption... options)
Return a
Transformer that splits a String value into multiple
strings that are all mapped from the original key. |
static Transformer |
valueStringToJava()
Return a
Transformer that uses the
Convert.stringToJava(String) method to convert String values to
the preferred java type. |
public static Transformer compose(Transformer... transformers)
CompositeTransformer that invokes each of the
transformers in order.transformers - the transformers to invokeCompositeTransformerpublic static Transformer composeForEach(Transformer... transformers)
CompositeTransformer that wrapers each of the
transformers in a forEach(Transformer) transformer} and
invokes each of them in ordertransformers - CompositeTransformerpublic static Transformer explode()
Transformerpublic static Transformer forEach(Transformer transformer)
Transformer that will apply the provided
transformer to every item in a value that is a
sequence or to the value itself if
the value is not a sequence.
NOTE: You should always wrap subsequent transformers
within this this one when it is likely that the input values will be
collections instead of "flat" objects. For instance, if you have a
composite transformation chain and one
of the transformers in the sequence is
valueSplitOnDelimiter(char, SplitOption...), you should wrap all
the following transformers using this method to ensure that the logic is
applied to each item.
transformer - the Transformer to apply to every elementTransformer@Deprecated public static Transformer keyCaseFormat(com.google.common.base.CaseFormat from, com.google.common.base.CaseFormat to)
keyEnsureCaseFormat(CaseFormat) or
keyConditionalConvertCaseFormat(CaseFormat, CaseFormat)
instead depending on the desired transformationfrom - the original CaseFormatto - the desired CaseFormatTransformerpublic static Transformer keyConditionalConvertCaseFormat(com.google.common.base.CaseFormat undesired, com.google.common.base.CaseFormat desired)
Transformer that converts a key to a CaseFormat
if and only if the key currently matches another undesired
format.
This transformer should be use when there is only one case format that is
undesirable (e.g. it is fine if a key takes on any other case format). If
you want to ensure that a key matches a particular case format, use
keyEnsureCaseFormat(CaseFormat).
undesired - desired - Transformerpublic static Transformer keyEnsureCaseFormat(com.google.common.base.CaseFormat format)
Transformer that ensures a key is in the specified case
formatformat - Transformerpublic static Transformer keyMap(java.util.Map<java.lang.String,java.lang.String> map)
mapping.map - Transformerpublic static Transformer keyWhitespaceToUnderscore()
Transformer that replaces whitespace characters with an
underscore in keys.Transformerpublic static Transformer keyRemoveWhitespace()
Transformer that removes all whitespace characters from
a key.Transformerpublic static Transformer keyRemoveInvalidChars(java.util.Collection<java.lang.Character> invalid)
Transformer that removes all the character in the
invalid collection.invalid - Transformerpublic static Transformer keyRemoveInvalidChars(java.util.function.Predicate<java.lang.Character> invalid)
invalid - Transformerpublic static Transformer keyReplaceChars(java.util.Map<java.lang.Character,java.lang.Character> replacements)
Transformer that replaces all the character keys in the
replacements mapping with their associated character values in
each data key.replacements - a mapping from characters to another character with
which it should be replacedTransformer@Deprecated public static Transformer keyStripInvalidChars(com.cinchapi.common.base.validate.Check<java.lang.Character> validator)
keyRemoveInvalidChars(Predicate) which takes a
Predicate that tests whether a character is
invalid. Please note that said functionality
is the inverse of this method, which takes a Check
that tests whether a character is valid.Transformer that strips invalid characters from the key.
Some of those characters are replaced with valid stand-ins.Transformerpublic static Transformer keyToLowerCase()
Transformer that converts all the characters in a key to
lowercase. No other modifications to the key are made.Transformerpublic static Transformer keyValueRemoveQuotes()
Transformer that will remove single and double quotes
from the beginning and end of both the key and value.@Deprecated public static Transformer keyValueStripQuotes()
keyValueRemoveQuotes() which has the exact same
functionalityTransformer that will strip single and double quotes
from the beginning and end of both the key and value.public static Transformer noOp()
Transformer that does not perform any key or value
transformations.Transformerpublic static Transformer nullSafe(Transformer transformer)
Transformer that only attempts transformation if the
value is not null.transformer - Transformerpublic static Transformer valueRemoveIfEmpty()
@Deprecated public static Transformer removeValuesThatAre(com.cinchapi.common.describe.Adjective adjective)
insteadTransformer that will cause a key/value pair to be
"removed" if the value is described by the provided adjective.
Removal is accomplished by returning an empty map for the transformation.
adjective - Transformerpublic static Transformer valueRemoveIf(com.cinchapi.common.describe.Adjective adjective)
Transformer that will cause a key/value pair to be
"removed" if the value is described by the provided adjective.
Removal is accomplished by returning an empty map for the transformation.
adjective - Transformerpublic static Transformer valueAsBoolean()
Transformer that, For EVERY key, transform values to a
Boolean if possible. If the value cannot be transformed, an
exception is thrown.Transformerpublic static Transformer valueAsBoolean(java.lang.String... keys)
Transformer that, for each of the keys,
transform values to a Boolean if possible. If the value cannot
be transformed, an exception is thrown. If keys is an empty
array, this transformation is applied to EVERY key (a la
valueAsBoolean().key - the keys for which the transformer is appliedTransformerpublic static Transformer valueAsNumber()
Transformer that, For EVERY key, transform values to a
Number if possible. If the value cannot be transformed, an
exception is thrown.Transformerpublic static Transformer valueAsNumber(java.lang.String... keys)
Transformer that, for each of the keys,
transform values to a Number if possible. If the value cannot
be transformed, an exception is thrown. If keys is an empty
array, this transformation is applied to EVERY key (a la
valueAsNumber().key - the keys for which the transformer is appliedTransformerpublic static Transformer valueAsResolvableLinkInstruction()
Transformer that, For EVERY key, transform values to a
resolvable link
instruction if possible. If the value cannot be transformed, an
exception is thrown.Transformerpublic static Transformer valueAsResolvableLinkInstruction(java.lang.String... keys)
Transformer that, for each of the keys,
transform values to a
resolvable link
instruction if possible. If the value cannot be transformed, an
exception is thrown. If keys is an empty array, this
transformation is applied to EVERY key (a la
valueAsResolvableLinkInstruction().key - the keys for which the transformer is appliedTransformerpublic static Transformer valueAsTag()
Transformer that, For EVERY key, transform values to a
Number if possible. If the value cannot be transformed, an
exception is thrown.Transformerpublic static Transformer valueAsTag(java.lang.String... keys)
Transformer that, for each of the keys,
transform values to a Tag if possible. If the value cannot
be transformed, an exception is thrown. If keys is an empty
array, this transformation is applied to EVERY key (a la
valueAsTag().key - the keys for which the transformer is appliedTransformerpublic static Transformer valueAsTimestamp()
Transformer that, For EVERY key, transform values to a
Timestamp if possible. If the value cannot be transformed, an
exception is thrown.Transformerpublic static Transformer valueAsTimestamp(java.lang.String... keys)
Transformer that, for each of the keys,
transform values to a Timestamp if possible. If the value cannot
be transformed, an exception is thrown. If keys is an empty
array, this transformation is applied to EVERY key (a la
valueAsTimestamp().key - the keys for which the transformer is appliedTransformerpublic static Transformer valueNullifyIfEmpty()
Transformerpublic static Transformer valueNullifyIfEmpty(com.cinchapi.common.describe.Empty empty)
empty - Transformer@Deprecated public static Transformer valueSplitOnDelimiter(char delimiter, com.cinchapi.concourse.util.SplitOption... options)
valueStringSplitOnDelimiter(char, SplitOption...)
insteadTransformer that splits a String value into multiple
strings that are all mapped from the original key.delimiter - the character on which to split the Stringoptions - the optional SplitOptionsTransformerpublic static Transformer valueStringSplitOnDelimiter(char delimiter, com.cinchapi.concourse.util.SplitOption... options)
Transformer that splits a String value into multiple
strings that are all mapped from the original key.delimiter - the character on which to split the Stringoptions - the optional SplitOptionsTransformerpublic static Transformer valueStringToJava()
Transformer that uses the
Convert.stringToJava(String) method to convert String values to
the preferred java type. If the value is not a String, this transformer
has no effect.Transformer