Package org.polkadot.types.codec
Class EnumType<T>
- java.lang.Object
-
- org.polkadot.types.codec.Base<Codec>
-
- org.polkadot.types.codec.EnumType<T>
-
- All Implemented Interfaces:
Codec
- Direct Known Subclasses:
AttestedCandidate.ValidityAttestation,Digest.DigestItem,EventRecord.Phase,ExtrinsicStatus,MetadataVersioned.MetadataEnum,MisbehaviorReport.MisbehaviorKind,Modules.StorageFunctionType,Storage.MetadataStorageModifier,Storage.MetadataStorageType,Storage.MetadataStorageType,Storage.MetadataStorageType
public class EnumType<T> extends Base<Codec> implements Codec
This implements an enum, that based on the value wraps a different type. It is effectively an extension to enum where the value type is determined by the actual index.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceEnumType.EnumConstructor<T extends Codec>
-
Constructor Summary
Constructors Constructor Description EnumType(Types.ConstructorDef def, java.lang.Object value, int index, java.util.LinkedHashMap<java.lang.String,java.lang.String> aliasses)
-
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 Uint8Arrayjava.lang.StringgetType()The name of the type this enum value representsintindex()The index of the metadata valuebooleanisEmpty()Checks if the value is an empty valuebooleanisNone()Checks if the Enum points to aNulltypebooleanisNull()Checks if the Enum points to aNulltype (deprecated, use isNone)booleanisType(java.lang.String value)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 specificationsCodecvalue()The value of the enumstatic Types.ConstructorCodec<EnumType>with(Types.ConstructorDef def)
-
-
-
Constructor Detail
-
EnumType
public EnumType(Types.ConstructorDef def, java.lang.Object value, int index, java.util.LinkedHashMap<java.lang.String,java.lang.String> aliasses)
-
-
Method Detail
-
with
public static Types.ConstructorCodec<EnumType> with(Types.ConstructorDef def)
-
toNumber
public int toNumber()
Returns the number representation for the value
-
value
public Codec value()
The value of the enum
-
getType
public java.lang.String getType()
The name of the type this enum value represents
-
index
public int index()
The index of the metadata value
-
isNull
public boolean isNull()
Checks if the Enum points to aNulltype (deprecated, use isNone)
-
getEncodedLength
public int getEncodedLength()
The length of the value when encoded as a Uint8Array- Specified by:
getEncodedLengthin interfaceCodec
-
isEmpty
public boolean isEmpty()
Checks if the value is an empty value
-
isNone
public boolean isNone()
Checks if the Enum points to aNulltype
-
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
-
toString
public java.lang.String toString()
Returns the string representation of the value- Overrides:
toStringin classjava.lang.Object
-
toU8a
public byte[] toU8a(boolean isBare)
Encodes the value as a Uint8Array as per the parity-codec specifications
-
isType
public boolean isType(java.lang.String value)
-
-