Class ShortEncoding

All Implemented Interfaces:
Encoding<Short>, NaturalSortAware, Serializable, Comparator<Short>

public class ShortEncoding extends IntegralEncoding<Short>
Short type.
See Also:
  • Constructor Details

    • ShortEncoding

      public ShortEncoding(EncodingId encodingId)
  • Method Details

    • withEncodingId

      public ShortEncoding withEncodingId(EncodingId encodingId)
      Description copied from interface: Encoding
      Build an encoding that has the given EncodingId but is otherwise equivalent to this encoding.

      If this encoding already has encodingId, then this method may (but is not required to) return this same instance.

      Parameters:
      encodingId - new encoding's EncodingId, or null for an anonymized encoding
      Returns:
      a version of this encoding with the given EncodingId
    • convertNumber

      protected Short convertNumber(Number value)
      Specified by:
      convertNumber in class PrimitiveEncoding<Short>
    • downCast

      protected Short downCast(long value)
      Specified by:
      downCast in class IntegralEncoding<Short>
    • validate

      public Short validate(Object obj)
      Description copied from interface: Encoding
      Verify the given object is a valid instance of this Encoding's Java type and cast it to that type.

      Note that this method must throw IllegalArgumentException, not ClassCastException or NullPointerException, if obj does not have the correct type, or is an unsupported value - including null if null is not supported.

      This method is allowed to perform widening conversions of the object that lose no information, e.g., from Integer to Long.

      The implementation in Encoding first verifies the value is not null if this instance does not allow null values, and then attempts to cast the value using this instance's raw Java type. Subclasses should override this method to implement any other restrictions.

      Specified by:
      validate in interface Encoding<Short>
      Overrides:
      validate in class PrimitiveEncoding<Short>
      Parameters:
      obj - object to validate
      Returns:
      obj cast to this encoding's type