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 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).
      • 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 - When function is null.
      • 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 - When map is null.
      • 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.