Class LongEncoding

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

public class LongEncoding extends IntegralEncoding<Long>
Long type.
See Also:
  • Constructor Details

    • LongEncoding

      public LongEncoding(EncodingId encodingId)
  • Method Details

    • withEncodingId

      public LongEncoding 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 Long convertNumber(Number value)
      Specified by:
      convertNumber in class PrimitiveEncoding<Long>
    • downCast

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

      public Long 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<Long>
      Overrides:
      validate in class PrimitiveEncoding<Long>
      Parameters:
      obj - object to validate
      Returns:
      obj cast to this encoding's type