Class ASN1EnumBase<T extends Enum<T> & EnumWithIntegerValue>

java.lang.Object
org.bouncycastle.asn1.ASN1Object
paccor.tcg.credential.ASN1EnumBase<T>
Type Parameters:
T - An enum that implements EnumWithValue
All Implemented Interfaces:
org.bouncycastle.asn1.ASN1Encodable, org.bouncycastle.util.Encodable
Direct Known Subclasses:
ASN1BitStringEnumBase, ASN1EnumeratedEnumBase

public abstract class ASN1EnumBase<T extends Enum<T> & EnumWithIntegerValue> extends org.bouncycastle.asn1.ASN1Object
Common functionality for usage of Java Enums with BC ASN1Objects that can be identified by an integer value
  • Constructor Details

    • ASN1EnumBase

      public ASN1EnumBase()
  • Method Details

    • getInstance

      public static <T extends Enum<T> & EnumWithIntegerValue, U extends ASN1EnumBase<T>> U getInstance(Object obj, @NonNull @NonNull ASN1EnumBase.Factory<T,U> factory)
      Get Instance.
      Type Parameters:
      T - Java enum type that implements EnumWithValue.
      U - Type relevant to <T> that extends AbstractEnumWithASN1Value.
      Parameters:
      obj - Input object
      factory - Utility to convert values.
      Returns:
      U
    • fromJsonNode

      public static <T extends Enum<T> & EnumWithIntegerValue, U extends ASN1EnumBase<T>> U fromJsonNode(@NonNull @NonNull tools.jackson.databind.JsonNode jsonNode, @NonNull @NonNull Class<T> enumType, @NonNull @NonNull ASN1EnumBase.Factory<T,U> factory)
      Get Instance from JsonNode
      Type Parameters:
      T - Java enum type that implements EnumWithValue.
      U - Type relevant to <T> that extends AbstractEnumWithASN1Value.
      Parameters:
      jsonNode - json object
      enumType - Target enum class.
      factory - Utility to convert values.
      Returns:
      U
    • toASN1Primitive

      public abstract org.bouncycastle.asn1.ASN1Primitive toASN1Primitive()
      Converts the value to its ASN.1 representation.
      Specified by:
      toASN1Primitive in interface org.bouncycastle.asn1.ASN1Encodable
      Specified by:
      toASN1Primitive in class org.bouncycastle.asn1.ASN1Object
      Returns:
      value as ASN1Primitive
    • getEnum

      public T getEnum()
      Look up the enum object by value.
      Returns:
      The Enum object in T that corresponds with the value.