All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.everit.json.schema.ConstSchema Maven / Gradle / Ivy

Go to download

Implementation of the JSON Schema Core Draft v4 specification built with the org.json API

There is a newer version: 1.14.4
Show newest version
package org.everit.json.schema;

import static org.everit.json.schema.EnumSchema.toJavaValue;

import org.everit.json.schema.internal.JSONPrinter;

public class ConstSchema extends Schema {

    public static class ConstSchemaBuilder extends Schema.Builder {

        private Object permittedValue;

        public ConstSchemaBuilder permittedValue(Object permittedValue) {
            this.permittedValue = permittedValue;
            return this;
        }

        @Override public ConstSchema build() {
            return new ConstSchema(this);
        }
    }

    public static ConstSchemaBuilder builder() {
        return new ConstSchemaBuilder();
    }

    private final Object permittedValue;

    protected ConstSchema(ConstSchemaBuilder builder) {
        super(builder);
        this.permittedValue = toJavaValue(builder.permittedValue);
    }

    @Override void describePropertiesTo(JSONPrinter writer) {
        writer.key("const");
        writer.value(this.permittedValue);
    }

    @Override void accept(Visitor visitor) {
        visitor.visitConstSchema(this);
    }

    public Object getPermittedValue() {
        return permittedValue;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy