Class ImmutablePriceData

java.lang.Object
org.xrpl.xrpl4j.model.transactions.ImmutablePriceData
All Implemented Interfaces:
PriceData

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

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

  • Method Details

    • baseAsset

      public String baseAsset()
      The primary asset in a trading pair. Any valid identifier, such as a stock symbol, bond CUSIP, or currency code is allowed. For example, in the BTC/USD pair, BTC is the base asset; in 912810RR9/BTC, 912810RR9 is the base asset.
      Specified by:
      baseAsset in interface PriceData
      Returns:
      A String.
    • quoteAsset

      public String quoteAsset()
      The quote asset in a trading pair. The quote asset denotes the price of one unit of the base asset. For example, in the BTC/USD pair, BTC is the base asset; in 912810RR9/BTC, 912810RR9 is the base asset.
      Specified by:
      quoteAsset in interface PriceData
      Returns:
      A String.
    • assetPrice

      public Optional<AssetPrice> assetPrice()
      The asset price after applying the scale() precision level. It's not included if the last update transaction didn't include the baseAsset()/quoteAsset() pair.
      Specified by:
      assetPrice in interface PriceData
      Returns:
      An Optional AssetPrice.
    • scale

      public Optional<com.google.common.primitives.UnsignedInteger> scale()
      The scaling factor to apply to an asset price. For example, if scale is 6 and original price is 0.155, then the scaled price is 155000. Valid scale ranges are 0-10. It's not included if the last update transaction didn't include the baseAsset()/quoteAsset() pair.
      Specified by:
      scale in interface PriceData
      Returns:
      An Optional UnsignedInteger.
    • withBaseAsset

      public final ImmutablePriceData withBaseAsset(String value)
      Copy the current immutable object by setting a value for the baseAsset attribute. An equals check used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for baseAsset
      Returns:
      A modified copy of the this object
    • withQuoteAsset

      public final ImmutablePriceData withQuoteAsset(String value)
      Copy the current immutable object by setting a value for the quoteAsset attribute. An equals check used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for quoteAsset
      Returns:
      A modified copy of the this object
    • withAssetPrice

      public final ImmutablePriceData withAssetPrice(AssetPrice value)
      Copy the current immutable object by setting a present value for the optional assetPrice attribute.
      Parameters:
      value - The value for assetPrice
      Returns:
      A modified copy of this object
    • withAssetPrice

      public final ImmutablePriceData withAssetPrice(Optional<? extends AssetPrice> optional)
      Copy the current immutable object by setting an optional value for the assetPrice 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 assetPrice
      Returns:
      A modified copy of this object
    • withScale

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

      public final ImmutablePriceData withScale(Optional<? extends com.google.common.primitives.UnsignedInteger> optional)
      Copy the current immutable object by setting an optional value for the scale 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 scale
      Returns:
      A modified copy of this object
    • equals

      public boolean equals(@Nullable Object another)
      This instance is equal to all instances of ImmutablePriceData 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: baseAsset, quoteAsset, assetPrice, scale.
      Overrides:
      hashCode in class Object
      Returns:
      hashCode value
    • toString

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

      public static ImmutablePriceData copyOf(PriceData instance)
      Creates an immutable copy of a PriceData 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 PriceData instance
    • builder

      public static ImmutablePriceData.Builder builder()
      Creates a builder for ImmutablePriceData.
       ImmutablePriceData.builder()
          .baseAsset(String) // required baseAsset
          .quoteAsset(String) // required quoteAsset
          .assetPrice(AssetPrice) // optional assetPrice
          .scale(com.google.common.primitives.UnsignedInteger) // optional scale
          .build();
       
      Returns:
      A new ImmutablePriceData builder