Package org.stellar.sdk
Class Price
java.lang.Object
org.stellar.sdk.Price
Represents Price. Price in Stellar is represented as a fraction.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
static Price
fromString
(@NonNull String price) Approximatesprice
to a fraction.static Price
Generates a Price SDK object from the XDR representation.int
denominatorint
numeratorint
hashCode()
toString()
Returns price as a string.toXdr()
Generates Price XDR object.
-
Constructor Details
-
Price
public Price(int numerator, int denominator) Creates a newPrice
instance.- Parameters:
numerator
- numeratordenominator
- denominator
-
-
Method Details
-
fromString
Approximatesprice
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
Generates a Price SDK object from the XDR representation. -
toXdr
Generates Price XDR object. -
toString
Returns price as a string. -
getNumerator
public int getNumerator()numerator -
getDenominator
public int getDenominator()denominator -
equals
-
hashCode
public int hashCode()
-