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

net.morimekta.providence.graphql.directives.SkipArguments Maven / Gradle / Ivy

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

@SuppressWarnings("unused")
@javax.annotation.Generated(
        value = "net.morimekta.providence:providence-generator-java",
        comments = "java")
@javax.annotation.concurrent.Immutable
public class SkipArguments
        implements SkipArguments_OrBuilder,
                   net.morimekta.providence.PMessage,
                   Comparable,
                   net.morimekta.providence.serializer.binary.BinaryWriter {
    private final static boolean kDefaultIf = false;

    private final transient boolean mIf;

    private volatile transient int tHashCode;

    private SkipArguments(_Builder builder) {
        mIf = builder.mIf;
    }

    public boolean hasIf() {
        return true;
    }

    /**
     * @return The if value
     */
    public boolean isIf() {
        return mIf;
    }

    @Override
    public boolean has(int key) {
        switch(key) {
            case 1: return true;
            default: return false;
        }
    }

    @Override
    @SuppressWarnings("unchecked")
    public  T get(int key) {
        switch(key) {
            case 1: return (T) (Boolean) mIf;
            default: return null;
        }
    }

    @Override
    public boolean equals(Object o) {
        if (o == this) return true;
        if (o == null || !o.getClass().equals(getClass())) return false;
        SkipArguments other = (SkipArguments) o;
        return java.util.Objects.equals(mIf, other.mIf);
    }

    @Override
    public int hashCode() {
        if (tHashCode == 0) {
            tHashCode = java.util.Objects.hash(
                    SkipArguments.class,
                    _Field.IF, mIf);
        }
        return tHashCode;
    }

    @Override
    public String toString() {
        return "gql_directives.SkipArguments" + asString();
    }

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

        out.append("if:")
           .append(mIf);
        out.append('}');
        return out.toString();
    }

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

        c = Boolean.compare(mIf, other.mIf);
        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) 2);
        length += writer.writeShort((short) 1);
        length += writer.writeUInt8(mIf ? (byte) 1 : (byte) 0);

        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 {
        IF(1, net.morimekta.providence.descriptor.PRequirement.REQUIRED, "if", "if", net.morimekta.providence.descriptor.PPrimitive.BOOL.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.IF;
            }
            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 "if": return _Field.IF;
            }
            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 "if": return _Field.IF;
            }
            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_directives.SkipArguments");
            }
            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_directives.SkipArguments");
            }
            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_directives.SkipArguments");
            }
            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_directives", "SkipArguments", _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_directives.SkipArguments builder.
     * @return The builder instance.
     */
    public static _Builder builder() {
        return new _Builder();
    }

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

        private boolean mIf;

        /**
         * Make a gql_directives.SkipArguments builder instance.
         */
        public _Builder() {
            optionals = new java.util.BitSet(1);
            modified = new java.util.BitSet(1);
            mIf = kDefaultIf;
        }

        /**
         * Make a mutating builder off a base gql_directives.SkipArguments.
         *
         * @param base The base SkipArguments
         */
        public _Builder(SkipArguments base) {
            this();

            optionals.set(0);
            mIf = base.mIf;
        }

        @javax.annotation.Nonnull
        @Override
        public SkipArguments._Builder merge(SkipArguments from) {
            optionals.set(0);
            modified.set(0);
            mIf = from.isIf();
            return this;
        }

        /**
         * Set the if field value.
         *
         * @param value The new value
         * @return The builder
         */
        @javax.annotation.Nonnull
        public SkipArguments._Builder setIf(Boolean value) {
            if (value == null) {
                return clearIf();
            }

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

        /**
         * Set the if field value.
         *
         * @param value The new value
         * @return The builder
         */
        @javax.annotation.Nonnull
        public SkipArguments._Builder setIf(boolean value) {
            optionals.set(0);
            modified.set(0);
            mIf = value;
            return this;
        }

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

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

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

        /**
         * Clear the if field.
         *
         * @return The builder
         */
        @javax.annotation.Nonnull
        public SkipArguments._Builder clearIf() {
            optionals.clear(0);
            modified.set(0);
            mIf = kDefaultIf;
            return this;
        }

        /**
         * @return The if field value
         */
        public boolean isIf() {
            return isSetIf() ? mIf : kDefaultIf;
        }

        @Override
        public boolean equals(Object o) {
            if (o == this) return true;
            if (o == null || !o.getClass().equals(getClass())) return false;
            SkipArguments._Builder other = (SkipArguments._Builder) o;
            return java.util.Objects.equals(optionals, other.optionals) &&
                   java.util.Objects.equals(mIf, other.mIf);
        }

        @Override
        public int hashCode() {
            return java.util.Objects.hash(
                    SkipArguments.class, optionals,
                    SkipArguments._Field.IF, mIf);
        }

        @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 SkipArguments._Builder set(int key, Object value) {
            if (value == null) return clear(key);
            switch (key) {
                case 1: setIf((boolean) value); break;
                default: break;
            }
            return this;
        }

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

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

        @Override
        @SuppressWarnings("unchecked")
        public  T get(int key) {
            switch(key) {
                case 1: return (T) (Object) isIf();
                default: return null;
            }
        }

        @Override
        public boolean has(int key) {
            switch(key) {
                case 1: return true;
                default: return false;
            }
        }

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

        @javax.annotation.Nonnull
        @Override
        public SkipArguments._Builder clear(int key) {
            switch (key) {
                case 1: clearIf(); break;
                default: break;
            }
            return this;
        }

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

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

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

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

        @javax.annotation.Nonnull
        @Override
        public net.morimekta.providence.descriptor.PStructDescriptor descriptor() {
            return SkipArguments.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 == 2) {
                            mIf = reader.expectUInt8() == 1;
                            optionals.set(0);
                        } else {
                            throw new net.morimekta.providence.serializer.SerializerException("Wrong type " + net.morimekta.providence.serializer.binary.BinaryType.asString(type) + " for gql_directives.SkipArguments.if, 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 SkipArguments build() {
            return new SkipArguments(this);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy