Class Price

java.lang.Object
org.stellar.sdk.Price

public final class Price extends Object
Represents Price. Price in Stellar is represented as a fraction.
  • Constructor Details

    • Price

      public Price(int numerator, int denominator)
      Creates a new Price instance.
      Parameters:
      numerator - numerator
      denominator - denominator
  • Method Details

    • fromString

      public static Price fromString(@NonNull @NonNull String price)
      Approximates price to a fraction. Please remember that this function can give unexpected results for values that cannot be represented as a fraction with 32-bit numerator and denominator. It's safer to create a Price object using the constructor.
      Parameters:
      price - Ex. "1.25"
    • fromXdr

      public static Price fromXdr(Price price)
      Generates a Price SDK object from the XDR representation.
    • toXdr

      public Price toXdr()
      Generates Price XDR object.
    • toString

      public String toString()
      Returns price as a string.
      Overrides:
      toString in class Object
    • getNumerator

      public int getNumerator()
      numerator
    • getDenominator

      public int getDenominator()
      denominator
    • equals

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

      public int hashCode()
      Overrides:
      hashCode in class Object