Class Asset

java.lang.Object
org.stellar.sdk.xdr.Asset
All Implemented Interfaces:
XdrElement

public class Asset extends Object implements XdrElement
Asset's original definition in the XDR file is:
 union Asset switch (AssetType type)
 {
 case ASSET_TYPE_NATIVE: // Not credit
     void;

 case ASSET_TYPE_CREDIT_ALPHANUM4:
     AlphaNum4 alphaNum4;

 case ASSET_TYPE_CREDIT_ALPHANUM12:
     AlphaNum12 alphaNum12;

     // add other asset types here in the future
 };
 
  • Constructor Details

    • Asset

      public Asset()
    • Asset

      public Asset(AssetType discriminant, AlphaNum4 alphaNum4, AlphaNum12 alphaNum12)
      Creates a new Asset instance.
      Parameters:
      discriminant - the discriminant field value
      alphaNum4 - the alphaNum4 field value
      alphaNum12 - the alphaNum12 field value
  • Method Details

    • encode

      public void encode(XdrDataOutputStream stream) throws IOException
      Description copied from interface: XdrElement
      Encodes this value to XDR and writes it to the provided stream.
      Specified by:
      encode in interface XdrElement
      Parameters:
      stream - the destination XDR output stream
      Throws:
      IOException - if an I/O error occurs while writing the value
    • decode

      public static Asset decode(XdrDataInputStream stream, int maxDepth) throws IOException
      Throws:
      IOException
    • decode

      public static Asset decode(XdrDataInputStream stream) throws IOException
      Throws:
      IOException
    • fromXdrBase64

      public static Asset fromXdrBase64(String xdr) throws IOException
      Throws:
      IOException
    • fromXdrByteArray

      public static Asset fromXdrByteArray(byte[] xdr) throws IOException
      Throws:
      IOException
    • toJson

      public String toJson()
      Description copied from interface: XdrElement
      Serializes this value to JSON.
      Specified by:
      toJson in interface XdrElement
      Returns:
      the JSON representation of this value
    • fromJson

      public static Asset fromJson(String json)
    • builder

      public static Asset.AssetBuilder builder()
    • toBuilder

      public Asset.AssetBuilder toBuilder()
    • getDiscriminant

      public AssetType getDiscriminant()
      Value of the discriminant field.
      Returns:
      the discriminant field value
    • getAlphaNum4

      public AlphaNum4 getAlphaNum4()
      Value of the alphaNum4 field.
      Returns:
      the alphaNum4 field value
    • getAlphaNum12

      public AlphaNum12 getAlphaNum12()
      Value of the alphaNum12 field.
      Returns:
      the alphaNum12 field value
    • setDiscriminant

      public void setDiscriminant(AssetType discriminant)
      Value of the discriminant field.
      Parameters:
      discriminant - the discriminant field value
    • setAlphaNum4

      public void setAlphaNum4(AlphaNum4 alphaNum4)
      Value of the alphaNum4 field.
      Parameters:
      alphaNum4 - the alphaNum4 field value
    • setAlphaNum12

      public void setAlphaNum12(AlphaNum12 alphaNum12)
      Value of the alphaNum12 field.
      Parameters:
      alphaNum12 - the alphaNum12 field value
    • equals

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

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object