Class EnumCodec<T extends Enum<T>>

java.lang.Object
com.hypixel.hytale.codec.codecs.EnumCodec<T>
All Implemented Interfaces:
Codec<T>, RawJsonCodec<T>, SchemaConvertable<T>

public class EnumCodec<T extends Enum<T>> extends Object implements Codec<T>
Since:
30/6/17.
Version:
1.0
  • Constructor Details

  • Method Details

    • getEnumKeys

      @Nonnull public String[] getEnumKeys()
    • documentKey

      @Nonnull public EnumCodec<T> documentKey(T key, String doc)
    • decode

      @Nonnull public T decode(@Nonnull org.bson.BsonValue bsonValue, ExtraInfo extraInfo)
      Specified by:
      decode in interface Codec<T extends Enum<T>>
    • encode

      @Nonnull public org.bson.BsonValue encode(@Nonnull T r, ExtraInfo extraInfo)
      Specified by:
      encode in interface Codec<T extends Enum<T>>
    • decodeJson

      @Nonnull public T decodeJson(@Nonnull RawJsonReader reader, ExtraInfo extraInfo) throws IOException
      Specified by:
      decodeJson in interface Codec<T extends Enum<T>>
      Specified by:
      decodeJson in interface RawJsonCodec<T extends Enum<T>>
      Throws:
      IOException
    • toSchema

      @Nonnull public Schema toSchema(@Nonnull SchemaContext context)
      Description copied from interface: SchemaConvertable
      Returns a schema object that represents this codec as JSON Schema.
      Specified by:
      toSchema in interface SchemaConvertable<T extends Enum<T>>
      Parameters:
      context - A context to use to assist with creating the schema.
      Returns:
      the generated schema.
    • toSchema

      @Nonnull public Schema toSchema(@Nonnull SchemaContext context, @Nullable T def)
      Description copied from interface: SchemaConvertable
      Returns a schema object that represents this codec as JSON Schema.
      Specified by:
      toSchema in interface SchemaConvertable<T extends Enum<T>>
      Parameters:
      context - A context to use to assist with creating the schema.
      def - An instance of what this codec can produce which is the default value.
      Returns:
      the generated schema.