ArraySchema.java
package com.hypixel.hytale.codec.schema.config;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.ExtraInfo;
import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.codec.codecs.array.ArrayCodec;
import com.hypixel.hytale.codec.schema.SchemaContext;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.bson.BsonValue;
public class ArraySchema extends Schema {
public static final BuilderCodec<ArraySchema> CODEC;
private Object items;
private Integer minItems;
private Integer maxItems;
private Boolean uniqueItems;
public ArraySchema() {
}
public ArraySchema(Schema item) {
this.setItem(item);
}
@Nullable
public Object getItems() {
return this.items;
}
public void setItem {
.items = items;
}
{
.items = items;
}
Integer {
.minItems;
}
{
.minItems = minItems;
}
Integer {
.maxItems;
}
{
.maxItems = maxItems;
}
{
.uniqueItems;
}
{
.uniqueItems = uniqueItems;
}
{
( == o) {
;
} (o != && .getClass() == o.getClass()) {
(!.equals(o)) {
;
} {
(ArraySchema)o;
(.items != ) {
(!.items.equals(that.items)) {
;
}
} (that.items != ) {
;
}
(.minItems != ) {
(!.minItems.equals(that.minItems)) {
;
}
} (that.minItems != ) {
;
}
(.maxItems != ) {
(!.maxItems.equals(that.maxItems)) {
;
}
} (that.maxItems != ) {
;
}
.uniqueItems != ? .uniqueItems.equals(that.uniqueItems) : that.uniqueItems == ;
}
} {
;
}
}
{
.hashCode();
result = * result + (.items != ? .items.hashCode() : );
result = * result + (.minItems != ? .minItems.hashCode() : );
result = * result + (.maxItems != ? .maxItems.hashCode() : );
result = * result + (.uniqueItems != ? .uniqueItems.hashCode() : );
result;
}
{
CODEC = ((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(ArraySchema.class, ArraySchema::, Schema.BASE_CODEC).addField( (, (), , ), (o, i) -> o.items = i, (o) -> o.items)).addField( (, Codec.INTEGER, , ), (o, i) -> o.minItems = i, (o) -> o.minItems)).addField( (, Codec.INTEGER, , ), (o, i) -> o.maxItems = i, (o) -> o.maxItems)).addField( (, Codec.BOOLEAN, , ), (o, i) -> o.uniqueItems = i, (o) -> o.uniqueItems)).build();
}
<Object> {
ArrayCodec<Schema> array;
{
.array = <Schema>(Schema.CODEC, (x$) -> [x$]);
}
Object {
bsonValue.isArray() ? .array.decode(bsonValue, extraInfo) : Schema.CODEC.decode(bsonValue, extraInfo);
}
BsonValue {
o Schema[] ? .array.encode((Schema[])o, extraInfo) : Schema.CODEC.encode((Schema)o, extraInfo);
}
Schema {
Schema.anyOf(Schema.CODEC.toSchema(context), .array.toSchema(context));
}
}
}