Class Asset

java.lang.Object
org.stellar.sdk.Asset
All Implemented Interfaces:
Comparable<Asset>
Direct Known Subclasses:
AssetTypeCreditAlphaNum, AssetTypeNative, AssetTypePoolShare

public abstract class Asset extends Object implements Comparable<Asset>
Base Asset class.
See Also:
  • Method Details

    • create

      public static Asset create(String canonicalForm)
      Parses an asset string and returns the equivalent Asset instance. The asset string is expected to either be "native" or a string of Alpha4 or Alpha12 asset code as "CODE:ISSUER"
      Parameters:
      canonicalForm - Canonical string representation of an Alpha4 or Alpha12 asset
      Returns:
      Asset or throws IllegalArgumentException if not Alpha4 or Alpha12 asset code
    • create

      public static Asset create(String type, String code, String issuer)
      Creates Asset for Alpha4/Alpha12/Native
      Parameters:
      type - the type of asset. 'native' will generate its respective asset sub-class, if null or any other value will attempt to derive the asset sub-class from code and issuer.
      code - the asset code or null
      issuer - the asset issuer or null
      Returns:
      Asset
    • create

      public static Asset create(String type, String code, String issuer, String liquidityPoolID)
      Creates Asset for Alpha4/Alpha12/Native/LiquidityPool
      Parameters:
      type - the type of asset. 'native' and 'liquidity_pool_shares' will generate their respective asset sub-classes null or any other value will attempt to derive the asset sub-class from code and issuer.
      code - the asset code or null
      issuer - the asset issuer or null
      liquidityPoolID - required only if type is 'liquidity_pool_shares'
      Returns:
      Asset
    • create

      public static Asset create(ChangeTrustAsset.Wrapper wrapped)
      Create Asset from a ChangeTrustAsset
      Parameters:
      wrapped - the ChangeTrustAsset wrapper
      Returns:
      Asset
    • create

      public static Asset create(TrustLineAsset.Wrapper wrapped)
      Create Asset from a TrustLineAsset
      Parameters:
      wrapped - the TrustLineAsset wrapper
      Returns:
      Asset
    • fromXdr

      public static Asset fromXdr(Asset xdr)
      Generates Asset object from a given XDR object
      Parameters:
      xdr - XDR object
    • getType

      public abstract String getType()
      Returns asset type. Possible types:
      • native
      • credit_alphanum4
      • credit_alphanum12
      • liquidity_pool_shares
    • toXdr

      public abstract Asset toXdr()
      Generates XDR object from a given Asset object
    • equals

      public abstract boolean equals(Object object)
      Overrides:
      equals in class Object
    • compareTo

      public abstract int compareTo(@NonNull @NonNull Asset other)
      Specified by:
      compareTo in interface Comparable<Asset>
    • getContractId

      public String getContractId(Network network) throws IOException
      Returns the contract Id for the asset contract.
      Parameters:
      network - The network where the asset is located.
      Returns:
      The contract Id for the asset contract.
      Throws:
      IOException