Class BaseValue<T extends BaseValue<T>>

java.lang.Object
org.symbol.sdk.BaseValue<T>
Type Parameters:
T - Self-type — the concrete POD extending this class.
All Implemented Interfaces:
Comparable<T>, Serializer
Direct Known Subclasses:
Amount, BlockDuration, BlockFeeMultiplier, Difficulty, FinalizationEpoch, FinalizationPoint, Height, Importance, ImportanceHeight, MosaicId, MosaicNonce, MosaicRestrictionKey, NamespaceId, Timestamp, UnresolvedMosaicId

public abstract class BaseValue<T extends BaseValue<T>> extends Object implements Serializer, Comparable<T>
BaseValue
Fixed-size integer value (amount, height, mosaic id, …) extended by every generated integer POD; F-bounded for a type-safe Comparable. The backing long holds an unsigned u64 >= 2^63 as its negative two's-complement pattern (see value()).
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    BaseValue(long value, int size, boolean isSigned)
    Creates a fixed-size integer value, validating that it fits in size bytes with the given signedness.
  • Method Summary

    Modifier and Type
    Method
    Description
    final int
    compareTo(T other)
     
    final boolean
    equals(Object other)
     
    final int
     
    final boolean
    Returns true if this value should be interpreted as signed.
    final byte[]
    Serializes this object to a fresh byte array.
    final int
    Returns the size, in bytes, of the serialized form of this object.
    final Object
    Returns the JSON-safe representation: a number for values below 8 bytes, a base-10 string for 8-byte values (which can exceed the 2^53 safe-integer range of JSON readers); unsigned 8-byte values render via Long.toUnsignedString(long).
    final String
     
    final long
    Returns the underlying value as a long.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • BaseValue

      protected BaseValue(long value, int size, boolean isSigned)
      Creates a fixed-size integer value, validating that it fits in size bytes with the given signedness.
      Parameters:
      value - Underlying value as a 64-bit two's-complement bit pattern (unsigned u64 values >= 2^63 are stored negative).
      size - Byte width.
      isSigned - true if signed.
  • Method Details

    • value

      public final long value()
      BaseValue.value
      Returns the underlying value as a long. Java long is signed, so unsigned 64-bit values >= 2^63 are returned as negative numbers; interpret them with Long.toUnsignedString(long) and Long.compareUnsigned(long, long).
      Returns:
      Value (64-bit two's-complement bit pattern).
    • isSigned

      public final boolean isSigned()
      BaseValue.isSigned
      Returns true if this value should be interpreted as signed.
      Returns:
      true if signed.
    • size

      public final int size()
      BaseValue.size
      Description copied from interface: Serializer
      Returns the size, in bytes, of the serialized form of this object.
      Specified by:
      size in interface Serializer
      Returns:
      Size in bytes.
    • serialize

      public final byte[] serialize()
      BaseValue.serialize
      Description copied from interface: Serializer
      Serializes this object to a fresh byte array.
      Specified by:
      serialize in interface Serializer
      Returns:
      Serialized bytes.
    • compareTo

      public final int compareTo(T other)
      Specified by:
      compareTo in interface Comparable<T extends BaseValue<T>>
    • toJson

      public final Object toJson()
      BaseValue.toJson
      Returns the JSON-safe representation: a number for values below 8 bytes, a base-10 string for 8-byte values (which can exceed the 2^53 safe-integer range of JSON readers); unsigned 8-byte values render via Long.toUnsignedString(long).
      Returns:
      JSON-safe representation of this value.
    • toString

      public final String toString()
      Overrides:
      toString in class Object
    • equals

      public final boolean equals(Object other)
      Overrides:
      equals in class Object
    • hashCode

      public final int hashCode()
      Overrides:
      hashCode in class Object