Contents
Class ArrayCodec<T>
java.lang.Object
com.hypixel.hytale.codec.codecs.array.ArrayCodec<T>
- All Implemented Interfaces:
Codec<T[]>, RawJsonCodec<T[]>, SchemaConvertable<T[]>, WrappedCodec<T>
- Since:
- 30/6/17.
- Version:
- 1.0
-
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
ConstructorsConstructorDescriptionArrayCodec(Codec<T> codec, IntFunction<T[]> arrayConstructor) ArrayCodec(Codec<T> codec, IntFunction<T[]> arrayConstructor, Supplier<T> defaultValue) -
Method Summary
Modifier and TypeMethodDescriptionT[]T[]decodeJson(RawJsonReader reader, ExtraInfo extraInfo) org.bson.BsonValuestatic <T> ArrayCodec<T> ofBuilderCodec(BuilderCodec<T> codec, IntFunction<T[]> arrayConstructor) Construct an ArrayCodec from the given BuilderCodec whose default array element value is taken fromBuilderCodec.getSupplier().toSchema(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
-
ArrayCodec
-
ArrayCodec
-
-
Method Details
-
getChildCodec
- Specified by:
getChildCodecin interfaceWrappedCodec<T>
-
decode
-
encode
-
decodeJson
public T[] decodeJson(@Nonnull RawJsonReader reader, @Nonnull ExtraInfo extraInfo) throws IOException - Specified by:
decodeJsonin interfaceCodec<T>- Specified by:
decodeJsonin interfaceRawJsonCodec<T>- Throws:
IOException
-
metadata
-
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.
-
getDefaultSupplier
-
ofBuilderCodec
@Nonnull public static <T> ArrayCodec<T> ofBuilderCodec(@Nonnull BuilderCodec<T> codec, IntFunction<T[]> arrayConstructor) Construct an ArrayCodec from the given BuilderCodec whose default array element value is taken fromBuilderCodec.getSupplier(). The returned Codec will parse null array elements as the BuilderCodec's default value.- Type Parameters:
T- The array element type.- Parameters:
codec- TheBuilderCodecto construct an ArrayCodec for.arrayConstructor- An IntFunction used to construct arrays of element type T.- Returns:
- A new ArrayCodec for encoding and decoding arrays of type T.
-