Class FloatEncoding

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

public class FloatEncoding extends NumberEncoding<Float>
Float type.
See Also:
  • Constructor Details

    • FloatEncoding

      public FloatEncoding(EncodingId encodingId)
  • Method Details

    • withEncodingId

      public FloatEncoding 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
    • read

      public Float read(ByteReader reader)
      Description copied from interface: Encoding
      Read a value from the given input.
      Parameters:
      reader - byte input
      Returns:
      field value (possibly null)
    • write

      public void write(ByteWriter writer, Float value)
      Description copied from interface: Encoding
      Write a value to the given output.
      Parameters:
      writer - byte output
      value - value to write (possibly null)
    • skip

      public void skip(ByteReader reader)
      Description copied from interface: Encoding
      Read and discard a byte[] encoded value from the given input.
      Parameters:
      reader - byte input
    • validate

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

      protected Float convertNumber(Number value)
      Specified by:
      convertNumber in class PrimitiveEncoding<Float>