Class ImmutableLedgerHeader

java.lang.Object
org.xrpl.xrpl4j.model.ledger.ImmutableLedgerHeader
All Implemented Interfaces:
LedgerHeader

@ParametersAreNonnullByDefault @Generated("org.immutables.processor.ProxyProcessor") @Immutable @CheckReturnValue public final class ImmutableLedgerHeader extends Object implements LedgerHeader
Immutable implementation of LedgerHeader.

Use the builder to create immutable instances: ImmutableLedgerHeader.builder().

  • Method Details

    • ledgerIndex

      public LedgerIndex ledgerIndex()
      The ledger index of the ledger. In other objects, this would be a LedgerIndex, however the ledger method returns the ledger_index as a String representing an unsigned 32 bit integer.
      Specified by:
      ledgerIndex in interface LedgerHeader
      Returns:
      A String containing the ledger index.
    • ledgerHash

      public Optional<Hash256> ledgerHash()
      The SHA-512Half of this ledger version. This serves as a unique identifier for this ledger and all its contents.
      Specified by:
      ledgerHash in interface LedgerHeader
      Returns:
      An Optional of type Hash256 containing the hash of the ledger.
    • accountHash

      public Optional<Hash256> accountHash()
      The SHA-512Half of this ledger's state tree information.
      Specified by:
      accountHash in interface LedgerHeader
      Returns:
      An Optional of type Hash256 containing the hash of this ledger's state tree.
    • closeTime

      public Optional<com.google.common.primitives.UnsignedLong> closeTime()
      The approximate time this ledger version closed, as the number of seconds since the Ripple Epoch. This value is rounded based on the closeTimeResolution()}.
      Specified by:
      closeTime in interface LedgerHeader
      Returns:
      An Optional of type UnsignedLong representing the close time.
    • closeTimeHuman

      public Optional<ZonedDateTime> closeTimeHuman()
      The time this ledger was closed, in human-readable format. Always uses the UTC time zone.
      Specified by:
      closeTimeHuman in interface LedgerHeader
      Returns:
      A ZonedDateTime representing the closeTime() in human-readable format.
    • closed

      public boolean closed()
      If true, this ledger version is no longer accepting new transactions. (However, unless this ledger version is validated, it might be replaced by a different ledger version with a different set of transactions.)
      Specified by:
      closed in interface LedgerHeader
      Returns:
      true if this ledger version is no longer accepting new transactions, otherwise false.
    • parentHash

      public Hash256 parentHash()
      The ledgerHash() value of the previous ledger version that is the direct predecessor of this one. If there are different versions of the previous ledger index, this indicates from which one the ledger was derived.
      Specified by:
      parentHash in interface LedgerHeader
      Returns:
      A Hash256 containing the hash of this ledger's parent ledger.
    • parentCloseTime

      public Optional<com.google.common.primitives.UnsignedLong> parentCloseTime()
      The time at which the previous ledger was closed.
      Specified by:
      parentCloseTime in interface LedgerHeader
      Returns:
      An UnsignedLong denoting this ledger's parent ledger's close time.
    • totalCoins

      public Optional<XrpCurrencyAmount> totalCoins()
      The total number of drops of XRP owned by accounts in the ledger. This omits XRP that has been destroyed by transaction fees. The actual amount of XRP in circulation is lower because some accounts are "black holes" whose keys are not known by anyone.
      Specified by:
      totalCoins in interface LedgerHeader
      Returns:
      An Optional of type XrpCurrencyAmount representing the total number of coins.
    • transactionHash

      public Optional<Hash256> transactionHash()
      The SHA-512Half of the transactions included in this ledger.
      Specified by:
      transactionHash in interface LedgerHeader
      Returns:
      A Hash256 containing the hash of all transactions in this ledger.
    • transactions

      public com.google.common.collect.ImmutableList<TransactionResult<? extends Transaction>> transactions()
      Transactions applied in this ledger version.
      Specified by:
      transactions in interface LedgerHeader
      Returns:
      A List of TransactionResults containing all the transactions in this ledger.
    • closeTimeResolution

      public Optional<com.google.common.primitives.UnsignedInteger> closeTimeResolution()
      An UnsignedInteger in the range [2,120] indicating the maximum number of seconds by which the closeTime() could be rounded.
      Specified by:
      closeTimeResolution in interface LedgerHeader
      Returns:
      An Optional of type UnsignedInteger representing the close time resolution.
    • withLedgerIndex

      public final ImmutableLedgerHeader withLedgerIndex(LedgerIndex value)
      Copy the current immutable object by setting a value for the ledgerIndex attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for ledgerIndex
      Returns:
      A modified copy of the this object
    • withLedgerHash

      public final ImmutableLedgerHeader withLedgerHash(Hash256 value)
      Copy the current immutable object by setting a present value for the optional ledgerHash attribute.
      Parameters:
      value - The value for ledgerHash
      Returns:
      A modified copy of this object
    • withLedgerHash

      public final ImmutableLedgerHeader withLedgerHash(Optional<? extends Hash256> optional)
      Copy the current immutable object by setting an optional value for the ledgerHash attribute. A shallow reference equality check is used on unboxed optional value to prevent copying of the same value by returning this.
      Parameters:
      optional - A value for ledgerHash
      Returns:
      A modified copy of this object
    • withAccountHash

      public final ImmutableLedgerHeader withAccountHash(Hash256 value)
      Copy the current immutable object by setting a present value for the optional accountHash attribute.
      Parameters:
      value - The value for accountHash
      Returns:
      A modified copy of this object
    • withAccountHash

      public final ImmutableLedgerHeader withAccountHash(Optional<? extends Hash256> optional)
      Copy the current immutable object by setting an optional value for the accountHash attribute. A shallow reference equality check is used on unboxed optional value to prevent copying of the same value by returning this.
      Parameters:
      optional - A value for accountHash
      Returns:
      A modified copy of this object
    • withCloseTime

      public final ImmutableLedgerHeader withCloseTime(com.google.common.primitives.UnsignedLong value)
      Copy the current immutable object by setting a present value for the optional closeTime attribute.
      Parameters:
      value - The value for closeTime
      Returns:
      A modified copy of this object
    • withCloseTime

      public final ImmutableLedgerHeader withCloseTime(Optional<? extends com.google.common.primitives.UnsignedLong> optional)
      Copy the current immutable object by setting an optional value for the closeTime attribute. An equality check is used on inner nullable value to prevent copying of the same value by returning this.
      Parameters:
      optional - A value for closeTime
      Returns:
      A modified copy of this object
    • withCloseTimeHuman

      public final ImmutableLedgerHeader withCloseTimeHuman(ZonedDateTime value)
      Copy the current immutable object by setting a present value for the optional closeTimeHuman attribute.
      Parameters:
      value - The value for closeTimeHuman
      Returns:
      A modified copy of this object
    • withCloseTimeHuman

      public final ImmutableLedgerHeader withCloseTimeHuman(Optional<? extends ZonedDateTime> optional)
      Copy the current immutable object by setting an optional value for the closeTimeHuman attribute. A shallow reference equality check is used on unboxed optional value to prevent copying of the same value by returning this.
      Parameters:
      optional - A value for closeTimeHuman
      Returns:
      A modified copy of this object
    • withClosed

      public final ImmutableLedgerHeader withClosed(boolean value)
      Copy the current immutable object by setting a value for the closed attribute. A value equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for closed
      Returns:
      A modified copy of the this object
    • withParentHash

      public final ImmutableLedgerHeader withParentHash(Hash256 value)
      Copy the current immutable object by setting a value for the parentHash attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for parentHash
      Returns:
      A modified copy of the this object
    • withParentCloseTime

      public final ImmutableLedgerHeader withParentCloseTime(com.google.common.primitives.UnsignedLong value)
      Copy the current immutable object by setting a present value for the optional parentCloseTime attribute.
      Parameters:
      value - The value for parentCloseTime
      Returns:
      A modified copy of this object
    • withParentCloseTime

      public final ImmutableLedgerHeader withParentCloseTime(Optional<? extends com.google.common.primitives.UnsignedLong> optional)
      Copy the current immutable object by setting an optional value for the parentCloseTime attribute. An equality check is used on inner nullable value to prevent copying of the same value by returning this.
      Parameters:
      optional - A value for parentCloseTime
      Returns:
      A modified copy of this object
    • withTotalCoins

      public final ImmutableLedgerHeader withTotalCoins(XrpCurrencyAmount value)
      Copy the current immutable object by setting a present value for the optional totalCoins attribute.
      Parameters:
      value - The value for totalCoins
      Returns:
      A modified copy of this object
    • withTotalCoins

      public final ImmutableLedgerHeader withTotalCoins(Optional<? extends XrpCurrencyAmount> optional)
      Copy the current immutable object by setting an optional value for the totalCoins attribute. A shallow reference equality check is used on unboxed optional value to prevent copying of the same value by returning this.
      Parameters:
      optional - A value for totalCoins
      Returns:
      A modified copy of this object
    • withTransactionHash

      public final ImmutableLedgerHeader withTransactionHash(Hash256 value)
      Copy the current immutable object by setting a present value for the optional transactionHash attribute.
      Parameters:
      value - The value for transactionHash
      Returns:
      A modified copy of this object
    • withTransactionHash

      public final ImmutableLedgerHeader withTransactionHash(Optional<? extends Hash256> optional)
      Copy the current immutable object by setting an optional value for the transactionHash attribute. A shallow reference equality check is used on unboxed optional value to prevent copying of the same value by returning this.
      Parameters:
      optional - A value for transactionHash
      Returns:
      A modified copy of this object
    • withTransactions

      @SafeVarargs public final ImmutableLedgerHeader withTransactions(TransactionResult<? extends Transaction>... elements)
      Copy the current immutable object with elements that replace the content of transactions.
      Parameters:
      elements - The elements to set
      Returns:
      A modified copy of this object
    • withTransactions

      public final ImmutableLedgerHeader withTransactions(Iterable<? extends TransactionResult<? extends Transaction>> elements)
      Copy the current immutable object with elements that replace the content of transactions. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      elements - An iterable of transactions elements to set
      Returns:
      A modified copy of this object
    • withCloseTimeResolution

      public final ImmutableLedgerHeader withCloseTimeResolution(com.google.common.primitives.UnsignedInteger value)
      Copy the current immutable object by setting a present value for the optional closeTimeResolution attribute.
      Parameters:
      value - The value for closeTimeResolution
      Returns:
      A modified copy of this object
    • withCloseTimeResolution

      public final ImmutableLedgerHeader withCloseTimeResolution(Optional<? extends com.google.common.primitives.UnsignedInteger> optional)
      Copy the current immutable object by setting an optional value for the closeTimeResolution attribute. An equality check is used on inner nullable value to prevent copying of the same value by returning this.
      Parameters:
      optional - A value for closeTimeResolution
      Returns:
      A modified copy of this object
    • equals

      public boolean equals(@Nullable Object another)
      This instance is equal to all instances of ImmutableLedgerHeader that have equal attribute values.
      Overrides:
      equals in class Object
      Returns:
      true if this is equal to another instance
    • hashCode

      public int hashCode()
      Computes a hash code from attributes: ledgerIndex, ledgerHash, accountHash, closeTime, closeTimeHuman, closed, parentHash, parentCloseTime, totalCoins, transactionHash, transactions, closeTimeResolution.
      Overrides:
      hashCode in class Object
      Returns:
      hashCode value
    • toString

      public String toString()
      Prints the immutable value LedgerHeader with attribute values.
      Overrides:
      toString in class Object
      Returns:
      A string representation of the value
    • copyOf

      public static ImmutableLedgerHeader copyOf(LedgerHeader instance)
      Creates an immutable copy of a LedgerHeader value. Uses accessors to get values to initialize the new immutable instance. If an instance is already immutable, it is returned as is.
      Parameters:
      instance - The instance to copy
      Returns:
      A copied immutable LedgerHeader instance
    • builder

      public static ImmutableLedgerHeader.Builder builder()
      Creates a builder for ImmutableLedgerHeader.
       ImmutableLedgerHeader.builder()
          .ledgerIndex(org.xrpl.xrpl4j.model.client.common.LedgerIndex) // required ledgerIndex
          .ledgerHash(org.xrpl.xrpl4j.model.transactions.Hash256) // optional ledgerHash
          .accountHash(org.xrpl.xrpl4j.model.transactions.Hash256) // optional accountHash
          .closeTime(com.google.common.primitives.UnsignedLong) // optional closeTime
          .closeTimeHuman(java.time.ZonedDateTime) // optional closeTimeHuman
          .closed(boolean) // optional closed
          .parentHash(org.xrpl.xrpl4j.model.transactions.Hash256) // required parentHash
          .parentCloseTime(com.google.common.primitives.UnsignedLong) // optional parentCloseTime
          .totalCoins(org.xrpl.xrpl4j.model.transactions.XrpCurrencyAmount) // optional totalCoins
          .transactionHash(org.xrpl.xrpl4j.model.transactions.Hash256) // optional transactionHash
          .addTransactions|addAllTransactions(org.xrpl.xrpl4j.model.client.transactions.TransactionResult&lt;? extends org.xrpl.xrpl4j.model.transactions.Transaction&gt;) // transactions elements
          .closeTimeResolution(com.google.common.primitives.UnsignedInteger) // optional closeTimeResolution
          .build();
       
      Returns:
      A new ImmutableLedgerHeader builder