Package com.hypixel.hytale.codec.builder
Class BuilderCodec<T>
java.lang.Object
com.hypixel.hytale.codec.builder.BuilderCodec<T>
- All Implemented Interfaces:
Codec<T>,DirectDecodeCodec<T>,InheritCodec<T>,RawJsonCodec<T>,RawJsonInheritCodec<T>,SchemaConvertable<T>,ValidatableCodec<T>
- Direct Known Subclasses:
AssetBuilderCodec
public class BuilderCodec<T>
extends Object
implements Codec<T>, DirectDecodeCodec<T>, RawJsonCodec<T>, InheritCodec<T>, ValidatableCodec<T>
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classBuilderCodec.BuilderBase<T,S extends BuilderCodec.BuilderBase<T, S>> protected static enumprotected static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final BiConsumer<T, ExtraInfo> protected final intprotected final Stringstatic final BuilderCodec<?>[]protected final Map<String, List<BuilderField<T, ?>>> protected final booleanstatic final intprotected final intprotected final BuilderCodec<? super T> protected final StringTreeMap<BuilderCodec.KeyEntry<T>> protected final Map<String, List<BuilderField<T, ?>>> static final intstatic final intprotected final booleanprotected final BiConsumer<T, ValidationResults> private static final KeyedCodec<Integer> protected final booleanFields inherited from interface com.hypixel.hytale.codec.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, PATH, SHORT, STRING, STRING_ARRAY, UUID_BINARY, UUID_STRING -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> BuilderCodec.Builder<T> abstractBuilder(Class<T> tClass) static <T> BuilderCodec.Builder<T> abstractBuilder(Class<T> tClass, BuilderCodec<? super T> parentCodec) voidafterDecode(T t, ExtraInfo extraInfo) voidafterDecodeAndValidate(T t, ExtraInfo extraInfo) static <T> BuilderCodec.Builder<T> static <T> BuilderCodec.Builder<T> builder(Class<T> tClass, Supplier<T> supplier, BuilderCodec<? super T> parentCodec) private static <T> voidcreateSchemaFields(SchemaContext context, T def, BuilderCodec<T> codec, Map<String, Schema> properties) voidprotected voidprivate static <Type,FieldType>
voiddecodeAndInherit(BuilderField<Type, FieldType> entry, org.bson.BsonDocument document, Type t, Type parent, ExtraInfo extraInfo) decodeAndInherit(org.bson.BsonDocument document, T parent, ExtraInfo extraInfo) voiddecodeAndInherit(org.bson.BsonDocument document, T t, T parent, ExtraInfo extraInfo) protected voiddecodeAndInherit0(org.bson.BsonDocument document, T t, T parent, ExtraInfo extraInfo) private static <Type,FieldType>
voiddecodeAndInheritJson(BuilderField<Type, FieldType> entry, RawJsonReader reader, Type t, Type parent, ExtraInfo extraInfo) decodeAndInheritJson(RawJsonReader reader, T parent, ExtraInfo extraInfo) voiddecodeAndInheritJson(RawJsonReader reader, T t, T parent, ExtraInfo extraInfo) voiddecodeAndInheritJson0(RawJsonReader reader, T t, T parent, ExtraInfo extraInfo) decodeJson(RawJsonReader reader, ExtraInfo extraInfo) voiddecodeJson(RawJsonReader reader, T t, ExtraInfo extraInfo) voiddecodeJson0(RawJsonReader reader, T t, ExtraInfo extraInfo) protected ExtraInfodecodeVersion(RawJsonReader reader, ExtraInfo extraInfo) protected ExtraInfodecodeVersion(org.bson.BsonDocument document, ExtraInfo extraInfo) org.bson.BsonDocumentprotected org.bson.BsonDocumentprotected static <T> BuilderField<? super T, ?> findEntry(BuilderCodec<? super T> current, String key, ExtraInfo extraInfo) protected static <T,F extends BuilderField<T, ?>>
FintgetDefaultValue(ExtraInfo extraInfo) Map<String, List<BuilderField<T, ?>>> BuilderCodec<? super T> voidprotected voidreadAndInheritEntry(RawJsonReader reader, T t, T parent, ExtraInfo extraInfo) private voidreadAndInheritField(RawJsonReader reader, T t, T parent, ExtraInfo extraInfo, String key, List<BuilderField<T, ?>> fields) protected voidreadEntry(RawJsonReader reader, T t, ExtraInfo extraInfo) private voidreadField(RawJsonReader reader, T t, ExtraInfo extraInfo, String key, List<BuilderField<T, ?>> fields) private voidreadUnknownField(RawJsonReader reader, ExtraInfo extraInfo) private voidskipField(RawJsonReader reader) toSchema(SchemaContext context) toSchema(SchemaContext context, T def) toString()voidvoidvalidateDefaults(ExtraInfo extraInfo, Set<Codec<?>> tested) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.hypixel.hytale.codec.RawJsonCodec
decodeJson
-
Field Details
-
UNSET_VERSION
public static final int UNSET_VERSION- See Also:
-
UNSET_MAX_VERSION
public static final int UNSET_MAX_VERSION- See Also:
-
INITIAL_VERSION
public static final int INITIAL_VERSION- See Also:
-
EMPTY_ARRAY
-
VERSION
-
tClass
-
supplier
-
parentCodec
-
entries
-
unmodifiableEntries
-
validator
-
afterDecode
-
hasNonNullValidator
protected final boolean hasNonNullValidator -
documentation
-
metadata
-
codecVersion
protected final int codecVersion -
minCodecVersion
protected final int minCodecVersion -
versioned
protected final boolean versioned -
useLegacyVersion
protected final boolean useLegacyVersion -
stringTreeMap
-
-
Constructor Details
-
BuilderCodec
-
-
Method Details
-
getInnerClass
-
getSupplier
-
getDefaultValue
-
getDefaultValue
-
getEntries
-
getAfterDecode
-
getParent
-
getDocumentation
-
getCodecVersion
public int getCodecVersion() -
inherit
-
afterDecode
-
afterDecodeAndValidate
-
decode
-
encode
-
decode
- Specified by:
decodein interfaceDirectDecodeCodec<T>
-
decode0
-
encode0
-
decodeJson
- Specified by:
decodeJsonin interfaceCodec<T>- Specified by:
decodeJsonin interfaceRawJsonCodec<T>- Throws:
IOException
-
decodeJson0
- Throws:
IOException
-
readEntry
protected void readEntry(@Nonnull RawJsonReader reader, T t, @Nonnull ExtraInfo extraInfo) throws IOException - Throws:
IOException
-
skipField
- Throws:
IOException
-
readField
private void readField(@Nonnull RawJsonReader reader, T t, @Nonnull ExtraInfo extraInfo, String key, @Nonnull List<BuilderField<T, ?>> fields) throws IOException- Throws:
IOException
-
readUnknownField
private void readUnknownField(@Nonnull RawJsonReader reader, @Nonnull ExtraInfo extraInfo) throws IOException - Throws:
IOException
-
decodeJson
public void decodeJson(@Nonnull RawJsonReader reader, T t, @Nonnull ExtraInfo extraInfo) throws IOException - Throws:
IOException
-
decodeAndInherit
- Specified by:
decodeAndInheritin interfaceInheritCodec<T>
-
decodeAndInherit
public void decodeAndInherit(@Nonnull org.bson.BsonDocument document, T t, @Nullable T parent, ExtraInfo extraInfo) - Specified by:
decodeAndInheritin interfaceInheritCodec<T>
-
decodeAndInherit0
-
decodeAndInherit
private static <Type,FieldType> void decodeAndInherit(@Nonnull BuilderField<Type, FieldType> entry, @Nonnull org.bson.BsonDocument document, Type t, @Nullable Type parent, @Nonnull ExtraInfo extraInfo) -
decodeAndInheritJson
public T decodeAndInheritJson(@Nonnull RawJsonReader reader, T parent, ExtraInfo extraInfo) throws IOException - Specified by:
decodeAndInheritJsonin interfaceRawJsonInheritCodec<T>- Throws:
IOException
-
decodeAndInheritJson
public void decodeAndInheritJson(@Nonnull RawJsonReader reader, T t, @Nullable T parent, ExtraInfo extraInfo) throws IOException - Specified by:
decodeAndInheritJsonin interfaceRawJsonInheritCodec<T>- Throws:
IOException
-
decodeAndInheritJson0
public void decodeAndInheritJson0(@Nonnull RawJsonReader reader, T t, T parent, @Nonnull ExtraInfo extraInfo) throws IOException - Throws:
IOException
-
readAndInheritEntry
protected void readAndInheritEntry(@Nonnull RawJsonReader reader, T t, T parent, @Nonnull ExtraInfo extraInfo) throws IOException - Throws:
IOException
-
readAndInheritField
private void readAndInheritField(@Nonnull RawJsonReader reader, T t, T parent, @Nonnull ExtraInfo extraInfo, String key, @Nonnull List<BuilderField<T, ?>> fields) throws IOException- Throws:
IOException
-
decodeAndInheritJson
private static <Type,FieldType> void decodeAndInheritJson(@Nonnull BuilderField<Type, FieldType> entry, @Nonnull RawJsonReader reader, Type t, @Nullable Type parent, @Nonnull ExtraInfo extraInfo) throws IOException- Throws:
IOException
-
decodeVersion
-
decodeVersion
@Nonnull protected ExtraInfo decodeVersion(@Nonnull RawJsonReader reader, @Nonnull ExtraInfo extraInfo) throws IOException - Throws:
IOException
-
validate
- Specified by:
validatein interfaceValidatableCodec<T>
-
validateDefaults
- Specified by:
validateDefaultsin interfaceValidatableCodec<T>
-
toSchema
- Specified by:
toSchemain interfaceSchemaConvertable<T>
-
toSchema
- Specified by:
toSchemain interfaceSchemaConvertable<T>
-
createSchemaFields
private static <T> void createSchemaFields(@Nonnull SchemaContext context, @Nullable T def, @Nonnull BuilderCodec<T> codec, @Nonnull Map<String, Schema> properties) -
toString
-
findEntry
@Nullable protected static <T> BuilderField<? super T,?> findEntry(@Nonnull BuilderCodec<? super T> current, String key, @Nonnull ExtraInfo extraInfo) -
findField
@Nullable protected static <T,F extends BuilderField<T, F findField?>> (@Nullable List<F> entry, @Nonnull ExtraInfo extraInfo) -
builder
-
builder
@Nonnull public static <T> BuilderCodec.Builder<T> builder(Class<T> tClass, Supplier<T> supplier, BuilderCodec<? super T> parentCodec) -
abstractBuilder
-
abstractBuilder
@Nonnull public static <T> BuilderCodec.Builder<T> abstractBuilder(Class<T> tClass, BuilderCodec<? super T> parentCodec)
-