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

net.morimekta.providence.graphql.introspection.EnumValue 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 EnumValue
        implements EnumValue_OrBuilder,
                   net.morimekta.providence.PMessage,
                   Comparable,
                   net.morimekta.providence.serializer.binary.BinaryWriter {
    private final static String kDefaultName = "";
    private final static boolean kDefaultIsDeprecated = false;

    private final transient String mName;
    private final transient String mDescription;
    private final transient boolean mIsDeprecated;
    private final transient String mDeprecationReason;

    private volatile transient int tHashCode;

    public EnumValue(String pName,
                     String pDescription,
                     boolean pIsDeprecated,
                     String pDeprecationReason) {
        if (pName != null) {
            mName = pName;
        } else {
            mName = kDefaultName;
        }
        mDescription = pDescription;
        mIsDeprecated = pIsDeprecated;
        mDeprecationReason = pDeprecationReason;
    }

    private EnumValue(_Builder builder) {
        if (builder.isSetName()) {
            mName = builder.mName;
        } else {
            mName = kDefaultName;
        }
        mDescription = builder.mDescription;
        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 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 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) (Boolean) mIsDeprecated;
            case 4: 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;
        EnumValue other = (EnumValue) o;
        return java.util.Objects.equals(mName, other.mName) &&
               java.util.Objects.equals(mDescription, other.mDescription) &&
               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(
                    EnumValue.class,
                    _Field.NAME, mName,
                    _Field.DESCRIPTION, mDescription,
                    _Field.IS_DEPRECATED, mIsDeprecated,
                    _Field.DEPRECATION_REASON, mDeprecationReason);
        }
        return tHashCode;
    }

    @Override
    public String toString() {
        return "gql_introspection.__EnumValue" + 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("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(EnumValue 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 = 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) 2);
        length += writer.writeShort((short) 3);
        length += writer.writeUInt8(mIsDeprecated ? (byte) 1 : (byte) 0);

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

        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),
        IS_DEPRECATED(3, net.morimekta.providence.descriptor.PRequirement.REQUIRED, "isDeprecated", "isDeprecated", net.morimekta.providence.descriptor.PPrimitive.BOOL.provider(), null, null),
        DEPRECATION_REASON(4, 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.IS_DEPRECATED;
                case 4: 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 "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 "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.__EnumValue");
            }
            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.__EnumValue");
            }
            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.__EnumValue");
            }
            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", "__EnumValue", _Builder::new, true);
        }

        @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.__EnumValue builder.
     * @return The builder instance.
     */
    public static _Builder builder() {
        return new _Builder();
    }

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

        private String mName;
        private String mDescription;
        private boolean mIsDeprecated;
        private String mDeprecationReason;

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

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

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

        @javax.annotation.Nonnull
        @Override
        public EnumValue._Builder merge(EnumValue 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);
            mIsDeprecated = from.isIsDeprecated();

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

        /**
         * Set the name field value.
         *
         * @param value The new value
         * @return The builder
         */
        @javax.annotation.Nonnull
        public EnumValue._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 EnumValue._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 EnumValue._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 EnumValue._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 isDeprecated field value.
         *
         * @param value The new value
         * @return The builder
         */
        @javax.annotation.Nonnull
        public EnumValue._Builder setIsDeprecated(Boolean value) {
            if (value == null) {
                return clearIsDeprecated();
            }

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

        /**
         * Set the isDeprecated field value.
         *
         * @param value The new value
         * @return The builder
         */
        @javax.annotation.Nonnull
        public EnumValue._Builder setIsDeprecated(boolean value) {
            optionals.set(2);
            modified.set(2);
            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(2);
        }

        /**
         * 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(2);
        }

        /**
         * Clear the isDeprecated field.
         *
         * @return The builder
         */
        @javax.annotation.Nonnull
        public EnumValue._Builder clearIsDeprecated() {
            optionals.clear(2);
            modified.set(2);
            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 EnumValue._Builder setDeprecationReason(String value) {
            if (value == null) {
                return clearDeprecationReason();
            }

            optionals.set(3);
            modified.set(3);
            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(3);
        }

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

        /**
         * 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(3);
        }

        /**
         * Clear the deprecationReason field.
         *
         * @return The builder
         */
        @javax.annotation.Nonnull
        public EnumValue._Builder clearDeprecationReason() {
            optionals.clear(3);
            modified.set(3);
            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;
            EnumValue._Builder other = (EnumValue._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(mIsDeprecated, other.mIsDeprecated) &&
                   java.util.Objects.equals(mDeprecationReason, other.mDeprecationReason);
        }

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

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

        @javax.annotation.Nonnull
        @Override
        @SuppressWarnings("unchecked")
        public EnumValue._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: setIsDeprecated((boolean) value); break;
                case 4: 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);
                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);
                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) (Object) isIsDeprecated();
                case 4: 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 mDeprecationReason != null;
                default: return false;
            }
        }

        @javax.annotation.Nonnull
        @Override
        @SuppressWarnings("unchecked")
        public EnumValue._Builder addTo(int key, Object value) {
            switch (key) {
                default: break;
            }
            return this;
        }

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

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

        @Override
        public EnumValue._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("isDeprecated");
                }

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

        @javax.annotation.Nonnull
        @Override
        public net.morimekta.providence.descriptor.PStructDescriptor descriptor() {
            return EnumValue.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.__EnumValue.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.__EnumValue.description, should be struct(12)");
                        }
                        break;
                    }
                    case 3: {
                        if (type == 2) {
                            mIsDeprecated = reader.expectUInt8() == 1;
                            optionals.set(2);
                        } else {
                            throw new net.morimekta.providence.serializer.SerializerException("Wrong type " + net.morimekta.providence.serializer.binary.BinaryType.asString(type) + " for gql_introspection.__EnumValue.isDeprecated, should be struct(12)");
                        }
                        break;
                    }
                    case 4: {
                        if (type == 11) {
                            int len_3 = reader.expectUInt32();
                            mDeprecationReason = new String(reader.expectBytes(len_3), java.nio.charset.StandardCharsets.UTF_8);
                            optionals.set(3);
                        } else {
                            throw new net.morimekta.providence.serializer.SerializerException("Wrong type " + net.morimekta.providence.serializer.binary.BinaryType.asString(type) + " for gql_introspection.__EnumValue.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 EnumValue build() {
            return new EnumValue(this);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy