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

net.morimekta.providence.graphql.introspection.Field Maven / Gradle / Ivy

There is a newer version: 2.7.0
Show newest version
package net.morimekta.providence.graphql.introspection;

@SuppressWarnings("unused")
@javax.annotation.Generated(
        value = "net.morimekta.providence:providence-generator-java",
        comments = "java")
@javax.annotation.concurrent.Immutable
public class Field
        implements Field_OrBuilder,
                   net.morimekta.providence.PMessage,
                   Comparable,
                   net.morimekta.providence.serializer.binary.BinaryWriter {
    private final static String kDefaultName = "";
    private final static java.util.List kDefaultArgs = new net.morimekta.providence.descriptor.PList.DefaultBuilder()
                .build();
    private final static boolean kDefaultIsDeprecated = false;

    private final transient String mName;
    private final transient String mDescription;
    private final transient java.util.List mArgs;
    private final transient net.morimekta.providence.graphql.introspection.Type mType;
    private final transient boolean mIsDeprecated;
    private final transient String mDeprecationReason;

    private volatile transient int tHashCode;

    private Field(_Builder builder) {
        if (builder.isSetName()) {
            mName = builder.mName;
        } else {
            mName = kDefaultName;
        }
        mDescription = builder.mDescription;
        if (builder.isSetArgs()) {
            mArgs = net.morimekta.util.collect.UnmodifiableList.copyOf(builder.mArgs);
        } else {
            mArgs = kDefaultArgs;
        }
        mType = builder.mType_builder != null ? builder.mType_builder.build() : builder.mType;
        mIsDeprecated = builder.mIsDeprecated;
        mDeprecationReason = builder.mDeprecationReason;
    }

    public boolean hasName() {
        return true;
    }

    /**
     * @return The name value
     */
    @javax.annotation.Nonnull
    public String getName() {
        return mName;
    }

    public boolean hasDescription() {
        return mDescription != null;
    }

    /**
     * @return The description value
     */
    public String getDescription() {
        return mDescription;
    }

    /**
     * @return Optional of the description field value.
     */
    @javax.annotation.Nonnull
    public java.util.Optional optionalDescription() {
        return java.util.Optional.ofNullable(mDescription);
    }

    public int numArgs() {
        return mArgs != null ? mArgs.size() : 0;
    }

    public boolean hasArgs() {
        return true;
    }

    /**
     * @return The args value
     */
    @javax.annotation.Nonnull
    public java.util.List getArgs() {
        return mArgs;
    }

    public boolean hasType() {
        return mType != null;
    }

    /**
     * @return The type value
     */
    public net.morimekta.providence.graphql.introspection.Type getType() {
        return mType;
    }

    /**
     * @return Optional of the type field value.
     */
    @javax.annotation.Nonnull
    public java.util.Optional optionalType() {
        return java.util.Optional.ofNullable(mType);
    }

    public boolean hasIsDeprecated() {
        return true;
    }

    /**
     * @return The isDeprecated value
     */
    public boolean isIsDeprecated() {
        return mIsDeprecated;
    }

    public boolean hasDeprecationReason() {
        return mDeprecationReason != null;
    }

    /**
     * @return The deprecationReason value
     */
    public String getDeprecationReason() {
        return mDeprecationReason;
    }

    /**
     * @return Optional of the deprecationReason field value.
     */
    @javax.annotation.Nonnull
    public java.util.Optional optionalDeprecationReason() {
        return java.util.Optional.ofNullable(mDeprecationReason);
    }

    @Override
    public boolean has(int key) {
        switch(key) {
            case 1: return true;
            case 2: return mDescription != null;
            case 3: return true;
            case 4: return mType != null;
            case 5: return true;
            case 6: return mDeprecationReason != null;
            default: return false;
        }
    }

    @Override
    @SuppressWarnings("unchecked")
    public  T get(int key) {
        switch(key) {
            case 1: return (T) mName;
            case 2: return (T) mDescription;
            case 3: return (T) mArgs;
            case 4: return (T) mType;
            case 5: return (T) (Boolean) mIsDeprecated;
            case 6: return (T) mDeprecationReason;
            default: return null;
        }
    }

    @Override
    public boolean equals(Object o) {
        if (o == this) return true;
        if (o == null || !o.getClass().equals(getClass())) return false;
        Field other = (Field) o;
        return java.util.Objects.equals(mName, other.mName) &&
               java.util.Objects.equals(mDescription, other.mDescription) &&
               java.util.Objects.equals(mArgs, other.mArgs) &&
               java.util.Objects.equals(mType, other.mType) &&
               java.util.Objects.equals(mIsDeprecated, other.mIsDeprecated) &&
               java.util.Objects.equals(mDeprecationReason, other.mDeprecationReason);
    }

    @Override
    public int hashCode() {
        if (tHashCode == 0) {
            tHashCode = java.util.Objects.hash(
                    Field.class,
                    _Field.NAME, mName,
                    _Field.DESCRIPTION, mDescription,
                    _Field.ARGS, mArgs,
                    _Field.TYPE, mType,
                    _Field.IS_DEPRECATED, mIsDeprecated,
                    _Field.DEPRECATION_REASON, mDeprecationReason);
        }
        return tHashCode;
    }

    @Override
    public String toString() {
        return "gql_introspection.__Field" + asString();
    }

    @Override
    @javax.annotation.Nonnull
    public String asString() {
        StringBuilder out = new StringBuilder();
        out.append("{");

        out.append("name:")
           .append('\"')
           .append(net.morimekta.util.Strings.escape(mName))
           .append('\"');
        if (hasDescription()) {
            out.append(',');
            out.append("description:")
               .append('\"')
               .append(net.morimekta.util.Strings.escape(mDescription))
               .append('\"');
        }
        out.append(',');
        out.append("args:")
           .append(net.morimekta.util.Strings.asString(mArgs));
        if (hasType()) {
            out.append(',');
            out.append("type:")
               .append(mType.asString());
        }
        out.append(',');
        out.append("isDeprecated:")
           .append(mIsDeprecated);
        if (hasDeprecationReason()) {
            out.append(',');
            out.append("deprecationReason:")
               .append('\"')
               .append(net.morimekta.util.Strings.escape(mDeprecationReason))
               .append('\"');
        }
        out.append('}');
        return out.toString();
    }

    @Override
    public int compareTo(Field other) {
        int c;

        c = mName.compareTo(other.mName);
        if (c != 0) return c;

        c = Boolean.compare(mDescription != null, other.mDescription != null);
        if (c != 0) return c;
        if (mDescription != null) {
            c = mDescription.compareTo(other.mDescription);
            if (c != 0) return c;
        }

        c = Integer.compare(mArgs.hashCode(), other.mArgs.hashCode());
        if (c != 0) return c;

        c = Boolean.compare(mType != null, other.mType != null);
        if (c != 0) return c;
        if (mType != null) {
            c = mType.compareTo(other.mType);
            if (c != 0) return c;
        }

        c = Boolean.compare(mIsDeprecated, other.mIsDeprecated);
        if (c != 0) return c;

        c = Boolean.compare(mDeprecationReason != null, other.mDeprecationReason != null);
        if (c != 0) return c;
        if (mDeprecationReason != null) {
            c = mDeprecationReason.compareTo(other.mDeprecationReason);
            if (c != 0) return c;
        }

        return 0;
    }

    @Override
    public int writeBinary(net.morimekta.util.io.BigEndianBinaryWriter writer) throws java.io.IOException {
        int length = 0;

        length += writer.writeByte((byte) 11);
        length += writer.writeShort((short) 1);
        net.morimekta.util.Binary tmp_1 = net.morimekta.util.Binary.wrap(mName.getBytes(java.nio.charset.StandardCharsets.UTF_8));
        length += writer.writeUInt32(tmp_1.length());
        length += writer.writeBinary(tmp_1);

        if (hasDescription()) {
            length += writer.writeByte((byte) 11);
            length += writer.writeShort((short) 2);
            net.morimekta.util.Binary tmp_2 = net.morimekta.util.Binary.wrap(mDescription.getBytes(java.nio.charset.StandardCharsets.UTF_8));
            length += writer.writeUInt32(tmp_2.length());
            length += writer.writeBinary(tmp_2);
        }

        length += writer.writeByte((byte) 15);
        length += writer.writeShort((short) 3);
        length += writer.writeByte((byte) 12);
        length += writer.writeUInt32(mArgs.size());
        for (net.morimekta.providence.graphql.introspection.InputValue entry_3 : mArgs) {
            length += net.morimekta.providence.serializer.binary.BinaryFormatUtils.writeMessage(writer, entry_3);
        }

        if (hasType()) {
            length += writer.writeByte((byte) 12);
            length += writer.writeShort((short) 4);
            length += net.morimekta.providence.serializer.binary.BinaryFormatUtils.writeMessage(writer, mType);
        }

        length += writer.writeByte((byte) 2);
        length += writer.writeShort((short) 5);
        length += writer.writeUInt8(mIsDeprecated ? (byte) 1 : (byte) 0);

        if (hasDeprecationReason()) {
            length += writer.writeByte((byte) 11);
            length += writer.writeShort((short) 6);
            net.morimekta.util.Binary tmp_4 = net.morimekta.util.Binary.wrap(mDeprecationReason.getBytes(java.nio.charset.StandardCharsets.UTF_8));
            length += writer.writeUInt32(tmp_4.length());
            length += writer.writeBinary(tmp_4);
        }

        length += writer.writeByte((byte) 0);
        return length;
    }

    @javax.annotation.Nonnull
    @Override
    public _Builder mutate() {
        return new _Builder(this);
    }

    public enum _Field implements net.morimekta.providence.descriptor.PField {
        NAME(1, net.morimekta.providence.descriptor.PRequirement.REQUIRED, "name", "name", net.morimekta.providence.descriptor.PPrimitive.STRING.provider(), null, null),
        DESCRIPTION(2, net.morimekta.providence.descriptor.PRequirement.OPTIONAL, "description", "description", net.morimekta.providence.descriptor.PPrimitive.STRING.provider(), null, null),
        ARGS(3, net.morimekta.providence.descriptor.PRequirement.REQUIRED, "args", "args", net.morimekta.providence.descriptor.PList.provider(net.morimekta.providence.graphql.introspection.InputValue.provider()), null, new net.morimekta.providence.descriptor.PDefaultValueProvider<>(kDefaultArgs)),
        TYPE(4, net.morimekta.providence.descriptor.PRequirement.REQUIRED, "type", "type", net.morimekta.providence.graphql.introspection.Type.provider(), null, null),
        IS_DEPRECATED(5, net.morimekta.providence.descriptor.PRequirement.REQUIRED, "isDeprecated", "isDeprecated", net.morimekta.providence.descriptor.PPrimitive.BOOL.provider(), null, null),
        DEPRECATION_REASON(6, net.morimekta.providence.descriptor.PRequirement.OPTIONAL, "deprecationReason", "deprecationReason", net.morimekta.providence.descriptor.PPrimitive.STRING.provider(), null, null),
        ;

        private final int mId;
        private final net.morimekta.providence.descriptor.PRequirement mRequired;
        private final String mName;
        private final String mPojoName;
        private final net.morimekta.providence.descriptor.PDescriptorProvider mTypeProvider;
        private final net.morimekta.providence.descriptor.PStructDescriptorProvider mArgumentsProvider;
        private final net.morimekta.providence.descriptor.PValueProvider mDefaultValue;

        _Field(int id, net.morimekta.providence.descriptor.PRequirement required, String name, String pojoName, net.morimekta.providence.descriptor.PDescriptorProvider typeProvider, net.morimekta.providence.descriptor.PStructDescriptorProvider argumentsProvider, net.morimekta.providence.descriptor.PValueProvider defaultValue) {
            mId = id;
            mRequired = required;
            mName = name;
            mPojoName = pojoName;
            mTypeProvider = typeProvider;
            mArgumentsProvider = argumentsProvider;
            mDefaultValue = defaultValue;
        }

        @Override
        public int getId() { return mId; }

        @javax.annotation.Nonnull
        @Override
        public net.morimekta.providence.descriptor.PRequirement getRequirement() { return mRequired; }

        @javax.annotation.Nonnull
        @Override
        public net.morimekta.providence.descriptor.PDescriptor getDescriptor() { return mTypeProvider.descriptor(); }

        @Override
        @javax.annotation.Nullable
        public net.morimekta.providence.descriptor.PStructDescriptor getArgumentsType() { return mArgumentsProvider == null ? null : mArgumentsProvider.descriptor(); }

        @javax.annotation.Nonnull
        @Override
        public String getName() { return mName; }

        @javax.annotation.Nonnull
        @Override
        public String getPojoName() { return mPojoName; }

        @Override
        public boolean hasDefaultValue() { return mDefaultValue != null; }

        @Override
        @javax.annotation.Nullable
        public Object getDefaultValue() {
            return hasDefaultValue() ? mDefaultValue.get() : null;
        }

        @Override
        public String toString() {
            return net.morimekta.providence.descriptor.PField.asString(this);
        }

        /**
         * @param id Field ID
         * @return The identified field or null
         */
        public static _Field findById(int id) {
            switch (id) {
                case 1: return _Field.NAME;
                case 2: return _Field.DESCRIPTION;
                case 3: return _Field.ARGS;
                case 4: return _Field.TYPE;
                case 5: return _Field.IS_DEPRECATED;
                case 6: return _Field.DEPRECATION_REASON;
            }
            return null;
        }

        /**
         * @param name Field name
         * @return The named field or null
         */
        public static _Field findByName(String name) {
            if (name == null) return null;
            switch (name) {
                case "name": return _Field.NAME;
                case "description": return _Field.DESCRIPTION;
                case "args": return _Field.ARGS;
                case "type": return _Field.TYPE;
                case "isDeprecated": return _Field.IS_DEPRECATED;
                case "deprecationReason": return _Field.DEPRECATION_REASON;
            }
            return null;
        }

        /**
         * @param name Field POJO name
         * @return The named field or null
         */
        public static _Field findByPojoName(String name) {
            if (name == null) return null;
            switch (name) {
                case "name": return _Field.NAME;
                case "description": return _Field.DESCRIPTION;
                case "args": return _Field.ARGS;
                case "type": return _Field.TYPE;
                case "isDeprecated": return _Field.IS_DEPRECATED;
                case "deprecationReason": return _Field.DEPRECATION_REASON;
            }
            return null;
        }

        /**
         * @param id Field ID
         * @return The identified field
         * @throws IllegalArgumentException If no such field
         */
        public static _Field fieldForId(int id) {
            _Field field = findById(id);
            if (field == null) {
                throw new IllegalArgumentException("No such field id " + id + " in gql_introspection.__Field");
            }
            return field;
        }

        /**
         * @param name Field name
         * @return The named field
         * @throws IllegalArgumentException If no such field
         */
        public static _Field fieldForName(String name) {
            if (name == null) {
                throw new IllegalArgumentException("Null name argument");
            }
            _Field field = findByName(name);
            if (field == null) {
                throw new IllegalArgumentException("No such field \"" + name + "\" in gql_introspection.__Field");
            }
            return field;
        }

        /**
         * @param name Field POJO name
         * @return The named field
         * @throws IllegalArgumentException If no such field
         */
        public static _Field fieldForPojoName(String name) {
            if (name == null) {
                throw new IllegalArgumentException("Null name argument");
            }
            _Field field = findByPojoName(name);
            if (field == null) {
                throw new IllegalArgumentException("No such field \"" + name + "\" in gql_introspection.__Field");
            }
            return field;
        }
    }

    @javax.annotation.Nonnull
    public static net.morimekta.providence.descriptor.PStructDescriptorProvider provider() {
        return new _Provider();
    }

    @Override
    @javax.annotation.Nonnull
    public net.morimekta.providence.descriptor.PStructDescriptor descriptor() {
        return kDescriptor;
    }

    public static final net.morimekta.providence.descriptor.PStructDescriptor kDescriptor;

    private static final class _Descriptor
            extends net.morimekta.providence.descriptor.PStructDescriptor {
        public _Descriptor() {
            super("gql_introspection", "__Field", _Builder::new, false);
        }

        @Override
        @javax.annotation.Nonnull
        public boolean isInnerType() {
            return false;
        }

        @Override
        @javax.annotation.Nonnull
        public boolean isAutoType() {
            return false;
        }

        @Override
        @javax.annotation.Nonnull
        public _Field[] getFields() {
            return _Field.values();
        }

        @Override
        @javax.annotation.Nullable
        public _Field findFieldByName(String name) {
            return _Field.findByName(name);
        }

        @Override
        @javax.annotation.Nullable
        public _Field findFieldByPojoName(String name) {
            return _Field.findByPojoName(name);
        }

        @Override
        @javax.annotation.Nullable
        public _Field findFieldById(int id) {
            return _Field.findById(id);
        }
    }

    static {
        kDescriptor = new _Descriptor();
    }

    private static final class _Provider extends net.morimekta.providence.descriptor.PStructDescriptorProvider {
        @Override
        public net.morimekta.providence.descriptor.PStructDescriptor descriptor() {
            return kDescriptor;
        }
    }

    /**
     * Make a gql_introspection.__Field builder.
     * @return The builder instance.
     */
    public static _Builder builder() {
        return new _Builder();
    }

    public static class _Builder
            extends net.morimekta.providence.PMessageBuilder
            implements Field_OrBuilder,
                       net.morimekta.providence.serializer.binary.BinaryReader {
        private java.util.BitSet optionals;
        private java.util.BitSet modified;

        private String mName;
        private String mDescription;
        private java.util.List mArgs;
        private net.morimekta.providence.graphql.introspection.Type mType;
        private net.morimekta.providence.graphql.introspection.Type._Builder mType_builder;
        private boolean mIsDeprecated;
        private String mDeprecationReason;

        /**
         * Make a gql_introspection.__Field builder instance.
         */
        public _Builder() {
            optionals = new java.util.BitSet(6);
            modified = new java.util.BitSet(6);
            mName = kDefaultName;
            mArgs = kDefaultArgs;
            mIsDeprecated = kDefaultIsDeprecated;
        }

        /**
         * Make a mutating builder off a base gql_introspection.__Field.
         *
         * @param base The base __Field
         */
        public _Builder(Field base) {
            this();

            optionals.set(0);
            mName = base.mName;
            if (base.hasDescription()) {
                optionals.set(1);
                mDescription = base.mDescription;
            }
            optionals.set(2);
            mArgs = base.mArgs;
            if (base.hasType()) {
                optionals.set(3);
                mType = base.mType;
            }
            optionals.set(4);
            mIsDeprecated = base.mIsDeprecated;
            if (base.hasDeprecationReason()) {
                optionals.set(5);
                mDeprecationReason = base.mDeprecationReason;
            }
        }

        @javax.annotation.Nonnull
        @Override
        public Field._Builder merge(Field from) {
            optionals.set(0);
            modified.set(0);
            mName = from.getName();

            if (from.hasDescription()) {
                optionals.set(1);
                modified.set(1);
                mDescription = from.getDescription();
            }

            optionals.set(2);
            modified.set(2);
            mArgs = from.getArgs();

            if (from.hasType()) {
                optionals.set(3);
                modified.set(3);
                if (mType_builder != null) {
                    mType_builder.merge(from.getType());
                } else if (mType != null) {
                    mType_builder = mType.mutate().merge(from.getType());
                    mType = null;
                } else {
                    mType = from.getType();
                }
            }

            optionals.set(4);
            modified.set(4);
            mIsDeprecated = from.isIsDeprecated();

            if (from.hasDeprecationReason()) {
                optionals.set(5);
                modified.set(5);
                mDeprecationReason = from.getDeprecationReason();
            }
            return this;
        }

        /**
         * Set the name field value.
         *
         * @param value The new value
         * @return The builder
         */
        @javax.annotation.Nonnull
        public Field._Builder setName(String value) {
            if (value == null) {
                return clearName();
            }

            optionals.set(0);
            modified.set(0);
            mName = value;
            return this;
        }

        /**
         * Checks for explicit presence of the name field.
         *
         * @return True if name has been set.
         */
        public boolean isSetName() {
            return optionals.get(0);
        }

        /**
         * Checks for presence of the name field.
         *
         * @return True if name is present.
         */
        public boolean hasName() {
            return true;
        }

        /**
         * Checks if the name field has been modified since the
         * builder was created.
         *
         * @return True if name has been modified.
         */
        public boolean isModifiedName() {
            return modified.get(0);
        }

        /**
         * Clear the name field.
         *
         * @return The builder
         */
        @javax.annotation.Nonnull
        public Field._Builder clearName() {
            optionals.clear(0);
            modified.set(0);
            mName = kDefaultName;
            return this;
        }

        /**
         * @return The name field value
         */
        public String getName() {
            return isSetName() ? mName : kDefaultName;
        }

        /**
         * Set the description field value.
         *
         * @param value The new value
         * @return The builder
         */
        @javax.annotation.Nonnull
        public Field._Builder setDescription(String value) {
            if (value == null) {
                return clearDescription();
            }

            optionals.set(1);
            modified.set(1);
            mDescription = value;
            return this;
        }

        /**
         * Checks for explicit presence of the description field.
         *
         * @return True if description has been set.
         */
        public boolean isSetDescription() {
            return optionals.get(1);
        }

        /**
         * Checks for presence of the description field.
         *
         * @return True if description is present.
         */
        public boolean hasDescription() {
            return optionals.get(1);
        }

        /**
         * Checks if the description field has been modified since the
         * builder was created.
         *
         * @return True if description has been modified.
         */
        public boolean isModifiedDescription() {
            return modified.get(1);
        }

        /**
         * Clear the description field.
         *
         * @return The builder
         */
        @javax.annotation.Nonnull
        public Field._Builder clearDescription() {
            optionals.clear(1);
            modified.set(1);
            mDescription = null;
            return this;
        }

        /**
         * @return The description field value
         */
        public String getDescription() {
            return mDescription;
        }

        /**
         * @return Optional description field value
         */
        @javax.annotation.Nonnull
        public java.util.Optional optionalDescription() {
            return java.util.Optional.ofNullable(mDescription);
        }

        /**
         * Set the args field value.
         *
         * @param value The new value
         * @return The builder
         */
        @javax.annotation.Nonnull
        public Field._Builder setArgs(java.util.Collection value) {
            if (value == null) {
                return clearArgs();
            }

            optionals.set(2);
            modified.set(2);
            mArgs = net.morimekta.util.collect.UnmodifiableList.copyOf(value);
            return this;
        }

        /**
         * Adds entries to the args list.
         *
         * @param values The added value
         * @return The builder
         */
        @javax.annotation.Nonnull
        public Field._Builder addToArgs(net.morimekta.providence.graphql.introspection.InputValue... values) {
            optionals.set(2);
            modified.set(2);
            java.util.List _container = mutableArgs();
            for (net.morimekta.providence.graphql.introspection.InputValue item : values) {
                _container.add(item);
            }
            return this;
        }

        /**
         * Checks for explicit presence of the args field.
         *
         * @return True if args has been set.
         */
        public boolean isSetArgs() {
            return optionals.get(2);
        }

        /**
         * Checks for presence of the args field.
         *
         * @return True if args is present.
         */
        public boolean hasArgs() {
            return true;
        }

        /**
         * Checks if the args field has been modified since the
         * builder was created.
         *
         * @return True if args has been modified.
         */
        public boolean isModifiedArgs() {
            return modified.get(2);
        }

        /**
         * Clear the args field.
         *
         * @return The builder
         */
        @javax.annotation.Nonnull
        public Field._Builder clearArgs() {
            optionals.clear(2);
            modified.set(2);
            mArgs = kDefaultArgs;
            return this;
        }

        /**
         * @return The mutable args container
         */
        public java.util.List mutableArgs() {
            optionals.set(2);
            modified.set(2);

            if (mArgs == null) {
                mArgs = new java.util.ArrayList<>();
            } else if (!(mArgs instanceof java.util.ArrayList)) {
                mArgs = new java.util.ArrayList<>(mArgs);
            }
            return mArgs;
        }

        /**
         * @return The args field value
         */
        public java.util.List getArgs() {
            return isSetArgs() ? mArgs : kDefaultArgs;
        }

        /**
         * @return Number of entries in args.
         */
        public int numArgs() {
            return mArgs != null ? mArgs.size() : 0;
        }

        /**
         * Set the type field value.
         *
         * @param value The new value
         * @return The builder
         */
        @javax.annotation.Nonnull
        public Field._Builder setType(net.morimekta.providence.graphql.introspection.Type_OrBuilder value) {
            if (value == null) {
                return clearType();
            }

            optionals.set(3);
            modified.set(3);
            if (value instanceof net.morimekta.providence.graphql.introspection.Type._Builder) {
                value = ((net.morimekta.providence.graphql.introspection.Type._Builder) value).build();
            } else if (!(value instanceof net.morimekta.providence.graphql.introspection.Type)) {
                throw new java.lang.IllegalArgumentException("Invalid type for gql_introspection.__Type: " + value.getClass().getName());
            }
            mType = (net.morimekta.providence.graphql.introspection.Type) value;
            mType_builder = null;
            return this;
        }

        /**
         * Checks for explicit presence of the type field.
         *
         * @return True if type has been set.
         */
        public boolean isSetType() {
            return optionals.get(3);
        }

        /**
         * Checks for presence of the type field.
         *
         * @return True if type is present.
         */
        public boolean hasType() {
            return optionals.get(3);
        }

        /**
         * Checks if the type field has been modified since the
         * builder was created.
         *
         * @return True if type has been modified.
         */
        public boolean isModifiedType() {
            return modified.get(3);
        }

        /**
         * Clear the type field.
         *
         * @return The builder
         */
        @javax.annotation.Nonnull
        public Field._Builder clearType() {
            optionals.clear(3);
            modified.set(3);
            mType = null;
            mType_builder = null;
            return this;
        }

        /**
         * Get the builder for the contained type message field.
         *
         * @return The field message builder
         */
        @javax.annotation.Nonnull
        public net.morimekta.providence.graphql.introspection.Type._Builder mutableType() {
            optionals.set(3);
            modified.set(3);

            if (mType != null) {
                mType_builder = mType.mutate();
                mType = null;
            } else if (mType_builder == null) {
                mType_builder = net.morimekta.providence.graphql.introspection.Type.builder();
            }
            return mType_builder;
        }

        /**
         * @return The type field value
         */
        public net.morimekta.providence.graphql.introspection.Type getType() {
            return mType_builder != null ? mType_builder.build() : mType;
        }

        /**
         * @return Optional type field value
         */
        @javax.annotation.Nonnull
        public java.util.Optional optionalType() {
            return java.util.Optional.ofNullable(mType_builder != null ? mType_builder.build() : mType);
        }

        /**
         * Set the isDeprecated field value.
         *
         * @param value The new value
         * @return The builder
         */
        @javax.annotation.Nonnull
        public Field._Builder setIsDeprecated(Boolean value) {
            if (value == null) {
                return clearIsDeprecated();
            }

            optionals.set(4);
            modified.set(4);
            mIsDeprecated = value;
            return this;
        }

        /**
         * Set the isDeprecated field value.
         *
         * @param value The new value
         * @return The builder
         */
        @javax.annotation.Nonnull
        public Field._Builder setIsDeprecated(boolean value) {
            optionals.set(4);
            modified.set(4);
            mIsDeprecated = value;
            return this;
        }

        /**
         * Checks for explicit presence of the isDeprecated field.
         *
         * @return True if isDeprecated has been set.
         */
        public boolean isSetIsDeprecated() {
            return optionals.get(4);
        }

        /**
         * Checks for presence of the isDeprecated field.
         *
         * @return True if isDeprecated is present.
         */
        public boolean hasIsDeprecated() {
            return true;
        }

        /**
         * Checks if the isDeprecated field has been modified since the
         * builder was created.
         *
         * @return True if isDeprecated has been modified.
         */
        public boolean isModifiedIsDeprecated() {
            return modified.get(4);
        }

        /**
         * Clear the isDeprecated field.
         *
         * @return The builder
         */
        @javax.annotation.Nonnull
        public Field._Builder clearIsDeprecated() {
            optionals.clear(4);
            modified.set(4);
            mIsDeprecated = kDefaultIsDeprecated;
            return this;
        }

        /**
         * @return The isDeprecated field value
         */
        public boolean isIsDeprecated() {
            return isSetIsDeprecated() ? mIsDeprecated : kDefaultIsDeprecated;
        }

        /**
         * Set the deprecationReason field value.
         *
         * @param value The new value
         * @return The builder
         */
        @javax.annotation.Nonnull
        public Field._Builder setDeprecationReason(String value) {
            if (value == null) {
                return clearDeprecationReason();
            }

            optionals.set(5);
            modified.set(5);
            mDeprecationReason = value;
            return this;
        }

        /**
         * Checks for explicit presence of the deprecationReason field.
         *
         * @return True if deprecationReason has been set.
         */
        public boolean isSetDeprecationReason() {
            return optionals.get(5);
        }

        /**
         * Checks for presence of the deprecationReason field.
         *
         * @return True if deprecationReason is present.
         */
        public boolean hasDeprecationReason() {
            return optionals.get(5);
        }

        /**
         * Checks if the deprecationReason field has been modified since the
         * builder was created.
         *
         * @return True if deprecationReason has been modified.
         */
        public boolean isModifiedDeprecationReason() {
            return modified.get(5);
        }

        /**
         * Clear the deprecationReason field.
         *
         * @return The builder
         */
        @javax.annotation.Nonnull
        public Field._Builder clearDeprecationReason() {
            optionals.clear(5);
            modified.set(5);
            mDeprecationReason = null;
            return this;
        }

        /**
         * @return The deprecationReason field value
         */
        public String getDeprecationReason() {
            return mDeprecationReason;
        }

        /**
         * @return Optional deprecationReason field value
         */
        @javax.annotation.Nonnull
        public java.util.Optional optionalDeprecationReason() {
            return java.util.Optional.ofNullable(mDeprecationReason);
        }

        @Override
        public boolean equals(Object o) {
            if (o == this) return true;
            if (o == null || !o.getClass().equals(getClass())) return false;
            Field._Builder other = (Field._Builder) o;
            return java.util.Objects.equals(optionals, other.optionals) &&
                   java.util.Objects.equals(mName, other.mName) &&
                   java.util.Objects.equals(mDescription, other.mDescription) &&
                   java.util.Objects.equals(mArgs, other.mArgs) &&
                   java.util.Objects.equals(getType(), other.getType()) &&
                   java.util.Objects.equals(mIsDeprecated, other.mIsDeprecated) &&
                   java.util.Objects.equals(mDeprecationReason, other.mDeprecationReason);
        }

        @Override
        public int hashCode() {
            return java.util.Objects.hash(
                    Field.class, optionals,
                    Field._Field.NAME, mName,
                    Field._Field.DESCRIPTION, mDescription,
                    Field._Field.ARGS, mArgs,
                    Field._Field.TYPE, getType(),
                    Field._Field.IS_DEPRECATED, mIsDeprecated,
                    Field._Field.DEPRECATION_REASON, mDeprecationReason);
        }

        @Override
        @SuppressWarnings("unchecked")
        public net.morimekta.providence.PMessageBuilder mutator(int key) {
            switch (key) {
                case 4: return mutableType();
                default: throw new IllegalArgumentException("Not a message field ID: " + key);
            }
        }

        @javax.annotation.Nonnull
        @Override
        @SuppressWarnings("unchecked")
        public Field._Builder set(int key, Object value) {
            if (value == null) return clear(key);
            switch (key) {
                case 1: setName((String) value); break;
                case 2: setDescription((String) value); break;
                case 3: setArgs((java.util.List) value); break;
                case 4: setType((net.morimekta.providence.graphql.introspection.Type) value); break;
                case 5: setIsDeprecated((boolean) value); break;
                case 6: setDeprecationReason((String) value); break;
                default: break;
            }
            return this;
        }

        @Override
        public boolean isSet(int key) {
            switch (key) {
                case 1: return optionals.get(0);
                case 2: return optionals.get(1);
                case 3: return optionals.get(2);
                case 4: return optionals.get(3);
                case 5: return optionals.get(4);
                case 6: return optionals.get(5);
                default: break;
            }
            return false;
        }

        @Override
        public boolean isModified(int key) {
            switch (key) {
                case 1: return modified.get(0);
                case 2: return modified.get(1);
                case 3: return modified.get(2);
                case 4: return modified.get(3);
                case 5: return modified.get(4);
                case 6: return modified.get(5);
                default: break;
            }
            return false;
        }

        @Override
        @SuppressWarnings("unchecked")
        public  T get(int key) {
            switch(key) {
                case 1: return (T) getName();
                case 2: return (T) getDescription();
                case 3: return (T) getArgs();
                case 4: return (T) getType();
                case 5: return (T) (Object) isIsDeprecated();
                case 6: return (T) getDeprecationReason();
                default: return null;
            }
        }

        @Override
        public boolean has(int key) {
            switch(key) {
                case 1: return true;
                case 2: return mDescription != null;
                case 3: return true;
                case 4: return mType != null || mType_builder != null;
                case 5: return true;
                case 6: return mDeprecationReason != null;
                default: return false;
            }
        }

        @javax.annotation.Nonnull
        @Override
        @SuppressWarnings("unchecked")
        public Field._Builder addTo(int key, Object value) {
            switch (key) {
                case 3: addToArgs((net.morimekta.providence.graphql.introspection.InputValue) value); break;
                default: break;
            }
            return this;
        }

        @javax.annotation.Nonnull
        @Override
        public Field._Builder clear(int key) {
            switch (key) {
                case 1: clearName(); break;
                case 2: clearDescription(); break;
                case 3: clearArgs(); break;
                case 4: clearType(); break;
                case 5: clearIsDeprecated(); break;
                case 6: clearDeprecationReason(); break;
                default: break;
            }
            return this;
        }

        @Override
        public boolean valid() {
            return optionals.get(0) &&
                   optionals.get(2) &&
                   optionals.get(3) &&
                   optionals.get(4);
        }

        @Override
        public Field._Builder validate() {
            if (!valid()) {
                java.util.ArrayList missing = new java.util.ArrayList<>();

                if (!optionals.get(0)) {
                    missing.add("name");
                }

                if (!optionals.get(2)) {
                    missing.add("args");
                }

                if (!optionals.get(3)) {
                    missing.add("type");
                }

                if (!optionals.get(4)) {
                    missing.add("isDeprecated");
                }

                throw new java.lang.IllegalStateException(
                        "Missing required fields " +
                        String.join(",", missing) +
                        " in message gql_introspection.__Field");
            }
            return this;
        }

        @javax.annotation.Nonnull
        @Override
        public net.morimekta.providence.descriptor.PStructDescriptor descriptor() {
            return Field.kDescriptor;
        }

        @Override
        public void readBinary(net.morimekta.util.io.BigEndianBinaryReader reader, boolean strict) throws java.io.IOException {
            byte type = reader.expectByte();
            while (type != 0) {
                int field = reader.expectShort();
                switch (field) {
                    case 1: {
                        if (type == 11) {
                            int len_1 = reader.expectUInt32();
                            mName = new String(reader.expectBytes(len_1), java.nio.charset.StandardCharsets.UTF_8);
                            optionals.set(0);
                        } else {
                            throw new net.morimekta.providence.serializer.SerializerException("Wrong type " + net.morimekta.providence.serializer.binary.BinaryType.asString(type) + " for gql_introspection.__Field.name, should be struct(12)");
                        }
                        break;
                    }
                    case 2: {
                        if (type == 11) {
                            int len_2 = reader.expectUInt32();
                            mDescription = new String(reader.expectBytes(len_2), java.nio.charset.StandardCharsets.UTF_8);
                            optionals.set(1);
                        } else {
                            throw new net.morimekta.providence.serializer.SerializerException("Wrong type " + net.morimekta.providence.serializer.binary.BinaryType.asString(type) + " for gql_introspection.__Field.description, should be struct(12)");
                        }
                        break;
                    }
                    case 3: {
                        if (type == 15) {
                            byte t_5 = reader.expectByte();
                            if (t_5 == 12) {
                                final int len_4 = reader.expectUInt32();
                                net.morimekta.util.collect.UnmodifiableList.Builder b_3 = net.morimekta.util.collect.UnmodifiableList.builder(len_4);
                                for (int i_6 = 0; i_6 < len_4; ++i_6) {
                                    net.morimekta.providence.graphql.introspection.InputValue key_7 = net.morimekta.providence.serializer.binary.BinaryFormatUtils.readMessage(reader, net.morimekta.providence.graphql.introspection.InputValue.kDescriptor, strict);
                                    b_3.add(key_7);
                                }
                                mArgs = b_3.build();
                            } else {
                                throw new net.morimekta.providence.serializer.SerializerException("Wrong item type " + net.morimekta.providence.serializer.binary.BinaryType.asString(t_5) + " for gql_introspection.__Field.args, should be struct(12)");
                            }
                            optionals.set(2);
                        } else {
                            throw new net.morimekta.providence.serializer.SerializerException("Wrong type " + net.morimekta.providence.serializer.binary.BinaryType.asString(type) + " for gql_introspection.__Field.args, should be struct(12)");
                        }
                        break;
                    }
                    case 4: {
                        if (type == 12) {
                            mType = net.morimekta.providence.serializer.binary.BinaryFormatUtils.readMessage(reader, net.morimekta.providence.graphql.introspection.Type.kDescriptor, strict);
                            optionals.set(3);
                        } else {
                            throw new net.morimekta.providence.serializer.SerializerException("Wrong type " + net.morimekta.providence.serializer.binary.BinaryType.asString(type) + " for gql_introspection.__Field.type, should be struct(12)");
                        }
                        break;
                    }
                    case 5: {
                        if (type == 2) {
                            mIsDeprecated = reader.expectUInt8() == 1;
                            optionals.set(4);
                        } else {
                            throw new net.morimekta.providence.serializer.SerializerException("Wrong type " + net.morimekta.providence.serializer.binary.BinaryType.asString(type) + " for gql_introspection.__Field.isDeprecated, should be struct(12)");
                        }
                        break;
                    }
                    case 6: {
                        if (type == 11) {
                            int len_8 = reader.expectUInt32();
                            mDeprecationReason = new String(reader.expectBytes(len_8), java.nio.charset.StandardCharsets.UTF_8);
                            optionals.set(5);
                        } else {
                            throw new net.morimekta.providence.serializer.SerializerException("Wrong type " + net.morimekta.providence.serializer.binary.BinaryType.asString(type) + " for gql_introspection.__Field.deprecationReason, should be struct(12)");
                        }
                        break;
                    }
                    default: {
                        net.morimekta.providence.serializer.binary.BinaryFormatUtils.readFieldValue(reader, new net.morimekta.providence.serializer.binary.BinaryFormatUtils.FieldInfo(field, type), null, false);
                        break;
                    }
                }
                type = reader.expectByte();
            }
        }

        @Override
        @javax.annotation.Nonnull
        public Field build() {
            return new Field(this);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy