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

package com.google.crypto.tink.proto;

import com.google.protobuf.MessageOrBuilder;
import java.util.ArrayList;
import java.util.Collection;
import com.google.protobuf.RepeatedFieldBuilder;
import com.google.protobuf.AbstractMessageLite;
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.Message;
import com.google.protobuf.AbstractMessage;
import com.google.protobuf.CodedInputStream;
import java.io.InputStream;
import com.google.protobuf.ByteString;
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.Descriptors;
import java.util.Collections;
import com.google.protobuf.Parser;
import java.util.List;
import com.google.protobuf.GeneratedMessage;

public final class Keyset extends GeneratedMessage implements KeysetOrBuilder
{
    private static final long serialVersionUID = 0L;
    public static final int PRIMARY_KEY_ID_FIELD_NUMBER = 1;
    private int primaryKeyId_;
    public static final int KEY_FIELD_NUMBER = 2;
    private List<Key> key_;
    private byte memoizedIsInitialized;
    private static final Keyset DEFAULT_INSTANCE;
    private static final Parser<Keyset> PARSER;
    
    private Keyset(final GeneratedMessage.Builder<?> builder) {
        super(builder);
        this.primaryKeyId_ = 0;
        this.memoizedIsInitialized = -1;
    }
    
    private Keyset() {
        this.primaryKeyId_ = 0;
        this.memoizedIsInitialized = -1;
        this.key_ = Collections.emptyList();
    }
    
    public static final Descriptors.Descriptor getDescriptor() {
        return Tink.internal_static_google_crypto_tink_Keyset_descriptor;
    }
    
    @Override
    protected FieldAccessorTable internalGetFieldAccessorTable() {
        return Tink.internal_static_google_crypto_tink_Keyset_fieldAccessorTable.ensureFieldAccessorsInitialized(Keyset.class, Builder.class);
    }
    
    @Override
    public int getPrimaryKeyId() {
        return this.primaryKeyId_;
    }
    
    @Override
    public List<Key> getKeyList() {
        return this.key_;
    }
    
    @Override
    public List<? extends KeyOrBuilder> getKeyOrBuilderList() {
        return this.key_;
    }
    
    @Override
    public int getKeyCount() {
        return this.key_.size();
    }
    
    @Override
    public Key getKey(final int index) {
        return this.key_.get(index);
    }
    
    @Override
    public KeyOrBuilder getKeyOrBuilder(final int index) {
        return this.key_.get(index);
    }
    
    @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 (this.primaryKeyId_ != 0) {
            output.writeUInt32(1, this.primaryKeyId_);
        }
        for (int i = 0; i < this.key_.size(); ++i) {
            output.writeMessage(2, this.key_.get(i));
        }
        this.getUnknownFields().writeTo(output);
    }
    
    @Override
    public int getSerializedSize() {
        int size = this.memoizedSize;
        if (size != -1) {
            return size;
        }
        size = 0;
        if (this.primaryKeyId_ != 0) {
            size += CodedOutputStream.computeUInt32Size(1, this.primaryKeyId_);
        }
        for (int i = 0; i < this.key_.size(); ++i) {
            size += CodedOutputStream.computeMessageSize(2, this.key_.get(i));
        }
        size += this.getUnknownFields().getSerializedSize();
        return this.memoizedSize = size;
    }
    
    @Override
    public boolean equals(final Object obj) {
        if (obj == this) {
            return true;
        }
        if (!(obj instanceof Keyset)) {
            return super.equals(obj);
        }
        final Keyset other = (Keyset)obj;
        return this.getPrimaryKeyId() == other.getPrimaryKeyId() && this.getKeyList().equals(other.getKeyList()) && 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.getPrimaryKeyId();
        if (this.getKeyCount() > 0) {
            hash = 37 * hash + 2;
            hash = 53 * hash + this.getKeyList().hashCode();
        }
        hash = 29 * hash + this.getUnknownFields().hashCode();
        return this.memoizedHashCode = hash;
    }
    
    public static Keyset parseFrom(final ByteBuffer data) throws InvalidProtocolBufferException {
        return Keyset.PARSER.parseFrom(data);
    }
    
    public static Keyset parseFrom(final ByteBuffer data, final ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException {
        return Keyset.PARSER.parseFrom(data, extensionRegistry);
    }
    
    public static Keyset parseFrom(final ByteString data) throws InvalidProtocolBufferException {
        return Keyset.PARSER.parseFrom(data);
    }
    
    public static Keyset parseFrom(final ByteString data, final ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException {
        return Keyset.PARSER.parseFrom(data, extensionRegistry);
    }
    
    public static Keyset parseFrom(final byte[] data) throws InvalidProtocolBufferException {
        return Keyset.PARSER.parseFrom(data);
    }
    
    public static Keyset parseFrom(final byte[] data, final ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException {
        return Keyset.PARSER.parseFrom(data, extensionRegistry);
    }
    
    public static Keyset parseFrom(final InputStream input) throws IOException {
        return GeneratedMessage.parseWithIOException(Keyset.PARSER, input);
    }
    
    public static Keyset parseFrom(final InputStream input, final ExtensionRegistryLite extensionRegistry) throws IOException {
        return GeneratedMessage.parseWithIOException(Keyset.PARSER, input, extensionRegistry);
    }
    
    public static Keyset parseDelimitedFrom(final InputStream input) throws IOException {
        return GeneratedMessage.parseDelimitedWithIOException(Keyset.PARSER, input);
    }
    
    public static Keyset parseDelimitedFrom(final InputStream input, final ExtensionRegistryLite extensionRegistry) throws IOException {
        return GeneratedMessage.parseDelimitedWithIOException(Keyset.PARSER, input, extensionRegistry);
    }
    
    public static Keyset parseFrom(final CodedInputStream input) throws IOException {
        return GeneratedMessage.parseWithIOException(Keyset.PARSER, input);
    }
    
    public static Keyset parseFrom(final CodedInputStream input, final ExtensionRegistryLite extensionRegistry) throws IOException {
        return GeneratedMessage.parseWithIOException(Keyset.PARSER, input, extensionRegistry);
    }
    
    @Override
    public Builder newBuilderForType() {
        return newBuilder();
    }
    
    public static Builder newBuilder() {
        return Keyset.DEFAULT_INSTANCE.toBuilder();
    }
    
    public static Builder newBuilder(final Keyset prototype) {
        return Keyset.DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
    }
    
    @Override
    public Builder toBuilder() {
        return (this == Keyset.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 Keyset getDefaultInstance() {
        return Keyset.DEFAULT_INSTANCE;
    }
    
    public static Parser<Keyset> parser() {
        return Keyset.PARSER;
    }
    
    @Override
    public Parser<Keyset> getParserForType() {
        return Keyset.PARSER;
    }
    
    @Override
    public Keyset getDefaultInstanceForType() {
        return Keyset.DEFAULT_INSTANCE;
    }
    
    static {
        RuntimeVersion.validateProtobufGencodeVersion(RuntimeVersion.RuntimeDomain.PUBLIC, 4, 32, 1, "", Keyset.class.getName());
        DEFAULT_INSTANCE = new Keyset();
        PARSER = new AbstractParser<Keyset>() {
            @Override
            public Keyset parsePartialFrom(final CodedInputStream input, final ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException {
                final Builder builder = Keyset.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 Key extends GeneratedMessage implements KeyOrBuilder
    {
        private static final long serialVersionUID = 0L;
        private int bitField0_;
        public static final int KEY_DATA_FIELD_NUMBER = 1;
        private KeyData keyData_;
        public static final int STATUS_FIELD_NUMBER = 2;
        private int status_;
        public static final int KEY_ID_FIELD_NUMBER = 3;
        private int keyId_;
        public static final int OUTPUT_PREFIX_TYPE_FIELD_NUMBER = 4;
        private int outputPrefixType_;
        private byte memoizedIsInitialized;
        private static final Key DEFAULT_INSTANCE;
        private static final Parser<Key> PARSER;
        
        private Key(final GeneratedMessage.Builder<?> builder) {
            super(builder);
            this.status_ = 0;
            this.keyId_ = 0;
            this.outputPrefixType_ = 0;
            this.memoizedIsInitialized = -1;
        }
        
        private Key() {
            this.status_ = 0;
            this.keyId_ = 0;
            this.outputPrefixType_ = 0;
            this.memoizedIsInitialized = -1;
            this.status_ = 0;
            this.outputPrefixType_ = 0;
        }
        
        public static final Descriptors.Descriptor getDescriptor() {
            return Tink.internal_static_google_crypto_tink_Keyset_Key_descriptor;
        }
        
        @Override
        protected FieldAccessorTable internalGetFieldAccessorTable() {
            return Tink.internal_static_google_crypto_tink_Keyset_Key_fieldAccessorTable.ensureFieldAccessorsInitialized(Key.class, Builder.class);
        }
        
        @Override
        public boolean hasKeyData() {
            return (this.bitField0_ & 0x1) != 0x0;
        }
        
        @Override
        public KeyData getKeyData() {
            return (this.keyData_ == null) ? KeyData.getDefaultInstance() : this.keyData_;
        }
        
        @Override
        public KeyDataOrBuilder getKeyDataOrBuilder() {
            return (this.keyData_ == null) ? KeyData.getDefaultInstance() : this.keyData_;
        }
        
        @Override
        public int getStatusValue() {
            return this.status_;
        }
        
        @Override
        public KeyStatusType getStatus() {
            final KeyStatusType result = KeyStatusType.forNumber(this.status_);
            return (result == null) ? KeyStatusType.UNRECOGNIZED : result;
        }
        
        @Override
        public int getKeyId() {
            return this.keyId_;
        }
        
        @Override
        public int getOutputPrefixTypeValue() {
            return this.outputPrefixType_;
        }
        
        @Override
        public OutputPrefixType getOutputPrefixType() {
            final OutputPrefixType result = OutputPrefixType.forNumber(this.outputPrefixType_);
            return (result == null) ? OutputPrefixType.UNRECOGNIZED : result;
        }
        
        @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 ((this.bitField0_ & 0x1) != 0x0) {
                output.writeMessage(1, this.getKeyData());
            }
            if (this.status_ != KeyStatusType.UNKNOWN_STATUS.getNumber()) {
                output.writeEnum(2, this.status_);
            }
            if (this.keyId_ != 0) {
                output.writeUInt32(3, this.keyId_);
            }
            if (this.outputPrefixType_ != OutputPrefixType.UNKNOWN_PREFIX.getNumber()) {
                output.writeEnum(4, this.outputPrefixType_);
            }
            this.getUnknownFields().writeTo(output);
        }
        
        @Override
        public int getSerializedSize() {
            int size = this.memoizedSize;
            if (size != -1) {
                return size;
            }
            size = 0;
            if ((this.bitField0_ & 0x1) != 0x0) {
                size += CodedOutputStream.computeMessageSize(1, this.getKeyData());
            }
            if (this.status_ != KeyStatusType.UNKNOWN_STATUS.getNumber()) {
                size += CodedOutputStream.computeEnumSize(2, this.status_);
            }
            if (this.keyId_ != 0) {
                size += CodedOutputStream.computeUInt32Size(3, this.keyId_);
            }
            if (this.outputPrefixType_ != OutputPrefixType.UNKNOWN_PREFIX.getNumber()) {
                size += CodedOutputStream.computeEnumSize(4, this.outputPrefixType_);
            }
            size += this.getUnknownFields().getSerializedSize();
            return this.memoizedSize = size;
        }
        
        @Override
        public boolean equals(final Object obj) {
            if (obj == this) {
                return true;
            }
            if (!(obj instanceof Key)) {
                return super.equals(obj);
            }
            final Key other = (Key)obj;
            return this.hasKeyData() == other.hasKeyData() && (!this.hasKeyData() || this.getKeyData().equals(other.getKeyData())) && this.status_ == other.status_ && this.getKeyId() == other.getKeyId() && this.outputPrefixType_ == other.outputPrefixType_ && this.getUnknownFields().equals(other.getUnknownFields());
        }
        
        @Override
        public int hashCode() {
            if (this.memoizedHashCode != 0) {
                return this.memoizedHashCode;
            }
            int hash = 41;
            hash = 19 * hash + getDescriptor().hashCode();
            if (this.hasKeyData()) {
                hash = 37 * hash + 1;
                hash = 53 * hash + this.getKeyData().hashCode();
            }
            hash = 37 * hash + 2;
            hash = 53 * hash + this.status_;
            hash = 37 * hash + 3;
            hash = 53 * hash + this.getKeyId();
            hash = 37 * hash + 4;
            hash = 53 * hash + this.outputPrefixType_;
            hash = 29 * hash + this.getUnknownFields().hashCode();
            return this.memoizedHashCode = hash;
        }
        
        public static Key parseFrom(final ByteBuffer data) throws InvalidProtocolBufferException {
            return Key.PARSER.parseFrom(data);
        }
        
        public static Key parseFrom(final ByteBuffer data, final ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException {
            return Key.PARSER.parseFrom(data, extensionRegistry);
        }
        
        public static Key parseFrom(final ByteString data) throws InvalidProtocolBufferException {
            return Key.PARSER.parseFrom(data);
        }
        
        public static Key parseFrom(final ByteString data, final ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException {
            return Key.PARSER.parseFrom(data, extensionRegistry);
        }
        
        public static Key parseFrom(final byte[] data) throws InvalidProtocolBufferException {
            return Key.PARSER.parseFrom(data);
        }
        
        public static Key parseFrom(final byte[] data, final ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException {
            return Key.PARSER.parseFrom(data, extensionRegistry);
        }
        
        public static Key parseFrom(final InputStream input) throws IOException {
            return GeneratedMessage.parseWithIOException(Key.PARSER, input);
        }
        
        public static Key parseFrom(final InputStream input, final ExtensionRegistryLite extensionRegistry) throws IOException {
            return GeneratedMessage.parseWithIOException(Key.PARSER, input, extensionRegistry);
        }
        
        public static Key parseDelimitedFrom(final InputStream input) throws IOException {
            return GeneratedMessage.parseDelimitedWithIOException(Key.PARSER, input);
        }
        
        public static Key parseDelimitedFrom(final InputStream input, final ExtensionRegistryLite extensionRegistry) throws IOException {
            return GeneratedMessage.parseDelimitedWithIOException(Key.PARSER, input, extensionRegistry);
        }
        
        public static Key parseFrom(final CodedInputStream input) throws IOException {
            return GeneratedMessage.parseWithIOException(Key.PARSER, input);
        }
        
        public static Key parseFrom(final CodedInputStream input, final ExtensionRegistryLite extensionRegistry) throws IOException {
            return GeneratedMessage.parseWithIOException(Key.PARSER, input, extensionRegistry);
        }
        
        @Override
        public Builder newBuilderForType() {
            return newBuilder();
        }
        
        public static Builder newBuilder() {
            return Key.DEFAULT_INSTANCE.toBuilder();
        }
        
        public static Builder newBuilder(final Key prototype) {
            return Key.DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
        }
        
        @Override
        public Builder toBuilder() {
            return (this == Key.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 Key getDefaultInstance() {
            return Key.DEFAULT_INSTANCE;
        }
        
        public static Parser<Key> parser() {
            return Key.PARSER;
        }
        
        @Override
        public Parser<Key> getParserForType() {
            return Key.PARSER;
        }
        
        @Override
        public Key getDefaultInstanceForType() {
            return Key.DEFAULT_INSTANCE;
        }
        
        static {
            RuntimeVersion.validateProtobufGencodeVersion(RuntimeVersion.RuntimeDomain.PUBLIC, 4, 32, 1, "", Key.class.getName());
            DEFAULT_INSTANCE = new Key();
            PARSER = new AbstractParser<Key>() {
                @Override
                public Key parsePartialFrom(final CodedInputStream input, final ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException {
                    final Builder builder = Key.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 KeyOrBuilder
        {
            private int bitField0_;
            private KeyData keyData_;
            private SingleFieldBuilder<KeyData, KeyData.Builder, KeyDataOrBuilder> keyDataBuilder_;
            private int status_;
            private int keyId_;
            private int outputPrefixType_;
            
            public static final Descriptors.Descriptor getDescriptor() {
                return Tink.internal_static_google_crypto_tink_Keyset_Key_descriptor;
            }
            
            @Override
            protected FieldAccessorTable internalGetFieldAccessorTable() {
                return Tink.internal_static_google_crypto_tink_Keyset_Key_fieldAccessorTable.ensureFieldAccessorsInitialized(Key.class, Builder.class);
            }
            
            private Builder() {
                this.status_ = 0;
                this.outputPrefixType_ = 0;
                this.maybeForceBuilderInitialization();
            }
            
            private Builder(final BuilderParent parent) {
                super(parent);
                this.status_ = 0;
                this.outputPrefixType_ = 0;
                this.maybeForceBuilderInitialization();
            }
            
            private void maybeForceBuilderInitialization() {
                if (Key.alwaysUseFieldBuilders) {
                    this.internalGetKeyDataFieldBuilder();
                }
            }
            
            @Override
            public Builder clear() {
                super.clear();
                this.bitField0_ = 0;
                this.keyData_ = null;
                if (this.keyDataBuilder_ != null) {
                    this.keyDataBuilder_.dispose();
                    this.keyDataBuilder_ = null;
                }
                this.status_ = 0;
                this.keyId_ = 0;
                this.outputPrefixType_ = 0;
                return this;
            }
            
            @Override
            public Descriptors.Descriptor getDescriptorForType() {
                return Tink.internal_static_google_crypto_tink_Keyset_Key_descriptor;
            }
            
            @Override
            public Key getDefaultInstanceForType() {
                return Key.getDefaultInstance();
            }
            
            @Override
            public Key build() {
                final Key result = this.buildPartial();
                if (!result.isInitialized()) {
                    throw AbstractMessage.Builder.newUninitializedMessageException(result);
                }
                return result;
            }
            
            @Override
            public Key buildPartial() {
                final Key result = new Key((GeneratedMessage.Builder)this);
                if (this.bitField0_ != 0) {
                    this.buildPartial0(result);
                }
                this.onBuilt();
                return result;
            }
            
            private void buildPartial0(final Key result) {
                final int from_bitField0_ = this.bitField0_;
                int to_bitField0_ = 0;
                if ((from_bitField0_ & 0x1) != 0x0) {
                    result.keyData_ = ((this.keyDataBuilder_ == null) ? this.keyData_ : this.keyDataBuilder_.build());
                    to_bitField0_ |= 0x1;
                }
                if ((from_bitField0_ & 0x2) != 0x0) {
                    result.status_ = this.status_;
                }
                if ((from_bitField0_ & 0x4) != 0x0) {
                    result.keyId_ = this.keyId_;
                }
                if ((from_bitField0_ & 0x8) != 0x0) {
                    result.outputPrefixType_ = this.outputPrefixType_;
                }
                result.bitField0_ |= to_bitField0_;
            }
            
            @Override
            public Builder mergeFrom(final Message other) {
                if (other instanceof Key) {
                    return this.mergeFrom((Key)other);
                }
                super.mergeFrom(other);
                return this;
            }
            
            public Builder mergeFrom(final Key other) {
                if (other == Key.getDefaultInstance()) {
                    return this;
                }
                if (other.hasKeyData()) {
                    this.mergeKeyData(other.getKeyData());
                }
                if (other.status_ != 0) {
                    this.setStatusValue(other.getStatusValue());
                }
                if (other.getKeyId() != 0) {
                    this.setKeyId(other.getKeyId());
                }
                if (other.outputPrefixType_ != 0) {
                    this.setOutputPrefixTypeValue(other.getOutputPrefixTypeValue());
                }
                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: {
                                input.readMessage(this.internalGetKeyDataFieldBuilder().getBuilder(), extensionRegistry);
                                this.bitField0_ |= 0x1;
                                continue;
                            }
                            case 16: {
                                this.status_ = input.readEnum();
                                this.bitField0_ |= 0x2;
                                continue;
                            }
                            case 24: {
                                this.keyId_ = input.readUInt32();
                                this.bitField0_ |= 0x4;
                                continue;
                            }
                            case 32: {
                                this.outputPrefixType_ = input.readEnum();
                                this.bitField0_ |= 0x8;
                                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 boolean hasKeyData() {
                return (this.bitField0_ & 0x1) != 0x0;
            }
            
            @Override
            public KeyData getKeyData() {
                if (this.keyDataBuilder_ == null) {
                    return (this.keyData_ == null) ? KeyData.getDefaultInstance() : this.keyData_;
                }
                return this.keyDataBuilder_.getMessage();
            }
            
            public Builder setKeyData(final KeyData value) {
                if (this.keyDataBuilder_ == null) {
                    if (value == null) {
                        throw new NullPointerException();
                    }
                    this.keyData_ = value;
                }
                else {
                    this.keyDataBuilder_.setMessage(value);
                }
                this.bitField0_ |= 0x1;
                this.onChanged();
                return this;
            }
            
            public Builder setKeyData(final KeyData.Builder builderForValue) {
                if (this.keyDataBuilder_ == null) {
                    this.keyData_ = builderForValue.build();
                }
                else {
                    this.keyDataBuilder_.setMessage(builderForValue.build());
                }
                this.bitField0_ |= 0x1;
                this.onChanged();
                return this;
            }
            
            public Builder mergeKeyData(final KeyData value) {
                if (this.keyDataBuilder_ == null) {
                    if ((this.bitField0_ & 0x1) != 0x0 && this.keyData_ != null && this.keyData_ != KeyData.getDefaultInstance()) {
                        this.getKeyDataBuilder().mergeFrom(value);
                    }
                    else {
                        this.keyData_ = value;
                    }
                }
                else {
                    this.keyDataBuilder_.mergeFrom(value);
                }
                if (this.keyData_ != null) {
                    this.bitField0_ |= 0x1;
                    this.onChanged();
                }
                return this;
            }
            
            public Builder clearKeyData() {
                this.bitField0_ &= 0xFFFFFFFE;
                this.keyData_ = null;
                if (this.keyDataBuilder_ != null) {
                    this.keyDataBuilder_.dispose();
                    this.keyDataBuilder_ = null;
                }
                this.onChanged();
                return this;
            }
            
            public KeyData.Builder getKeyDataBuilder() {
                this.bitField0_ |= 0x1;
                this.onChanged();
                return this.internalGetKeyDataFieldBuilder().getBuilder();
            }
            
            @Override
            public KeyDataOrBuilder getKeyDataOrBuilder() {
                if (this.keyDataBuilder_ != null) {
                    return this.keyDataBuilder_.getMessageOrBuilder();
                }
                return (this.keyData_ == null) ? KeyData.getDefaultInstance() : this.keyData_;
            }
            
            private SingleFieldBuilder<KeyData, KeyData.Builder, KeyDataOrBuilder> internalGetKeyDataFieldBuilder() {
                if (this.keyDataBuilder_ == null) {
                    this.keyDataBuilder_ = new SingleFieldBuilder<KeyData, KeyData.Builder, KeyDataOrBuilder>(this.getKeyData(), this.getParentForChildren(), this.isClean());
                    this.keyData_ = null;
                }
                return this.keyDataBuilder_;
            }
            
            @Override
            public int getStatusValue() {
                return this.status_;
            }
            
            public Builder setStatusValue(final int value) {
                this.status_ = value;
                this.bitField0_ |= 0x2;
                this.onChanged();
                return this;
            }
            
            @Override
            public KeyStatusType getStatus() {
                final KeyStatusType result = KeyStatusType.forNumber(this.status_);
                return (result == null) ? KeyStatusType.UNRECOGNIZED : result;
            }
            
            public Builder setStatus(final KeyStatusType value) {
                if (value == null) {
                    throw new NullPointerException();
                }
                this.bitField0_ |= 0x2;
                this.status_ = value.getNumber();
                this.onChanged();
                return this;
            }
            
            public Builder clearStatus() {
                this.bitField0_ &= 0xFFFFFFFD;
                this.status_ = 0;
                this.onChanged();
                return this;
            }
            
            @Override
            public int getKeyId() {
                return this.keyId_;
            }
            
            public Builder setKeyId(final int value) {
                this.keyId_ = value;
                this.bitField0_ |= 0x4;
                this.onChanged();
                return this;
            }
            
            public Builder clearKeyId() {
                this.bitField0_ &= 0xFFFFFFFB;
                this.keyId_ = 0;
                this.onChanged();
                return this;
            }
            
            @Override
            public int getOutputPrefixTypeValue() {
                return this.outputPrefixType_;
            }
            
            public Builder setOutputPrefixTypeValue(final int value) {
                this.outputPrefixType_ = value;
                this.bitField0_ |= 0x8;
                this.onChanged();
                return this;
            }
            
            @Override
            public OutputPrefixType getOutputPrefixType() {
                final OutputPrefixType result = OutputPrefixType.forNumber(this.outputPrefixType_);
                return (result == null) ? OutputPrefixType.UNRECOGNIZED : result;
            }
            
            public Builder setOutputPrefixType(final OutputPrefixType value) {
                if (value == null) {
                    throw new NullPointerException();
                }
                this.bitField0_ |= 0x8;
                this.outputPrefixType_ = value.getNumber();
                this.onChanged();
                return this;
            }
            
            public Builder clearOutputPrefixType() {
                this.bitField0_ &= 0xFFFFFFF7;
                this.outputPrefixType_ = 0;
                this.onChanged();
                return this;
            }
        }
    }
    
    public static final class Builder extends GeneratedMessage.Builder<Builder> implements KeysetOrBuilder
    {
        private int bitField0_;
        private int primaryKeyId_;
        private List<Key> key_;
        private RepeatedFieldBuilder<Key, Key.Builder, KeyOrBuilder> keyBuilder_;
        
        public static final Descriptors.Descriptor getDescriptor() {
            return Tink.internal_static_google_crypto_tink_Keyset_descriptor;
        }
        
        @Override
        protected FieldAccessorTable internalGetFieldAccessorTable() {
            return Tink.internal_static_google_crypto_tink_Keyset_fieldAccessorTable.ensureFieldAccessorsInitialized(Keyset.class, Builder.class);
        }
        
        private Builder() {
            this.key_ = Collections.emptyList();
        }
        
        private Builder(final BuilderParent parent) {
            super(parent);
            this.key_ = Collections.emptyList();
        }
        
        @Override
        public Builder clear() {
            super.clear();
            this.bitField0_ = 0;
            this.primaryKeyId_ = 0;
            if (this.keyBuilder_ == null) {
                this.key_ = Collections.emptyList();
            }
            else {
                this.key_ = null;
                this.keyBuilder_.clear();
            }
            this.bitField0_ &= 0xFFFFFFFD;
            return this;
        }
        
        @Override
        public Descriptors.Descriptor getDescriptorForType() {
            return Tink.internal_static_google_crypto_tink_Keyset_descriptor;
        }
        
        @Override
        public Keyset getDefaultInstanceForType() {
            return Keyset.getDefaultInstance();
        }
        
        @Override
        public Keyset build() {
            final Keyset result = this.buildPartial();
            if (!result.isInitialized()) {
                throw AbstractMessage.Builder.newUninitializedMessageException(result);
            }
            return result;
        }
        
        @Override
        public Keyset buildPartial() {
            final Keyset result = new Keyset(this, null);
            this.buildPartialRepeatedFields(result);
            if (this.bitField0_ != 0) {
                this.buildPartial0(result);
            }
            this.onBuilt();
            return result;
        }
        
        private void buildPartialRepeatedFields(final Keyset result) {
            if (this.keyBuilder_ == null) {
                if ((this.bitField0_ & 0x2) != 0x0) {
                    this.key_ = Collections.unmodifiableList((List<? extends Key>)this.key_);
                    this.bitField0_ &= 0xFFFFFFFD;
                }
                result.key_ = this.key_;
            }
            else {
                result.key_ = this.keyBuilder_.build();
            }
        }
        
        private void buildPartial0(final Keyset result) {
            final int from_bitField0_ = this.bitField0_;
            if ((from_bitField0_ & 0x1) != 0x0) {
                result.primaryKeyId_ = this.primaryKeyId_;
            }
        }
        
        @Override
        public Builder mergeFrom(final Message other) {
            if (other instanceof Keyset) {
                return this.mergeFrom((Keyset)other);
            }
            super.mergeFrom(other);
            return this;
        }
        
        public Builder mergeFrom(final Keyset other) {
            if (other == Keyset.getDefaultInstance()) {
                return this;
            }
            if (other.getPrimaryKeyId() != 0) {
                this.setPrimaryKeyId(other.getPrimaryKeyId());
            }
            if (this.keyBuilder_ == null) {
                if (!other.key_.isEmpty()) {
                    if (this.key_.isEmpty()) {
                        this.key_ = other.key_;
                        this.bitField0_ &= 0xFFFFFFFD;
                    }
                    else {
                        this.ensureKeyIsMutable();
                        this.key_.addAll(other.key_);
                    }
                    this.onChanged();
                }
            }
            else if (!other.key_.isEmpty()) {
                if (this.keyBuilder_.isEmpty()) {
                    this.keyBuilder_.dispose();
                    this.keyBuilder_ = null;
                    this.key_ = other.key_;
                    this.bitField0_ &= 0xFFFFFFFD;
                    this.keyBuilder_ = (Keyset.alwaysUseFieldBuilders ? this.internalGetKeyFieldBuilder() : null);
                }
                else {
                    this.keyBuilder_.addAllMessages(other.key_);
                }
            }
            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 8: {
                            this.primaryKeyId_ = input.readUInt32();
                            this.bitField0_ |= 0x1;
                            continue;
                        }
                        case 18: {
                            final Key m = input.readMessage(Key.parser(), extensionRegistry);
                            if (this.keyBuilder_ == null) {
                                this.ensureKeyIsMutable();
                                this.key_.add(m);
                                continue;
                            }
                            this.keyBuilder_.addMessage(m);
                            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 int getPrimaryKeyId() {
            return this.primaryKeyId_;
        }
        
        public Builder setPrimaryKeyId(final int value) {
            this.primaryKeyId_ = value;
            this.bitField0_ |= 0x1;
            this.onChanged();
            return this;
        }
        
        public Builder clearPrimaryKeyId() {
            this.bitField0_ &= 0xFFFFFFFE;
            this.primaryKeyId_ = 0;
            this.onChanged();
            return this;
        }
        
        private void ensureKeyIsMutable() {
            if ((this.bitField0_ & 0x2) == 0x0) {
                this.key_ = new ArrayList<Key>(this.key_);
                this.bitField0_ |= 0x2;
            }
        }
        
        @Override
        public List<Key> getKeyList() {
            if (this.keyBuilder_ == null) {
                return Collections.unmodifiableList((List<? extends Key>)this.key_);
            }
            return this.keyBuilder_.getMessageList();
        }
        
        @Override
        public int getKeyCount() {
            if (this.keyBuilder_ == null) {
                return this.key_.size();
            }
            return this.keyBuilder_.getCount();
        }
        
        @Override
        public Key getKey(final int index) {
            if (this.keyBuilder_ == null) {
                return this.key_.get(index);
            }
            return this.keyBuilder_.getMessage(index);
        }
        
        public Builder setKey(final int index, final Key value) {
            if (this.keyBuilder_ == null) {
                if (value == null) {
                    throw new NullPointerException();
                }
                this.ensureKeyIsMutable();
                this.key_.set(index, value);
                this.onChanged();
            }
            else {
                this.keyBuilder_.setMessage(index, value);
            }
            return this;
        }
        
        public Builder setKey(final int index, final Key.Builder builderForValue) {
            if (this.keyBuilder_ == null) {
                this.ensureKeyIsMutable();
                this.key_.set(index, builderForValue.build());
                this.onChanged();
            }
            else {
                this.keyBuilder_.setMessage(index, builderForValue.build());
            }
            return this;
        }
        
        public Builder addKey(final Key value) {
            if (this.keyBuilder_ == null) {
                if (value == null) {
                    throw new NullPointerException();
                }
                this.ensureKeyIsMutable();
                this.key_.add(value);
                this.onChanged();
            }
            else {
                this.keyBuilder_.addMessage(value);
            }
            return this;
        }
        
        public Builder addKey(final int index, final Key value) {
            if (this.keyBuilder_ == null) {
                if (value == null) {
                    throw new NullPointerException();
                }
                this.ensureKeyIsMutable();
                this.key_.add(index, value);
                this.onChanged();
            }
            else {
                this.keyBuilder_.addMessage(index, value);
            }
            return this;
        }
        
        public Builder addKey(final Key.Builder builderForValue) {
            if (this.keyBuilder_ == null) {
                this.ensureKeyIsMutable();
                this.key_.add(builderForValue.build());
                this.onChanged();
            }
            else {
                this.keyBuilder_.addMessage(builderForValue.build());
            }
            return this;
        }
        
        public Builder addKey(final int index, final Key.Builder builderForValue) {
            if (this.keyBuilder_ == null) {
                this.ensureKeyIsMutable();
                this.key_.add(index, builderForValue.build());
                this.onChanged();
            }
            else {
                this.keyBuilder_.addMessage(index, builderForValue.build());
            }
            return this;
        }
        
        public Builder addAllKey(final Iterable<? extends Key> values) {
            if (this.keyBuilder_ == null) {
                this.ensureKeyIsMutable();
                AbstractMessageLite.Builder.addAll(values, this.key_);
                this.onChanged();
            }
            else {
                this.keyBuilder_.addAllMessages(values);
            }
            return this;
        }
        
        public Builder clearKey() {
            if (this.keyBuilder_ == null) {
                this.key_ = Collections.emptyList();
                this.bitField0_ &= 0xFFFFFFFD;
                this.onChanged();
            }
            else {
                this.keyBuilder_.clear();
            }
            return this;
        }
        
        public Builder removeKey(final int index) {
            if (this.keyBuilder_ == null) {
                this.ensureKeyIsMutable();
                this.key_.remove(index);
                this.onChanged();
            }
            else {
                this.keyBuilder_.remove(index);
            }
            return this;
        }
        
        public Key.Builder getKeyBuilder(final int index) {
            return this.internalGetKeyFieldBuilder().getBuilder(index);
        }
        
        @Override
        public KeyOrBuilder getKeyOrBuilder(final int index) {
            if (this.keyBuilder_ == null) {
                return this.key_.get(index);
            }
            return this.keyBuilder_.getMessageOrBuilder(index);
        }
        
        @Override
        public List<? extends KeyOrBuilder> getKeyOrBuilderList() {
            if (this.keyBuilder_ != null) {
                return this.keyBuilder_.getMessageOrBuilderList();
            }
            return Collections.unmodifiableList((List<? extends KeyOrBuilder>)this.key_);
        }
        
        public Key.Builder addKeyBuilder() {
            return this.internalGetKeyFieldBuilder().addBuilder(Key.getDefaultInstance());
        }
        
        public Key.Builder addKeyBuilder(final int index) {
            return this.internalGetKeyFieldBuilder().addBuilder(index, Key.getDefaultInstance());
        }
        
        public List<Key.Builder> getKeyBuilderList() {
            return this.internalGetKeyFieldBuilder().getBuilderList();
        }
        
        private RepeatedFieldBuilder<Key, Key.Builder, KeyOrBuilder> internalGetKeyFieldBuilder() {
            if (this.keyBuilder_ == null) {
                this.keyBuilder_ = new RepeatedFieldBuilder<Key, Key.Builder, KeyOrBuilder>(this.key_, (this.bitField0_ & 0x2) != 0x0, this.getParentForChildren(), this.isClean());
                this.key_ = null;
            }
            return this.keyBuilder_;
        }
    }
    
    public interface KeyOrBuilder extends MessageOrBuilder
    {
        boolean hasKeyData();
        
        KeyData getKeyData();
        
        KeyDataOrBuilder getKeyDataOrBuilder();
        
        int getStatusValue();
        
        KeyStatusType getStatus();
        
        int getKeyId();
        
        int getOutputPrefixTypeValue();
        
        OutputPrefixType getOutputPrefixType();
    }
}
