Package cdc.util.data.util
Interface AttributeValueConverter
-
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface AttributeValueConverter
Interface used to convert (replace) an attribute value.- Author:
- Damien Carbonne
-
-
Field Summary
Fields Modifier and Type Field Description static AttributeValueConverterINDENTITYAn attribute value converter that returns the value unchanged.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default AttributeValueConverterandThen(AttributeValueConverter other)Returns a converter that first applies this converter and thenother.default AttributeValueConvertercompose(AttributeValueConverter other)Returns a converter that first appliesotherthen this converter.StringconvertAttributeValue(Element element, String name, String value)Returns the value that should be used instead of the original value.static AttributeValueConverterfromNameMap(Map<String,String> map)Creates a new AttributeValueConverter from an attribute name to value map.static AttributeValueConverterfromPathMap(Map<SPath,String> map)static AttributeValueConverterfromString(String s)static AttributeValueConverterfromValueFunction(UnaryOperator<String> function)Creates a new AttributeValueConverter from a value converter function.static AttributeValueConverterfromValueMap(Map<String,String> map)Creates a new AttributeValueConverter from an attribute value map.static AttributeValueConverterscramble(boolean preserveSpaces)
-
-
-
Field Detail
-
INDENTITY
static final AttributeValueConverter INDENTITY
An attribute value converter that returns the value unchanged.
-
-
Method Detail
-
convertAttributeValue
String convertAttributeValue(Element element, String name, String value)
Returns the value that should be used instead of the original value.- Parameters:
element- The element containing the attribute.name- The attribute name.value- The attribute value.- Returns:
- The value to use for the attribute (instead of value).
-
compose
default AttributeValueConverter compose(AttributeValueConverter other)
Returns a converter that first appliesotherthen this converter.- Parameters:
other- The other converter.- Returns:
- A converter that first applies
otherthen this converter. - Throws:
IllegalArgumentException- Whenotherisnull.
-
andThen
default AttributeValueConverter andThen(AttributeValueConverter other)
Returns a converter that first applies this converter and thenother.- Parameters:
other- The other converter.- Returns:
- A converter that first applies this converter and then
other. - Throws:
IllegalArgumentException- Whenotherisnull.
-
fromString
static AttributeValueConverter fromString(String s)
-
scramble
static AttributeValueConverter scramble(boolean preserveSpaces)
-
fromValueFunction
static AttributeValueConverter fromValueFunction(UnaryOperator<String> function)
Creates a new AttributeValueConverter from a value converter function.Conversion is independent of element and attribute name.
- Parameters:
function- The function used to convert values.- Returns:
- A new AttributeValueConverter from
function. - Throws:
IllegalArgumentException- Whenfunctionisnull.
-
fromValueMap
static AttributeValueConverter fromValueMap(Map<String,String> map)
Creates a new AttributeValueConverter from an attribute value map.Conversion is independent of element and attribute name.
If a value is not mapped, then result is that value.- Parameters:
map- The map.- Returns:
- A new AttributeValueConverter from
map. - Throws:
IllegalArgumentException- Whenmapisnull.
-
fromNameMap
static AttributeValueConverter fromNameMap(Map<String,String> map)
Creates a new AttributeValueConverter from an attribute name to value map.If a name is not mapped, then result is original value.
- Parameters:
map- The map.- Returns:
- A new AttributeValueConverter from
map.
-
fromPathMap
static AttributeValueConverter fromPathMap(Map<SPath,String> map)
-
-