Package io.permazen.encoding
Class StringConvertedEncoding<T>
java.lang.Object
io.permazen.encoding.AbstractEncoding<T>
io.permazen.encoding.ConvertedEncoding<T,String>
io.permazen.encoding.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
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:
-
Field Summary
Fields inherited from class io.permazen.encoding.ConvertedEncoding
converter, delegateFields inherited from class io.permazen.encoding.AbstractEncoding
encodingId, typeTokenFields inherited from interface io.permazen.encoding.Encoding
MAX_ARRAY_DIMENSIONS -
Constructor Summary
ConstructorsConstructorDescriptionStringConvertedEncoding(EncodingId encodingId, TypeToken<T> type, Converter<T, String> converter) Primary constructor.StringConvertedEncoding(EncodingId encodingId, Class<T> type, Converter<T, String> converter) -
Method Summary
Methods inherited from class io.permazen.encoding.ConvertedEncoding
compare, equals, fromString, getFixedWidth, hashCode, hasPrefix0x00, hasPrefix0xff, read, skip, sortsNaturally, supportsNull, toString, validate, writeMethods inherited from class io.permazen.encoding.AbstractEncoding
getDefaultValue, getDefaultValueBytes, getEncodingId, getTypeToken, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Comparator
reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLongMethods inherited from interface io.permazen.encoding.Encoding
convert, decode, encode, validateAndWrite
-
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 anonymoustype- represented Java typeconverter- value converter- Throws:
IllegalArgumentException- if any parameter is null
-
StringConvertedEncoding
- Parameters:
encodingId- encoding ID for this encoding, or null to be anonymoustype- represented Java typeconverter- converts between native form andStringform; should beSerializable- Throws:
IllegalArgumentException- if any parameter is null
-