Class StringConvertedEncoding<T>

Type Parameters:
T - The associated Java type
All Implemented Interfaces:
Encoding<T>, NaturalSortAware, Serializable, Comparator<T>
Direct Known Subclasses:
FileEncoding, InternetAddressEncoding, PatternEncoding, URIEncoding, ZoneIdEncoding

public class StringConvertedEncoding<T> extends ConvertedEncoding<T,String>
Encoding for any Java type that can be encoded and ordered as a String. A Guava Converter is used to convert between native and String forms.

This class provides a convenient way to implement custom Encodings. Null values are supported and null is the default value. This type will sort instances according to the lexicographical sort order of their String encodings; null will sort last.

See Also:
  • Constructor Details

    • StringConvertedEncoding

      public StringConvertedEncoding(EncodingId encodingId, TypeToken<T> type, Converter<T,String> converter)
      Primary constructor.
      Parameters:
      encodingId - encoding ID for this encoding, or null to be anonymous
      type - represented Java type
      converter - value converter
      Throws:
      IllegalArgumentException - if any parameter is null
    • StringConvertedEncoding

      public StringConvertedEncoding(EncodingId encodingId, Class<T> type, Converter<T,String> converter)
      Convenience constructor taking Class instead of TypeToken.
      Parameters:
      encodingId - encoding ID for this encoding, or null to be anonymous
      type - represented Java type
      converter - converts between native form and String form; should be Serializable
      Throws:
      IllegalArgumentException - if any parameter is null