Contents
Class DeferredCodec<T>
java.lang.Object
com.hypixel.hytale.codec.lookup.DeferredCodec<T>
- Type Parameters:
T- the type the value decodes to
- All Implemented Interfaces:
Codec<Deferred<T>>, RawJsonCodec<Deferred<T>>, SchemaConvertable<Deferred<T>>, WrappedCodec<T>
Reads a value into a
Deferred rather than decoding it. This lets the codec for its
type be registered after the file that names it was read.
The schema is that of the codec it wraps, so a key that defers its decode still documents every type it accepts.
A value read from JSON is held as BSON and later decoded from that BSON. A field codec that accepts a JSON form its BSON decode does not, such as a base64 string for binary, fails once deferred. Register only types whose fields decode from both forms.
-
Field Summary
Fields inherited from interface Codec
BASE64_PATTERN, BOOLEAN, BSON_DOCUMENT, BYTE, BYTE_ARRAY, DOUBLE, DOUBLE_ARRAY, DURATION, DURATION_SECONDS, FLOAT, FLOAT_ARRAY, INSTANT, INT_ARRAY, INTEGER, LOG_LEVEL, LONG, LONG_ARRAY, NULLABLE_BOOLEAN, PATH, SHORT, STRING, STRING_ARRAY, UUID_BINARY, UUID_STRING -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondecodeJson(RawJsonReader reader, ExtraInfo extraInfo) org.bson.BsonValuetoSchema(SchemaContext context) Returns a schema object that represents this codec as JSON Schema.Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface RawJsonCodec
decodeJsonMethods inherited from interface SchemaConvertable
toSchema
-
Constructor Details
-
DeferredCodec
-
-
Method Details
-
decode
-
decodeJson
@Nonnull public Deferred<T> decodeJson(@Nonnull RawJsonReader reader, ExtraInfo extraInfo) throws IOException - Specified by:
decodeJsonin interfaceCodec<T>- Specified by:
decodeJsonin interfaceRawJsonCodec<T>- Throws:
IOException
-
encode
-
getChildCodec
- Specified by:
getChildCodecin interfaceWrappedCodec<T>
-
toSchema
Description copied from interface:SchemaConvertableReturns a schema object that represents this codec as JSON Schema.- Specified by:
toSchemain interfaceSchemaConvertable<T>- Parameters:
context- A context to use to assist with creating the schema.- Returns:
- the generated schema.
-