Interface LedgerSpecifier
-
- All Known Implementing Classes:
ImmutableLedgerSpecifier
@Immutable public interface LedgerSpecifier
Represents one of the three ways of specifying a ledger in a rippled API request.- See Also:
- "https://xrpl.org/basic-data-types.html#specifying-ledgers"
-
-
Field Summary
Fields Modifier and Type Field Description static LedgerSpecifier
CLOSED
Request information about the most recent ledger that has been closed for modifications and proposed for validation.static LedgerSpecifier
CURRENT
Request information about for the most recent ledger that has been validated by consensus.static LedgerSpecifier
VALIDATED
Request information about a rippled server's current working version of the ledger.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default void
handle(Consumer<Hash256> ledgerHashHandler, Consumer<LedgerIndex> ledgerIndexHandler, Consumer<LedgerIndexShortcut> ledgerIndexShortcutHandler)
Handle thisLedgerSpecifier
depending on which specifier is present.Optional<Hash256>
ledgerHash()
A 20-byte hex string for the ledger version to use.Optional<LedgerIndex>
ledgerIndex()
The ledger index of the ledger to use.Optional<LedgerIndexShortcut>
ledgerIndexShortcut()
A shortcut word specifying the ledger to use.default <R> R
map(Function<Hash256,R> ledgerHashMapper, Function<LedgerIndex,R> ledgerIndexMapper, Function<LedgerIndexShortcut,R> ledgerIndexShortcutMapper)
Map thisLedgerSpecifier
to an instance ofLedgerSpecifier
, depending on which specifier is present.static LedgerSpecifier
of(int ledgerIndex)
Construct aLedgerSpecifier
with a numerical ledger index.static LedgerSpecifier
of(com.google.common.primitives.UnsignedInteger ledgerIndex)
Construct aLedgerSpecifier
with a numerical ledger index.static LedgerSpecifier
of(LedgerIndex ledgerIndex)
Construct aLedgerSpecifier
with a numerical ledger index.static LedgerSpecifier
of(Hash256 ledgerHash)
Construct aLedgerSpecifier
with a ledger hash.default void
validateOnlyOneSpecified()
Validates that only one of the three fields in aLedgerSpecifier
is present.
-
-
-
Field Detail
-
VALIDATED
static final LedgerSpecifier VALIDATED
Request information about a rippled server's current working version of the ledger.
-
CURRENT
static final LedgerSpecifier CURRENT
Request information about for the most recent ledger that has been validated by consensus.
-
CLOSED
static final LedgerSpecifier CLOSED
Request information about the most recent ledger that has been closed for modifications and proposed for validation.
-
-
Method Detail
-
of
static LedgerSpecifier of(Hash256 ledgerHash)
Construct aLedgerSpecifier
with a ledger hash.- Parameters:
ledgerHash
- AHash256
containing the ledger hash of the desired ledger.- Returns:
- A
LedgerSpecifier
containingledgerHash
.
-
of
static LedgerSpecifier of(LedgerIndex ledgerIndex)
Construct aLedgerSpecifier
with a numerical ledger index.- Parameters:
ledgerIndex
- TheLedgerIndex
of the desired ledger.- Returns:
- A
LedgerSpecifier
containingledgerIndex
.
-
of
static LedgerSpecifier of(com.google.common.primitives.UnsignedInteger ledgerIndex)
Construct aLedgerSpecifier
with a numerical ledger index.- Parameters:
ledgerIndex
- TheUnsignedInteger
of the desired ledger.- Returns:
- A
LedgerSpecifier
containingledgerIndex
.
-
of
static LedgerSpecifier of(int ledgerIndex)
Construct aLedgerSpecifier
with a numerical ledger index.- Parameters:
ledgerIndex
- Theint
of the desired ledger.- Returns:
- A
LedgerSpecifier
containingledgerIndex
.
-
ledgerHash
Optional<Hash256> ledgerHash()
A 20-byte hex string for the ledger version to use.- Returns:
- An optionally-present
Hash256
.
-
ledgerIndex
Optional<LedgerIndex> ledgerIndex()
The ledger index of the ledger to use.- Returns:
- An optionally-present
LedgerIndex
.
-
ledgerIndexShortcut
Optional<LedgerIndexShortcut> ledgerIndexShortcut()
A shortcut word specifying the ledger to use.- Returns:
- An optionally-present
LedgerIndexShortcut
.
-
handle
@Auxiliary default void handle(Consumer<Hash256> ledgerHashHandler, Consumer<LedgerIndex> ledgerIndexHandler, Consumer<LedgerIndexShortcut> ledgerIndexShortcutHandler)
Handle thisLedgerSpecifier
depending on which specifier is present.- Parameters:
ledgerHashHandler
- AConsumer
that is called ifledgerHash()
is present.ledgerIndexHandler
- AConsumer
that is called ifledgerIndex()
is present.ledgerIndexShortcutHandler
- AConsumer
that is called ifledgerIndexShortcut()
is present.
-
map
@Auxiliary default <R> R map(Function<Hash256,R> ledgerHashMapper, Function<LedgerIndex,R> ledgerIndexMapper, Function<LedgerIndexShortcut,R> ledgerIndexShortcutMapper)
Map thisLedgerSpecifier
to an instance ofLedgerSpecifier
, depending on which specifier is present.- Type Parameters:
R
- The type of object to return after mapping.- Parameters:
ledgerHashMapper
- AFunction
that is called ifledgerHash()
is present.ledgerIndexMapper
- AFunction
that is called ifledgerIndex()
is present.ledgerIndexShortcutMapper
- AFunction
that is called ifledgerIndexShortcut()
is present.- Returns:
- A
LedgerSpecifier
that is constructed by the appropriate mapper function.
-
validateOnlyOneSpecified
@Check default void validateOnlyOneSpecified()
Validates that only one of the three fields in aLedgerSpecifier
is present.
-
-