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

package com.google.crypto.tink.proto;

import com.google.protobuf.UnknownFieldSet;
import com.google.protobuf.SingleFieldBuilder;
import com.google.protobuf.UninitializedMessageException;
import com.google.protobuf.AbstractParser;
import com.google.protobuf.RuntimeVersion;
import com.google.protobuf.AbstractMessageLite;
import com.google.protobuf.Message;
import com.google.protobuf.AbstractMessage;
import com.google.protobuf.CodedInputStream;
import java.io.InputStream;
import com.google.protobuf.ExtensionRegistryLite;
import com.google.protobuf.InvalidProtocolBufferException;
import java.nio.ByteBuffer;
import java.io.IOException;
import com.google.protobuf.MessageLite;
import com.google.protobuf.CodedOutputStream;
import com.google.protobuf.ByteString;
import com.google.protobuf.Descriptors;
import com.google.protobuf.Parser;
import com.google.protobuf.GeneratedMessage;

public final class KmsEnvelopeAeadKeyFormat extends GeneratedMessage implements KmsEnvelopeAeadKeyFormatOrBuilder
{
    private static final long serialVersionUID = 0L;
    private int bitField0_;
    public static final int KEK_URI_FIELD_NUMBER = 1;
    private volatile Object kekUri_;
    public static final int DEK_TEMPLATE_FIELD_NUMBER = 2;
    private KeyTemplate dekTemplate_;
    private byte memoizedIsInitialized;
    private static final KmsEnvelopeAeadKeyFormat DEFAULT_INSTANCE;
    private static final Parser<KmsEnvelopeAeadKeyFormat> PARSER;
    
    private KmsEnvelopeAeadKeyFormat(final GeneratedMessage.Builder<?> builder) {
        super(builder);
        this.kekUri_ = "";
        this.memoizedIsInitialized = -1;
    }
    
    private KmsEnvelopeAeadKeyFormat() {
        this.kekUri_ = "";
        this.memoizedIsInitialized = -1;
        this.kekUri_ = "";
    }
    
    public static final Descriptors.Descriptor getDescriptor() {
        return KmsEnvelope.internal_static_google_crypto_tink_KmsEnvelopeAeadKeyFormat_descriptor;
    }
    
    @Override
    protected FieldAccessorTable internalGetFieldAccessorTable() {
        return KmsEnvelope.internal_static_google_crypto_tink_KmsEnvelopeAeadKeyFormat_fieldAccessorTable.ensureFieldAccessorsInitialized(KmsEnvelopeAeadKeyFormat.class, Builder.class);
    }
    
    @Override
    public String getKekUri() {
        final Object ref = this.kekUri_;
        if (ref instanceof String) {
            return (String)ref;
        }
        final ByteString bs = (ByteString)ref;
        final String s = bs.toStringUtf8();
        return (String)(this.kekUri_ = s);
    }
    
    @Override
    public ByteString getKekUriBytes() {
        final Object ref = this.kekUri_;
        if (ref instanceof String) {
            final ByteString b = ByteString.copyFromUtf8((String)ref);
            return (ByteString)(this.kekUri_ = b);
        }
        return (ByteString)ref;
    }
    
    @Override
    public boolean hasDekTemplate() {
        return (this.bitField0_ & 0x1) != 0x0;
    }
    
    @Override
    public KeyTemplate getDekTemplate() {
        return (this.dekTemplate_ == null) ? KeyTemplate.getDefaultInstance() : this.dekTemplate_;
    }
    
    @Override
    public KeyTemplateOrBuilder getDekTemplateOrBuilder() {
        return (this.dekTemplate_ == null) ? KeyTemplate.getDefaultInstance() : this.dekTemplate_;
    }
    
    @Override
    public final boolean isInitialized() {
        final byte isInitialized = this.memoizedIsInitialized;
        if (isInitialized == 1) {
            return true;
        }
        if (isInitialized == 0) {
            return false;
        }
        this.memoizedIsInitialized = 1;
        return true;
    }
    
    @Override
    public void writeTo(final CodedOutputStream output) throws IOException {
        if (!GeneratedMessage.isStringEmpty(this.kekUri_)) {
            GeneratedMessage.writeString(output, 1, this.kekUri_);
        }
        if ((this.bitField0_ & 0x1) != 0x0) {
            output.writeMessage(2, this.getDekTemplate());
        }
        this.getUnknownFields().writeTo(output);
    }
    
    @Override
    public int getSerializedSize() {
        int size = this.memoizedSize;
        if (size != -1) {
            return size;
        }
        size = 0;
        if (!GeneratedMessage.isStringEmpty(this.kekUri_)) {
            size += GeneratedMessage.computeStringSize(1, this.kekUri_);
        }
        if ((this.bitField0_ & 0x1) != 0x0) {
            size += CodedOutputStream.computeMessageSize(2, this.getDekTemplate());
        }
        size += this.getUnknownFields().getSerializedSize();
        return this.memoizedSize = size;
    }
    
    @Override
    public boolean equals(final Object obj) {
        if (obj == this) {
            return true;
        }
        if (!(obj instanceof KmsEnvelopeAeadKeyFormat)) {
            return super.equals(obj);
        }
        final KmsEnvelopeAeadKeyFormat other = (KmsEnvelopeAeadKeyFormat)obj;
        return this.getKekUri().equals(other.getKekUri()) && this.hasDekTemplate() == other.hasDekTemplate() && (!this.hasDekTemplate() || this.getDekTemplate().equals(other.getDekTemplate())) && this.getUnknownFields().equals(other.getUnknownFields());
    }
    
    @Override
    public int hashCode() {
        if (this.memoizedHashCode != 0) {
            return this.memoizedHashCode;
        }
        int hash = 41;
        hash = 19 * hash + getDescriptor().hashCode();
        hash = 37 * hash + 1;
        hash = 53 * hash + this.getKekUri().hashCode();
        if (this.hasDekTemplate()) {
            hash = 37 * hash + 2;
            hash = 53 * hash + this.getDekTemplate().hashCode();
        }
        hash = 29 * hash + this.getUnknownFields().hashCode();
        return this.memoizedHashCode = hash;
    }
    
    public static KmsEnvelopeAeadKeyFormat parseFrom(final ByteBuffer data) throws InvalidProtocolBufferException {
        return KmsEnvelopeAeadKeyFormat.PARSER.parseFrom(data);
    }
    
    public static KmsEnvelopeAeadKeyFormat parseFrom(final ByteBuffer data, final ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException {
        return KmsEnvelopeAeadKeyFormat.PARSER.parseFrom(data, extensionRegistry);
    }
    
    public static KmsEnvelopeAeadKeyFormat parseFrom(final ByteString data) throws InvalidProtocolBufferException {
        return KmsEnvelopeAeadKeyFormat.PARSER.parseFrom(data);
    }
    
    public static KmsEnvelopeAeadKeyFormat parseFrom(final ByteString data, final ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException {
        return KmsEnvelopeAeadKeyFormat.PARSER.parseFrom(data, extensionRegistry);
    }
    
    public static KmsEnvelopeAeadKeyFormat parseFrom(final byte[] data) throws InvalidProtocolBufferException {
        return KmsEnvelopeAeadKeyFormat.PARSER.parseFrom(data);
    }
    
    public static KmsEnvelopeAeadKeyFormat parseFrom(final byte[] data, final ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException {
        return KmsEnvelopeAeadKeyFormat.PARSER.parseFrom(data, extensionRegistry);
    }
    
    public static KmsEnvelopeAeadKeyFormat parseFrom(final InputStream input) throws IOException {
        return GeneratedMessage.parseWithIOException(KmsEnvelopeAeadKeyFormat.PARSER, input);
    }
    
    public static KmsEnvelopeAeadKeyFormat parseFrom(final InputStream input, final ExtensionRegistryLite extensionRegistry) throws IOException {
        return GeneratedMessage.parseWithIOException(KmsEnvelopeAeadKeyFormat.PARSER, input, extensionRegistry);
    }
    
    public static KmsEnvelopeAeadKeyFormat parseDelimitedFrom(final InputStream input) throws IOException {
        return GeneratedMessage.parseDelimitedWithIOException(KmsEnvelopeAeadKeyFormat.PARSER, input);
    }
    
    public static KmsEnvelopeAeadKeyFormat parseDelimitedFrom(final InputStream input, final ExtensionRegistryLite extensionRegistry) throws IOException {
        return GeneratedMessage.parseDelimitedWithIOException(KmsEnvelopeAeadKeyFormat.PARSER, input, extensionRegistry);
    }
    
    public static KmsEnvelopeAeadKeyFormat parseFrom(final CodedInputStream input) throws IOException {
        return GeneratedMessage.parseWithIOException(KmsEnvelopeAeadKeyFormat.PARSER, input);
    }
    
    public static KmsEnvelopeAeadKeyFormat parseFrom(final CodedInputStream input, final ExtensionRegistryLite extensionRegistry) throws IOException {
        return GeneratedMessage.parseWithIOException(KmsEnvelopeAeadKeyFormat.PARSER, input, extensionRegistry);
    }
    
    @Override
    public Builder newBuilderForType() {
        return newBuilder();
    }
    
    public static Builder newBuilder() {
        return KmsEnvelopeAeadKeyFormat.DEFAULT_INSTANCE.toBuilder();
    }
    
    public static Builder newBuilder(final KmsEnvelopeAeadKeyFormat prototype) {
        return KmsEnvelopeAeadKeyFormat.DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
    }
    
    @Override
    public Builder toBuilder() {
        return (this == KmsEnvelopeAeadKeyFormat.DEFAULT_INSTANCE) ? new Builder() : new Builder().mergeFrom(this);
    }
    
    @Override
    protected Builder newBuilderForType(final BuilderParent parent) {
        final Builder builder = new Builder(parent);
        return builder;
    }
    
    public static KmsEnvelopeAeadKeyFormat getDefaultInstance() {
        return KmsEnvelopeAeadKeyFormat.DEFAULT_INSTANCE;
    }
    
    public static Parser<KmsEnvelopeAeadKeyFormat> parser() {
        return KmsEnvelopeAeadKeyFormat.PARSER;
    }
    
    @Override
    public Parser<KmsEnvelopeAeadKeyFormat> getParserForType() {
        return KmsEnvelopeAeadKeyFormat.PARSER;
    }
    
    @Override
    public KmsEnvelopeAeadKeyFormat getDefaultInstanceForType() {
        return KmsEnvelopeAeadKeyFormat.DEFAULT_INSTANCE;
    }
    
    static {
        RuntimeVersion.validateProtobufGencodeVersion(RuntimeVersion.RuntimeDomain.PUBLIC, 4, 32, 1, "", KmsEnvelopeAeadKeyFormat.class.getName());
        DEFAULT_INSTANCE = new KmsEnvelopeAeadKeyFormat();
        PARSER = new AbstractParser<KmsEnvelopeAeadKeyFormat>() {
            @Override
            public KmsEnvelopeAeadKeyFormat parsePartialFrom(final CodedInputStream input, final ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException {
                final Builder builder = KmsEnvelopeAeadKeyFormat.newBuilder();
                try {
                    builder.mergeFrom(input, extensionRegistry);
                }
                catch (final InvalidProtocolBufferException e) {
                    throw e.setUnfinishedMessage(builder.buildPartial());
                }
                catch (final UninitializedMessageException e2) {
                    throw e2.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial());
                }
                catch (final IOException e3) {
                    throw new InvalidProtocolBufferException(e3).setUnfinishedMessage(builder.buildPartial());
                }
                return builder.buildPartial();
            }
        };
    }
    
    public static final class Builder extends GeneratedMessage.Builder<Builder> implements KmsEnvelopeAeadKeyFormatOrBuilder
    {
        private int bitField0_;
        private Object kekUri_;
        private KeyTemplate dekTemplate_;
        private SingleFieldBuilder<KeyTemplate, KeyTemplate.Builder, KeyTemplateOrBuilder> dekTemplateBuilder_;
        
        public static final Descriptors.Descriptor getDescriptor() {
            return KmsEnvelope.internal_static_google_crypto_tink_KmsEnvelopeAeadKeyFormat_descriptor;
        }
        
        @Override
        protected FieldAccessorTable internalGetFieldAccessorTable() {
            return KmsEnvelope.internal_static_google_crypto_tink_KmsEnvelopeAeadKeyFormat_fieldAccessorTable.ensureFieldAccessorsInitialized(KmsEnvelopeAeadKeyFormat.class, Builder.class);
        }
        
        private Builder() {
            this.kekUri_ = "";
            this.maybeForceBuilderInitialization();
        }
        
        private Builder(final BuilderParent parent) {
            super(parent);
            this.kekUri_ = "";
            this.maybeForceBuilderInitialization();
        }
        
        private void maybeForceBuilderInitialization() {
            if (KmsEnvelopeAeadKeyFormat.alwaysUseFieldBuilders) {
                this.internalGetDekTemplateFieldBuilder();
            }
        }
        
        @Override
        public Builder clear() {
            super.clear();
            this.bitField0_ = 0;
            this.kekUri_ = "";
            this.dekTemplate_ = null;
            if (this.dekTemplateBuilder_ != null) {
                this.dekTemplateBuilder_.dispose();
                this.dekTemplateBuilder_ = null;
            }
            return this;
        }
        
        @Override
        public Descriptors.Descriptor getDescriptorForType() {
            return KmsEnvelope.internal_static_google_crypto_tink_KmsEnvelopeAeadKeyFormat_descriptor;
        }
        
        @Override
        public KmsEnvelopeAeadKeyFormat getDefaultInstanceForType() {
            return KmsEnvelopeAeadKeyFormat.getDefaultInstance();
        }
        
        @Override
        public KmsEnvelopeAeadKeyFormat build() {
            final KmsEnvelopeAeadKeyFormat result = this.buildPartial();
            if (!result.isInitialized()) {
                throw AbstractMessage.Builder.newUninitializedMessageException(result);
            }
            return result;
        }
        
        @Override
        public KmsEnvelopeAeadKeyFormat buildPartial() {
            final KmsEnvelopeAeadKeyFormat result = new KmsEnvelopeAeadKeyFormat(this, null);
            if (this.bitField0_ != 0) {
                this.buildPartial0(result);
            }
            this.onBuilt();
            return result;
        }
        
        private void buildPartial0(final KmsEnvelopeAeadKeyFormat result) {
            final int from_bitField0_ = this.bitField0_;
            if ((from_bitField0_ & 0x1) != 0x0) {
                result.kekUri_ = this.kekUri_;
            }
            int to_bitField0_ = 0;
            if ((from_bitField0_ & 0x2) != 0x0) {
                result.dekTemplate_ = ((this.dekTemplateBuilder_ == null) ? this.dekTemplate_ : this.dekTemplateBuilder_.build());
                to_bitField0_ |= 0x1;
            }
            result.bitField0_ |= to_bitField0_;
        }
        
        @Override
        public Builder mergeFrom(final Message other) {
            if (other instanceof KmsEnvelopeAeadKeyFormat) {
                return this.mergeFrom((KmsEnvelopeAeadKeyFormat)other);
            }
            super.mergeFrom(other);
            return this;
        }
        
        public Builder mergeFrom(final KmsEnvelopeAeadKeyFormat other) {
            if (other == KmsEnvelopeAeadKeyFormat.getDefaultInstance()) {
                return this;
            }
            if (!other.getKekUri().isEmpty()) {
                this.kekUri_ = other.kekUri_;
                this.bitField0_ |= 0x1;
                this.onChanged();
            }
            if (other.hasDekTemplate()) {
                this.mergeDekTemplate(other.getDekTemplate());
            }
            this.mergeUnknownFields(other.getUnknownFields());
            this.onChanged();
            return this;
        }
        
        @Override
        public final boolean isInitialized() {
            return true;
        }
        
        @Override
        public Builder mergeFrom(final CodedInputStream input, final ExtensionRegistryLite extensionRegistry) throws IOException {
            if (extensionRegistry == null) {
                throw new NullPointerException();
            }
            try {
                boolean done = false;
                while (!done) {
                    final int tag = input.readTag();
                    switch (tag) {
                        case 0: {
                            done = true;
                            continue;
                        }
                        case 10: {
                            this.kekUri_ = input.readStringRequireUtf8();
                            this.bitField0_ |= 0x1;
                            continue;
                        }
                        case 18: {
                            input.readMessage(this.internalGetDekTemplateFieldBuilder().getBuilder(), extensionRegistry);
                            this.bitField0_ |= 0x2;
                            continue;
                        }
                        default: {
                            if (!super.parseUnknownField(input, extensionRegistry, tag)) {
                                done = true;
                                continue;
                            }
                            continue;
                        }
                    }
                }
            }
            catch (final InvalidProtocolBufferException e) {
                throw e.unwrapIOException();
            }
            finally {
                this.onChanged();
            }
            return this;
        }
        
        @Override
        public String getKekUri() {
            final Object ref = this.kekUri_;
            if (!(ref instanceof String)) {
                final ByteString bs = (ByteString)ref;
                final String s = bs.toStringUtf8();
                return (String)(this.kekUri_ = s);
            }
            return (String)ref;
        }
        
        @Override
        public ByteString getKekUriBytes() {
            final Object ref = this.kekUri_;
            if (ref instanceof String) {
                final ByteString b = ByteString.copyFromUtf8((String)ref);
                return (ByteString)(this.kekUri_ = b);
            }
            return (ByteString)ref;
        }
        
        public Builder setKekUri(final String value) {
            if (value == null) {
                throw new NullPointerException();
            }
            this.kekUri_ = value;
            this.bitField0_ |= 0x1;
            this.onChanged();
            return this;
        }
        
        public Builder clearKekUri() {
            this.kekUri_ = KmsEnvelopeAeadKeyFormat.getDefaultInstance().getKekUri();
            this.bitField0_ &= 0xFFFFFFFE;
            this.onChanged();
            return this;
        }
        
        public Builder setKekUriBytes(final ByteString value) {
            if (value == null) {
                throw new NullPointerException();
            }
            AbstractMessageLite.checkByteStringIsUtf8(value);
            this.kekUri_ = value;
            this.bitField0_ |= 0x1;
            this.onChanged();
            return this;
        }
        
        @Override
        public boolean hasDekTemplate() {
            return (this.bitField0_ & 0x2) != 0x0;
        }
        
        @Override
        public KeyTemplate getDekTemplate() {
            if (this.dekTemplateBuilder_ == null) {
                return (this.dekTemplate_ == null) ? KeyTemplate.getDefaultInstance() : this.dekTemplate_;
            }
            return this.dekTemplateBuilder_.getMessage();
        }
        
        public Builder setDekTemplate(final KeyTemplate value) {
            if (this.dekTemplateBuilder_ == null) {
                if (value == null) {
                    throw new NullPointerException();
                }
                this.dekTemplate_ = value;
            }
            else {
                this.dekTemplateBuilder_.setMessage(value);
            }
            this.bitField0_ |= 0x2;
            this.onChanged();
            return this;
        }
        
        public Builder setDekTemplate(final KeyTemplate.Builder builderForValue) {
            if (this.dekTemplateBuilder_ == null) {
                this.dekTemplate_ = builderForValue.build();
            }
            else {
                this.dekTemplateBuilder_.setMessage(builderForValue.build());
            }
            this.bitField0_ |= 0x2;
            this.onChanged();
            return this;
        }
        
        public Builder mergeDekTemplate(final KeyTemplate value) {
            if (this.dekTemplateBuilder_ == null) {
                if ((this.bitField0_ & 0x2) != 0x0 && this.dekTemplate_ != null && this.dekTemplate_ != KeyTemplate.getDefaultInstance()) {
                    this.getDekTemplateBuilder().mergeFrom(value);
                }
                else {
                    this.dekTemplate_ = value;
                }
            }
            else {
                this.dekTemplateBuilder_.mergeFrom(value);
            }
            if (this.dekTemplate_ != null) {
                this.bitField0_ |= 0x2;
                this.onChanged();
            }
            return this;
        }
        
        public Builder clearDekTemplate() {
            this.bitField0_ &= 0xFFFFFFFD;
            this.dekTemplate_ = null;
            if (this.dekTemplateBuilder_ != null) {
                this.dekTemplateBuilder_.dispose();
                this.dekTemplateBuilder_ = null;
            }
            this.onChanged();
            return this;
        }
        
        public KeyTemplate.Builder getDekTemplateBuilder() {
            this.bitField0_ |= 0x2;
            this.onChanged();
            return this.internalGetDekTemplateFieldBuilder().getBuilder();
        }
        
        @Override
        public KeyTemplateOrBuilder getDekTemplateOrBuilder() {
            if (this.dekTemplateBuilder_ != null) {
                return this.dekTemplateBuilder_.getMessageOrBuilder();
            }
            return (this.dekTemplate_ == null) ? KeyTemplate.getDefaultInstance() : this.dekTemplate_;
        }
        
        private SingleFieldBuilder<KeyTemplate, KeyTemplate.Builder, KeyTemplateOrBuilder> internalGetDekTemplateFieldBuilder() {
            if (this.dekTemplateBuilder_ == null) {
                this.dekTemplateBuilder_ = new SingleFieldBuilder<KeyTemplate, KeyTemplate.Builder, KeyTemplateOrBuilder>(this.getDekTemplate(), this.getParentForChildren(), this.isClean());
                this.dekTemplate_ = null;
            }
            return this.dekTemplateBuilder_;
        }
    }
}
