Package org.stellar.sdk
Class Asset
java.lang.Object
org.stellar.sdk.Asset
- All Implemented Interfaces:
Comparable<Asset>
- Direct Known Subclasses:
AssetTypeCreditAlphaNum,AssetTypeNative,AssetTypePoolShare
Base Asset class.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionabstract intstatic AssetParses an asset string and returns the equivalent Asset instance.static AssetCreates Asset for Alpha4/Alpha12/Nativestatic AssetCreates Asset for Alpha4/Alpha12/Native/LiquidityPoolstatic Assetcreate(ChangeTrustAsset.Wrapper wrapped) Create Asset from a ChangeTrustAssetstatic Assetcreate(TrustLineAsset.Wrapper wrapped) Create Asset from a TrustLineAssetabstract booleanstatic AssetGenerates Asset object from a given XDR objectgetContractId(Network network) Returns the contract Id for the asset contract.abstract StringgetType()Returns asset type.abstract AssettoXdr()Generates XDR object from a given Asset object
-
Method Details
-
create
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
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 nullissuer- the asset issuer or null- Returns:
- Asset
-
create
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 nullissuer- the asset issuer or nullliquidityPoolID- required only if type is 'liquidity_pool_shares'- Returns:
- Asset
-
create
Create Asset from a ChangeTrustAsset- Parameters:
wrapped- the ChangeTrustAsset wrapper- Returns:
- Asset
-
create
Create Asset from a TrustLineAsset- Parameters:
wrapped- the TrustLineAsset wrapper- Returns:
- Asset
-
fromXdr
Generates Asset object from a given XDR object- Parameters:
xdr- XDR object
-
getType
Returns asset type. Possible types:nativecredit_alphanum4credit_alphanum12liquidity_pool_shares
-
toXdr
Generates XDR object from a given Asset object -
equals
-
compareTo
- Specified by:
compareToin interfaceComparable<Asset>
-
getContractId
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
-