Package io.permazen.encoding
Class AbstractEncoding<T>
java.lang.Object
io.permazen.encoding.AbstractEncoding<T>
- Type Parameters:
T
- The associated Java type
- All Implemented Interfaces:
Encoding<T>
,NaturalSortAware
,Serializable
,Comparator<T>
- Direct Known Subclasses:
ArrayEncoding
,BigDecimalEncoding
,BigIntegerEncoding
,BitSetEncoding
,ConvertedEncoding
,DateEncoding
,DurationEncoding
,Inet4AddressEncoding
,Inet6AddressEncoding
,InetAddressEncoding
,InstantEncoding
,LocalDateEncoding
,LocalDateTimeEncoding
,LocalTimeEncoding
,MonthDayEncoding
,NullSafeEncoding
,ObjIdEncoding
,OffsetDateTimeEncoding
,OffsetTimeEncoding
,PeriodEncoding
,PrimitiveEncoding
,StringEncoding
,TupleEncoding
,UnsignedIntEncoding
,UUIDEncoding
,YearEncoding
,YearMonthEncoding
,ZonedDateTimeEncoding
,ZoneOffsetEncoding
Support superclass for
Encoding
implementations.
Instances are Serializable
if their default values are (typically the default value is null, making this the case).
- See Also:
-
Field Summary
Fields inherited from interface io.permazen.encoding.Encoding
MAX_ARRAY_DIMENSIONS
-
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractEncoding
(EncodingId encodingId, TypeToken<T> typeToken, T defaultValue) Constructor.protected
AbstractEncoding
(EncodingId encodingId, Class<T> type, T defaultValue) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionboolean
final T
Get the default value for this encoding.final EncodingId
Get the globally unique encoding ID that identifies this encoding, if any.Get the Java type corresponding to this encoding's values.int
hashCode()
toString()
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Comparator
reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
Methods inherited from interface io.permazen.encoding.Encoding
compare, convert, decode, encode, fromString, getDefaultValue, getKeyRange, hasPrefix0x00, hasPrefix0xff, read, skip, sortsNaturally, supportsNull, toString, validate, validateAndWrite, withEncodingId, write
-
Field Details
-
encodingId
-
typeToken
-
-
Constructor Details
-
AbstractEncoding
Constructor.- Parameters:
encodingId
- encoding ID for this encoding, or null to be anonymoustypeToken
- Java type for the field's valuesdefaultValue
- default value for this encoding- Throws:
IllegalArgumentException
- if any parameter is nullIllegalArgumentException
- ifname
is invalid
-
AbstractEncoding
Constructor.- Parameters:
encodingId
- encoding ID for this encoding, or null to be anonymoustype
- Java type for the field's valuesdefaultValue
- default value for this encoding- Throws:
IllegalArgumentException
- if any parameter is nullIllegalArgumentException
- ifname
is invalid
-
-
Method Details
-
getEncodingId
Description copied from interface:Encoding
Get the globally unique encoding ID that identifies this encoding, if any.Once associated with a specific encoding, an encoding ID must never be changed or reused. If an
Encoding
's encoding changes in any way, then its encoding ID must also change. This applies only to the encoding itself, and not the associated Java type. For example, anEncoding
's associated Java type can change over time, e.g., if the Java class changes package or class name.- Specified by:
getEncodingId
in interfaceEncoding<T>
- Returns:
- this encoding's unique ID, or null if this encoding is anonymous
-
getTypeToken
Description copied from interface:Encoding
Get the Java type corresponding to this encoding's values.- Specified by:
getTypeToken
in interfaceEncoding<T>
- Returns:
- the Java type used to represent this encoding's values
-
getDefaultValueObject
Description copied from interface:Encoding
Get the default value for this encoding.If this encoding supports null values, then this must return null.
- Specified by:
getDefaultValueObject
in interfaceEncoding<T>
- Returns:
- default value
-
toString
-
hashCode
public int hashCode() -
equals
- Specified by:
equals
in interfaceComparator<T>
- Overrides:
equals
in classObject
-