Class CharSequenceConverter<T>

All Implemented Interfaces:
Serializable, Function<CharSequence,T>, ObjectConverter<CharSequence,T>

final class CharSequenceConverter<T> extends SystemConverter<CharSequence,T>
Handles conversions from CharSequence to String, then forward to another converter from String to various objects. Instance of this converter are not registered in ConverterRegistry like other converters because we avoid registering converter expecting interfaces as their source.

The main purpose of this class is to support the conversion of InternationalString.

Immutability and thread safety

This class is immutable, and thus inherently thread-safe, if the converter given to the constructor is also immutable.
Since:
0.3
Version:
0.3
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      For cross-version compatibility.
      See Also:
    • next

      private final ObjectConverter<? super String,? extends T> next
      The converter to apply after this one.
  • Constructor Details

    • CharSequenceConverter

      CharSequenceConverter(Class<T> targetClass, ObjectConverter<? super String,? extends T> next)
      Creates a new converter from CharSequence to the given target type.
      Parameters:
      targetClass - the target class requested by the user.
      next - the converter to apply after this one.
  • Method Details

    • apply

      public T apply(CharSequence source) throws UnconvertibleObjectException
      Converts an object to an object of the target type.
      Parameters:
      source - the object to convert, or null.
      Returns:
      the converted object, or null.
      Throws:
      UnconvertibleObjectException - if the given object is not an element of the function domain.
    • properties

      public Set<FunctionProperty> properties()
      Returns the properties of the converter given at construction time minus FunctionProperty.INJECTIVE, because we don't know how many source CharSequences can produce the same String.
      Returns:
      the manners in which source values are mapped to target values. May be an empty set, but never null.