Package org.polkadot.types.codec
Class Enum
- java.lang.Object
-
- org.polkadot.types.codec.Base<java.lang.Number>
-
- org.polkadot.types.codec.Enum
-
- All Implemented Interfaces:
Codec
- Direct Known Subclasses:
Modules.StorageFunctionModifier,NewAccountOutcome,RewardDestination,VoteThreshold
public class Enum extends Base<java.lang.Number> implements Codec
A codec wrapper for an enum. Enums are encoded as a single byte, where the byte is a zero-indexed value. This class allows you to retrieve the value either by `toNumber()` exposing the actual raw index, or `toString()` returning a string representation (as provided as part of the constructor)
-
-
Constructor Summary
Constructors Constructor Description Enum(java.util.List<java.lang.String> def, java.lang.Object value)
-
Method Summary
Modifier and Type Method Description booleaneq(java.lang.Object other)Compares the value of the input to see if there is a matchintgetEncodedLength()The length of the value when encoded as a Uint8ArrayintgetIndex()Returns the index for this value (equivalent to toNumber)booleanisEmpty()Checks if the value is an empty value (always false)java.lang.StringtoHex()Returns a hex string representation of the valuejava.lang.ObjecttoJson()Converts the Object to JSON, typically used for RPC transfersinttoNumber()Returns the number representation for the valuejava.lang.StringtoString()Returns the string representation of the valuebyte[]toU8a(boolean isBare)Encodes the value as a Uint8Array as per the parity-codec specifications
-
-
-
Method Detail
-
getEncodedLength
public int getEncodedLength()
The length of the value when encoded as a Uint8Array- Specified by:
getEncodedLengthin interfaceCodec
-
getIndex
public int getIndex()
Returns the index for this value (equivalent to toNumber)
-
isEmpty
public boolean isEmpty()
Checks if the value is an empty value (always false)
-
eq
public boolean eq(java.lang.Object other)
Compares the value of the input to see if there is a match
-
toHex
public java.lang.String toHex()
Returns a hex string representation of the value
-
toJson
public java.lang.Object toJson()
Converts the Object to JSON, typically used for RPC transfers
-
toNumber
public int toNumber()
Returns the number representation for the value
-
toString
public java.lang.String toString()
Returns the string representation of the value- Overrides:
toStringin classjava.lang.Object
-
-