// 
// Decompiled by Procyon v0.6.0
// 

package com.hypixel.hytale.codec.schema.config;

import com.hypixel.hytale.codec.schema.SchemaContext;
import com.hypixel.hytale.codec.ExtraInfo;
import org.bson.BsonValue;
import javax.annotation.Nonnull;
import com.hypixel.hytale.codec.codecs.array.ArrayCodec;
import com.hypixel.hytale.codec.Codec;
import javax.annotation.Nullable;
import com.hypixel.hytale.codec.builder.BuilderCodec;

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(final Schema item) {
        this.setItem(item);
    }
    
    @Nullable
    public Object getItems() {
        return this.items;
    }
    
    public void setItem(final Schema items) {
        this.items = items;
    }
    
    public void setItems(final Schema... items) {
        this.items = items;
    }
    
    @Nullable
    public Integer getMinItems() {
        return this.minItems;
    }
    
    public void setMinItems(final Integer minItems) {
        this.minItems = minItems;
    }
    
    @Nullable
    public Integer getMaxItems() {
        return this.maxItems;
    }
    
    public void setMaxItems(final Integer maxItems) {
        this.maxItems = maxItems;
    }
    
    public boolean getUniqueItems() {
        return this.uniqueItems;
    }
    
    public void setUniqueItems(final boolean uniqueItems) {
        this.uniqueItems = uniqueItems;
    }
    
    @Override
    public boolean equals(@Nullable final Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || this.getClass() != o.getClass()) {
            return false;
        }
        if (!super.equals(o)) {
            return false;
        }
        final ArraySchema that = (ArraySchema)o;
        Label_0072: {
            if (this.items != null) {
                if (this.items.equals(that.items)) {
                    break Label_0072;
                }
            }
            else if (that.items == null) {
                break Label_0072;
            }
            return false;
        }
        Label_0105: {
            if (this.minItems != null) {
                if (this.minItems.equals(that.minItems)) {
                    break Label_0105;
                }
            }
            else if (that.minItems == null) {
                break Label_0105;
            }
            return false;
        }
        if (this.maxItems != null) {
            if (this.maxItems.equals(that.maxItems)) {
                return (this.uniqueItems != null) ? this.uniqueItems.equals(that.uniqueItems) : (that.uniqueItems == null);
            }
        }
        else if (that.maxItems == null) {
            return (this.uniqueItems != null) ? this.uniqueItems.equals(that.uniqueItems) : (that.uniqueItems == null);
        }
        return false;
    }
    
    @Override
    public int hashCode() {
        int result = super.hashCode();
        result = 31 * result + ((this.items != null) ? this.items.hashCode() : 0);
        result = 31 * result + ((this.minItems != null) ? this.minItems.hashCode() : 0);
        result = 31 * result + ((this.maxItems != null) ? this.maxItems.hashCode() : 0);
        result = 31 * result + ((this.uniqueItems != null) ? this.uniqueItems.hashCode() : 0);
        return result;
    }
    
    static {
        // 
        // This method could not be decompiled.
        // 
        // Original Bytecode:
        // 
        //     2: invokedynamic   BootstrapMethod #0, get:()Ljava/util/function/Supplier;
        //     7: getstatic       com/hypixel/hytale/codec/schema/config/Schema.BASE_CODEC:Lcom/hypixel/hytale/codec/builder/BuilderCodec;
        //    10: invokestatic    com/hypixel/hytale/codec/builder/BuilderCodec.builder:(Ljava/lang/Class;Ljava/util/function/Supplier;Lcom/hypixel/hytale/codec/builder/BuilderCodec;)Lcom/hypixel/hytale/codec/builder/BuilderCodec$Builder;
        //    13: new             Lcom/hypixel/hytale/codec/KeyedCodec;
        //    16: dup            
        //    17: ldc             "items"
        //    19: new             Lcom/hypixel/hytale/codec/schema/config/ArraySchema$ItemOrItems;
        //    22: dup            
        //    23: invokespecial   com/hypixel/hytale/codec/schema/config/ArraySchema$ItemOrItems.<init>:()V
        //    26: iconst_0       
        //    27: iconst_1       
        //    28: invokespecial   com/hypixel/hytale/codec/KeyedCodec.<init>:(Ljava/lang/String;Lcom/hypixel/hytale/codec/Codec;ZZ)V
        //    31: invokedynamic   BootstrapMethod #1, accept:()Ljava/util/function/BiConsumer;
        //    36: invokedynamic   BootstrapMethod #2, apply:()Ljava/util/function/Function;
        //    41: invokevirtual   com/hypixel/hytale/codec/builder/BuilderCodec$Builder.addField:(Lcom/hypixel/hytale/codec/KeyedCodec;Ljava/util/function/BiConsumer;Ljava/util/function/Function;)Lcom/hypixel/hytale/codec/builder/BuilderCodec$BuilderBase;
        //    44: checkcast       Lcom/hypixel/hytale/codec/builder/BuilderCodec$Builder;
        //    47: new             Lcom/hypixel/hytale/codec/KeyedCodec;
        //    50: dup            
        //    51: ldc             "minItems"
        //    53: getstatic       com/hypixel/hytale/codec/Codec.INTEGER:Lcom/hypixel/hytale/codec/codecs/simple/IntegerCodec;
        //    56: iconst_0       
        //    57: iconst_1       
        //    58: invokespecial   com/hypixel/hytale/codec/KeyedCodec.<init>:(Ljava/lang/String;Lcom/hypixel/hytale/codec/Codec;ZZ)V
        //    61: invokedynamic   BootstrapMethod #3, accept:()Ljava/util/function/BiConsumer;
        //    66: invokedynamic   BootstrapMethod #4, apply:()Ljava/util/function/Function;
        //    71: invokevirtual   com/hypixel/hytale/codec/builder/BuilderCodec$Builder.addField:(Lcom/hypixel/hytale/codec/KeyedCodec;Ljava/util/function/BiConsumer;Ljava/util/function/Function;)Lcom/hypixel/hytale/codec/builder/BuilderCodec$BuilderBase;
        //    74: checkcast       Lcom/hypixel/hytale/codec/builder/BuilderCodec$Builder;
        //    77: new             Lcom/hypixel/hytale/codec/KeyedCodec;
        //    80: dup            
        //    81: ldc             "maxItems"
        //    83: getstatic       com/hypixel/hytale/codec/Codec.INTEGER:Lcom/hypixel/hytale/codec/codecs/simple/IntegerCodec;
        //    86: iconst_0       
        //    87: iconst_1       
        //    88: invokespecial   com/hypixel/hytale/codec/KeyedCodec.<init>:(Ljava/lang/String;Lcom/hypixel/hytale/codec/Codec;ZZ)V
        //    91: invokedynamic   BootstrapMethod #5, accept:()Ljava/util/function/BiConsumer;
        //    96: invokedynamic   BootstrapMethod #6, apply:()Ljava/util/function/Function;
        //   101: invokevirtual   com/hypixel/hytale/codec/builder/BuilderCodec$Builder.addField:(Lcom/hypixel/hytale/codec/KeyedCodec;Ljava/util/function/BiConsumer;Ljava/util/function/Function;)Lcom/hypixel/hytale/codec/builder/BuilderCodec$BuilderBase;
        //   104: checkcast       Lcom/hypixel/hytale/codec/builder/BuilderCodec$Builder;
        //   107: new             Lcom/hypixel/hytale/codec/KeyedCodec;
        //   110: dup            
        //   111: ldc             "uniqueItems"
        //   113: getstatic       com/hypixel/hytale/codec/Codec.BOOLEAN:Lcom/hypixel/hytale/codec/codecs/simple/BooleanCodec;
        //   116: iconst_0       
        //   117: iconst_1       
        //   118: invokespecial   com/hypixel/hytale/codec/KeyedCodec.<init>:(Ljava/lang/String;Lcom/hypixel/hytale/codec/Codec;ZZ)V
        //   121: invokedynamic   BootstrapMethod #7, accept:()Ljava/util/function/BiConsumer;
        //   126: invokedynamic   BootstrapMethod #8, apply:()Ljava/util/function/Function;
        //   131: invokevirtual   com/hypixel/hytale/codec/builder/BuilderCodec$Builder.addField:(Lcom/hypixel/hytale/codec/KeyedCodec;Ljava/util/function/BiConsumer;Ljava/util/function/Function;)Lcom/hypixel/hytale/codec/builder/BuilderCodec$BuilderBase;
        //   134: checkcast       Lcom/hypixel/hytale/codec/builder/BuilderCodec$Builder;
        //   137: invokevirtual   com/hypixel/hytale/codec/builder/BuilderCodec$Builder.build:()Lcom/hypixel/hytale/codec/builder/BuilderCodec;
        //   140: putstatic       com/hypixel/hytale/codec/schema/config/ArraySchema.CODEC:Lcom/hypixel/hytale/codec/builder/BuilderCodec;
        //   143: return         
        // 
        // The error that occurred was:
        // 
        // java.lang.UnsupportedOperationException: The requested operation is not supported.
        //     at com.strobel.util.ContractUtils.unsupported(ContractUtils.java:27)
        //     at com.strobel.assembler.metadata.TypeReference.getRawType(TypeReference.java:284)
        //     at com.strobel.assembler.metadata.TypeReference.getRawType(TypeReference.java:279)
        //     at com.strobel.assembler.metadata.TypeReference.makeGenericType(TypeReference.java:154)
        //     at com.strobel.assembler.metadata.TypeSubstitutionVisitor.visitParameterizedType(TypeSubstitutionVisitor.java:225)
        //     at com.strobel.assembler.metadata.TypeSubstitutionVisitor.visitParameterizedType(TypeSubstitutionVisitor.java:25)
        //     at com.strobel.assembler.metadata.ParameterizedType.accept(ParameterizedType.java:103)
        //     at com.strobel.assembler.metadata.TypeSubstitutionVisitor.visit(TypeSubstitutionVisitor.java:40)
        //     at com.strobel.assembler.metadata.TypeSubstitutionVisitor.visitMethod(TypeSubstitutionVisitor.java:314)
        //     at com.strobel.decompiler.ast.TypeAnalysis.inferCall(TypeAnalysis.java:2611)
        //     at com.strobel.decompiler.ast.TypeAnalysis.doInferTypeForExpression(TypeAnalysis.java:1040)
        //     at com.strobel.decompiler.ast.TypeAnalysis.inferTypeForExpression(TypeAnalysis.java:815)
        //     at com.strobel.decompiler.ast.TypeAnalysis.inferTypeForExpression(TypeAnalysis.java:782)
        //     at com.strobel.decompiler.ast.TypeAnalysis.inferTypeForExpression(TypeAnalysis.java:778)
        //     at com.strobel.decompiler.ast.TypeAnalysis.doInferTypeForExpression(TypeAnalysis.java:1510)
        //     at com.strobel.decompiler.ast.TypeAnalysis.inferTypeForExpression(TypeAnalysis.java:815)
        //     at com.strobel.decompiler.ast.TypeAnalysis.inferTypeForExpression(TypeAnalysis.java:790)
        //     at com.strobel.decompiler.ast.TypeAnalysis.inferCall(TypeAnalysis.java:2689)
        //     at com.strobel.decompiler.ast.TypeAnalysis.doInferTypeForExpression(TypeAnalysis.java:1040)
        //     at com.strobel.decompiler.ast.TypeAnalysis.inferTypeForExpression(TypeAnalysis.java:815)
        //     at com.strobel.decompiler.ast.TypeAnalysis.inferTypeForExpression(TypeAnalysis.java:782)
        //     at com.strobel.decompiler.ast.TypeAnalysis.inferTypeForExpression(TypeAnalysis.java:778)
        //     at com.strobel.decompiler.ast.TypeAnalysis.doInferTypeForExpression(TypeAnalysis.java:1510)
        //     at com.strobel.decompiler.ast.TypeAnalysis.inferTypeForExpression(TypeAnalysis.java:815)
        //     at com.strobel.decompiler.ast.TypeAnalysis.inferTypeForExpression(TypeAnalysis.java:790)
        //     at com.strobel.decompiler.ast.TypeAnalysis.inferCall(TypeAnalysis.java:2689)
        //     at com.strobel.decompiler.ast.TypeAnalysis.doInferTypeForExpression(TypeAnalysis.java:1040)
        //     at com.strobel.decompiler.ast.TypeAnalysis.inferTypeForExpression(TypeAnalysis.java:815)
        //     at com.strobel.decompiler.ast.TypeAnalysis.inferTypeForExpression(TypeAnalysis.java:782)
        //     at com.strobel.decompiler.ast.TypeAnalysis.inferTypeForExpression(TypeAnalysis.java:778)
        //     at com.strobel.decompiler.ast.TypeAnalysis.doInferTypeForExpression(TypeAnalysis.java:1083)
        //     at com.strobel.decompiler.ast.TypeAnalysis.inferTypeForExpression(TypeAnalysis.java:815)
        //     at com.strobel.decompiler.ast.TypeAnalysis.runInference(TypeAnalysis.java:684)
        //     at com.strobel.decompiler.ast.TypeAnalysis.runInference(TypeAnalysis.java:667)
        //     at com.strobel.decompiler.ast.TypeAnalysis.runInference(TypeAnalysis.java:373)
        //     at com.strobel.decompiler.ast.TypeAnalysis.run(TypeAnalysis.java:95)
        //     at com.strobel.decompiler.ast.AstOptimizer.optimize(AstOptimizer.java:344)
        //     at com.strobel.decompiler.ast.AstOptimizer.optimize(AstOptimizer.java:42)
        //     at com.strobel.decompiler.languages.java.ast.AstMethodBodyBuilder.createMethodBody(AstMethodBodyBuilder.java:206)
        //     at com.strobel.decompiler.languages.java.ast.AstMethodBodyBuilder.createMethodBody(AstMethodBodyBuilder.java:93)
        //     at com.strobel.decompiler.languages.java.ast.AstBuilder.createMethodBody(AstBuilder.java:868)
        //     at com.strobel.decompiler.languages.java.ast.AstBuilder.createMethod(AstBuilder.java:761)
        //     at com.strobel.decompiler.languages.java.ast.AstBuilder.addTypeMembers(AstBuilder.java:638)
        //     at com.strobel.decompiler.languages.java.ast.AstBuilder.createTypeCore(AstBuilder.java:605)
        //     at com.strobel.decompiler.languages.java.ast.AstBuilder.createTypeNoCache(AstBuilder.java:195)
        //     at com.strobel.decompiler.languages.java.ast.AstBuilder.createType(AstBuilder.java:162)
        //     at com.strobel.decompiler.languages.java.ast.AstBuilder.addType(AstBuilder.java:137)
        //     at com.strobel.decompiler.languages.java.JavaLanguage.buildAst(JavaLanguage.java:71)
        //     at com.strobel.decompiler.languages.java.JavaLanguage.decompileType(JavaLanguage.java:59)
        //     at com.strobel.decompiler.DecompilerDriver.decompileType(DecompilerDriver.java:333)
        //     at com.strobel.decompiler.DecompilerDriver.decompileJar(DecompilerDriver.java:254)
        //     at com.strobel.decompiler.DecompilerDriver.main(DecompilerDriver.java:129)
        // 
        throw new IllegalStateException("An error occurred while decompiling this method.");
    }
    
    @Deprecated
    private static class ItemOrItems implements Codec<Object>
    {
        @Nonnull
        private ArrayCodec<Schema> array;
        
        private ItemOrItems() {
            this.array = new ArrayCodec<Schema>((Codec<Schema>)Schema.CODEC, Schema[]::new);
        }
        
        @Override
        public Object decode(@Nonnull final BsonValue bsonValue, @Nonnull final ExtraInfo extraInfo) {
            if (bsonValue.isArray()) {
                return this.array.decode(bsonValue, extraInfo);
            }
            return Schema.CODEC.decode(bsonValue, extraInfo);
        }
        
        @Override
        public BsonValue encode(final Object o, final ExtraInfo extraInfo) {
            if (o instanceof final Schema[]array) {
                return this.array.encode(array, extraInfo);
            }
            return Schema.CODEC.encode((Schema)o, extraInfo);
        }
        
        @Nonnull
        @Override
        public Schema toSchema(@Nonnull final SchemaContext context) {
            return Schema.anyOf(Schema.CODEC.toSchema(context), this.array.toSchema(context));
        }
    }
}
