// Code generated by protocol buffer compiler. Do not edit!
package emu.nebula.proto;

import java.io.IOException;
import us.hebi.quickbuf.FieldName;
import us.hebi.quickbuf.InvalidProtocolBufferException;
import us.hebi.quickbuf.JsonSink;
import us.hebi.quickbuf.JsonSource;
import us.hebi.quickbuf.MessageFactory;
import us.hebi.quickbuf.ProtoMessage;
import us.hebi.quickbuf.ProtoSink;
import us.hebi.quickbuf.ProtoSource;
import us.hebi.quickbuf.RepeatedByte;
import us.hebi.quickbuf.Utf8String;

public final class Ike {
  /**
   * Protobuf type {@code IKEReq}
   */
  public static final class IKEReq extends ProtoMessage<IKEReq> implements Cloneable {
    private static final long serialVersionUID = 0L;

    /**
     * <code>optional int64 ClientTs = 2;</code>
     */
    private long clientTs;

    /**
     * <code>optional int32 ProtoVersion = 1;</code>
     */
    private int protoVersion;

    /**
     * <code>optional bytes PubKey = 3;</code>
     */
    private final RepeatedByte pubKey = RepeatedByte.newEmptyInstance();

    /**
     * <code>optional bytes NextPackage = 2047;</code>
     */
    private final RepeatedByte nextPackage = RepeatedByte.newEmptyInstance();

    private IKEReq() {
    }

    /**
     * @return a new empty instance of {@code IKEReq}
     */
    public static IKEReq newInstance() {
      return new IKEReq();
    }

    /**
     * <code>optional int64 ClientTs = 2;</code>
     * @return whether the clientTs field is set
     */
    public boolean hasClientTs() {
      return (bitField0_ & 0x00000001) != 0;
    }

    /**
     * <code>optional int64 ClientTs = 2;</code>
     * @return this
     */
    public IKEReq clearClientTs() {
      bitField0_ &= ~0x00000001;
      clientTs = 0L;
      return this;
    }

    /**
     * <code>optional int64 ClientTs = 2;</code>
     * @return the clientTs
     */
    public long getClientTs() {
      return clientTs;
    }

    /**
     * <code>optional int64 ClientTs = 2;</code>
     * @param value the clientTs to set
     * @return this
     */
    public IKEReq setClientTs(final long value) {
      bitField0_ |= 0x00000001;
      clientTs = value;
      return this;
    }

    /**
     * <code>optional int32 ProtoVersion = 1;</code>
     * @return whether the protoVersion field is set
     */
    public boolean hasProtoVersion() {
      return (bitField0_ & 0x00000002) != 0;
    }

    /**
     * <code>optional int32 ProtoVersion = 1;</code>
     * @return this
     */
    public IKEReq clearProtoVersion() {
      bitField0_ &= ~0x00000002;
      protoVersion = 0;
      return this;
    }

    /**
     * <code>optional int32 ProtoVersion = 1;</code>
     * @return the protoVersion
     */
    public int getProtoVersion() {
      return protoVersion;
    }

    /**
     * <code>optional int32 ProtoVersion = 1;</code>
     * @param value the protoVersion to set
     * @return this
     */
    public IKEReq setProtoVersion(final int value) {
      bitField0_ |= 0x00000002;
      protoVersion = value;
      return this;
    }

    /**
     * <code>optional bytes PubKey = 3;</code>
     * @return whether the pubKey field is set
     */
    public boolean hasPubKey() {
      return (bitField0_ & 0x00000004) != 0;
    }

    /**
     * <code>optional bytes PubKey = 3;</code>
     * @return this
     */
    public IKEReq clearPubKey() {
      bitField0_ &= ~0x00000004;
      pubKey.clear();
      return this;
    }

    /**
     * <code>optional bytes PubKey = 3;</code>
     *
     * This method returns the internal storage object without modifying any has state.
     * The returned object should not be modified and be treated as read-only.
     *
     * Use {@link #getMutablePubKey()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public RepeatedByte getPubKey() {
      return pubKey;
    }

    /**
     * <code>optional bytes PubKey = 3;</code>
     *
     * This method returns the internal storage object and sets the corresponding
     * has state. The returned object will become part of this message and its
     * contents may be modified as long as the has state is not cleared.
     *
     * @return internal storage object for modifications
     */
    public RepeatedByte getMutablePubKey() {
      bitField0_ |= 0x00000004;
      return pubKey;
    }

    /**
     * <code>optional bytes PubKey = 3;</code>
     * @param value the pubKey to add
     * @return this
     */
    public IKEReq addPubKey(final byte value) {
      bitField0_ |= 0x00000004;
      pubKey.add(value);
      return this;
    }

    /**
     * <code>optional bytes PubKey = 3;</code>
     * @param values the pubKey to add
     * @return this
     */
    public IKEReq addAllPubKey(final byte... values) {
      bitField0_ |= 0x00000004;
      pubKey.addAll(values);
      return this;
    }

    /**
     * <code>optional bytes PubKey = 3;</code>
     * @param values the pubKey to set
     * @return this
     */
    public IKEReq setPubKey(final byte... values) {
      bitField0_ |= 0x00000004;
      pubKey.copyFrom(values);
      return this;
    }

    /**
     * <code>optional bytes NextPackage = 2047;</code>
     * @return whether the nextPackage field is set
     */
    public boolean hasNextPackage() {
      return (bitField0_ & 0x00000008) != 0;
    }

    /**
     * <code>optional bytes NextPackage = 2047;</code>
     * @return this
     */
    public IKEReq clearNextPackage() {
      bitField0_ &= ~0x00000008;
      nextPackage.clear();
      return this;
    }

    /**
     * <code>optional bytes NextPackage = 2047;</code>
     *
     * This method returns the internal storage object without modifying any has state.
     * The returned object should not be modified and be treated as read-only.
     *
     * Use {@link #getMutableNextPackage()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public RepeatedByte getNextPackage() {
      return nextPackage;
    }

    /**
     * <code>optional bytes NextPackage = 2047;</code>
     *
     * This method returns the internal storage object and sets the corresponding
     * has state. The returned object will become part of this message and its
     * contents may be modified as long as the has state is not cleared.
     *
     * @return internal storage object for modifications
     */
    public RepeatedByte getMutableNextPackage() {
      bitField0_ |= 0x00000008;
      return nextPackage;
    }

    /**
     * <code>optional bytes NextPackage = 2047;</code>
     * @param value the nextPackage to add
     * @return this
     */
    public IKEReq addNextPackage(final byte value) {
      bitField0_ |= 0x00000008;
      nextPackage.add(value);
      return this;
    }

    /**
     * <code>optional bytes NextPackage = 2047;</code>
     * @param values the nextPackage to add
     * @return this
     */
    public IKEReq addAllNextPackage(final byte... values) {
      bitField0_ |= 0x00000008;
      nextPackage.addAll(values);
      return this;
    }

    /**
     * <code>optional bytes NextPackage = 2047;</code>
     * @param values the nextPackage to set
     * @return this
     */
    public IKEReq setNextPackage(final byte... values) {
      bitField0_ |= 0x00000008;
      nextPackage.copyFrom(values);
      return this;
    }

    @Override
    public IKEReq copyFrom(final IKEReq other) {
      cachedSize = other.cachedSize;
      if ((bitField0_ | other.bitField0_) != 0) {
        bitField0_ = other.bitField0_;
        clientTs = other.clientTs;
        protoVersion = other.protoVersion;
        pubKey.copyFrom(other.pubKey);
        nextPackage.copyFrom(other.nextPackage);
      }
      return this;
    }

    @Override
    public IKEReq mergeFrom(final IKEReq other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasClientTs()) {
        setClientTs(other.clientTs);
      }
      if (other.hasProtoVersion()) {
        setProtoVersion(other.protoVersion);
      }
      if (other.hasPubKey()) {
        getMutablePubKey().copyFrom(other.pubKey);
      }
      if (other.hasNextPackage()) {
        getMutableNextPackage().copyFrom(other.nextPackage);
      }
      return this;
    }

    @Override
    public IKEReq clear() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      clientTs = 0L;
      protoVersion = 0;
      pubKey.clear();
      nextPackage.clear();
      return this;
    }

    @Override
    public IKEReq clearQuick() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      pubKey.clear();
      nextPackage.clear();
      return this;
    }

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (!(o instanceof IKEReq)) {
        return false;
      }
      IKEReq other = (IKEReq) o;
      return bitField0_ == other.bitField0_
        && (!hasClientTs() || clientTs == other.clientTs)
        && (!hasProtoVersion() || protoVersion == other.protoVersion)
        && (!hasPubKey() || pubKey.equals(other.pubKey))
        && (!hasNextPackage() || nextPackage.equals(other.nextPackage));
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawByte((byte) 16);
        output.writeInt64NoTag(clientTs);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeRawByte((byte) 8);
        output.writeInt32NoTag(protoVersion);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeRawByte((byte) 26);
        output.writeBytesNoTag(pubKey);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        output.writeRawLittleEndian16((short) 32762);
        output.writeBytesNoTag(nextPackage);
      }
    }

    @Override
    protected int computeSerializedSize() {
      int size = 0;
      if ((bitField0_ & 0x00000001) != 0) {
        size += 1 + ProtoSink.computeInt64SizeNoTag(clientTs);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        size += 1 + ProtoSink.computeInt32SizeNoTag(protoVersion);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        size += 1 + ProtoSink.computeBytesSizeNoTag(pubKey);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        size += 2 + ProtoSink.computeBytesSizeNoTag(nextPackage);
      }
      return size;
    }

    @Override
    @SuppressWarnings("fallthrough")
    public IKEReq mergeFrom(final ProtoSource input) throws IOException {
      // Enabled Fall-Through Optimization (QuickBuffers)
      int tag = input.readTag();
      while (true) {
        switch (tag) {
          case 16: {
            // clientTs
            clientTs = input.readInt64();
            bitField0_ |= 0x00000001;
            tag = input.readTag();
            if (tag != 8) {
              break;
            }
          }
          case 8: {
            // protoVersion
            protoVersion = input.readInt32();
            bitField0_ |= 0x00000002;
            tag = input.readTag();
            if (tag != 26) {
              break;
            }
          }
          case 26: {
            // pubKey
            input.readBytes(pubKey);
            bitField0_ |= 0x00000004;
            tag = input.readTag();
            if (tag != 16378) {
              break;
            }
          }
          case 16378: {
            // nextPackage
            input.readBytes(nextPackage);
            bitField0_ |= 0x00000008;
            tag = input.readTag();
            if (tag != 0) {
              break;
            }
          }
          case 0: {
            return this;
          }
          default: {
            if (!input.skipField(tag)) {
              return this;
            }
            tag = input.readTag();
            break;
          }
        }
      }
    }

    @Override
    public void writeTo(final JsonSink output) throws IOException {
      output.beginObject();
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeInt64(FieldNames.clientTs, clientTs);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeInt32(FieldNames.protoVersion, protoVersion);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeBytes(FieldNames.pubKey, pubKey);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        output.writeBytes(FieldNames.nextPackage, nextPackage);
      }
      output.endObject();
    }

    @Override
    public IKEReq mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case 973052874: {
            if (input.isAtField(FieldNames.clientTs)) {
              if (!input.trySkipNullValue()) {
                clientTs = input.readInt64();
                bitField0_ |= 0x00000001;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 1392888304: {
            if (input.isAtField(FieldNames.protoVersion)) {
              if (!input.trySkipNullValue()) {
                protoVersion = input.readInt32();
                bitField0_ |= 0x00000002;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -1893588414: {
            if (input.isAtField(FieldNames.pubKey)) {
              if (!input.trySkipNullValue()) {
                input.readBytes(pubKey);
                bitField0_ |= 0x00000004;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -2082324045: {
            if (input.isAtField(FieldNames.nextPackage)) {
              if (!input.trySkipNullValue()) {
                input.readBytes(nextPackage);
                bitField0_ |= 0x00000008;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

    @Override
    public IKEReq clone() {
      return new IKEReq().copyFrom(this);
    }

    @Override
    public boolean isEmpty() {
      return ((bitField0_) == 0);
    }

    public static IKEReq parseFrom(final byte[] data) throws InvalidProtocolBufferException {
      return ProtoMessage.mergeFrom(new IKEReq(), data).checkInitialized();
    }

    public static IKEReq parseFrom(final ProtoSource input) throws IOException {
      return ProtoMessage.mergeFrom(new IKEReq(), input).checkInitialized();
    }

    public static IKEReq parseFrom(final JsonSource input) throws IOException {
      return ProtoMessage.mergeFrom(new IKEReq(), input).checkInitialized();
    }

    /**
     * @return factory for creating IKEReq messages
     */
    public static MessageFactory<IKEReq> getFactory() {
      return IKEReqFactory.INSTANCE;
    }

    private enum IKEReqFactory implements MessageFactory<IKEReq> {
      INSTANCE;

      @Override
      public IKEReq create() {
        return IKEReq.newInstance();
      }
    }

    /**
     * Contains name constants used for serializing JSON
     */
    static class FieldNames {
      static final FieldName clientTs = FieldName.forField("ClientTs");

      static final FieldName protoVersion = FieldName.forField("ProtoVersion");

      static final FieldName pubKey = FieldName.forField("PubKey");

      static final FieldName nextPackage = FieldName.forField("NextPackage");
    }
  }

  /**
   * Protobuf type {@code IKEResp}
   */
  public static final class IKEResp extends ProtoMessage<IKEResp> implements Cloneable {
    private static final long serialVersionUID = 0L;

    /**
     * <code>optional int64 ServerTs = 3;</code>
     */
    private long serverTs;

    /**
     * <code>optional int32 Cipher = 2;</code>
     */
    private int cipher;

    /**
     * <code>optional bytes PubKey = 4;</code>
     */
    private final RepeatedByte pubKey = RepeatedByte.newEmptyInstance();

    /**
     * <code>optional bytes NextPackage = 2047;</code>
     */
    private final RepeatedByte nextPackage = RepeatedByte.newEmptyInstance();

    /**
     * <code>optional string Token = 1;</code>
     */
    private final Utf8String token = Utf8String.newEmptyInstance();

    private IKEResp() {
    }

    /**
     * @return a new empty instance of {@code IKEResp}
     */
    public static IKEResp newInstance() {
      return new IKEResp();
    }

    /**
     * <code>optional int64 ServerTs = 3;</code>
     * @return whether the serverTs field is set
     */
    public boolean hasServerTs() {
      return (bitField0_ & 0x00000001) != 0;
    }

    /**
     * <code>optional int64 ServerTs = 3;</code>
     * @return this
     */
    public IKEResp clearServerTs() {
      bitField0_ &= ~0x00000001;
      serverTs = 0L;
      return this;
    }

    /**
     * <code>optional int64 ServerTs = 3;</code>
     * @return the serverTs
     */
    public long getServerTs() {
      return serverTs;
    }

    /**
     * <code>optional int64 ServerTs = 3;</code>
     * @param value the serverTs to set
     * @return this
     */
    public IKEResp setServerTs(final long value) {
      bitField0_ |= 0x00000001;
      serverTs = value;
      return this;
    }

    /**
     * <code>optional int32 Cipher = 2;</code>
     * @return whether the cipher field is set
     */
    public boolean hasCipher() {
      return (bitField0_ & 0x00000002) != 0;
    }

    /**
     * <code>optional int32 Cipher = 2;</code>
     * @return this
     */
    public IKEResp clearCipher() {
      bitField0_ &= ~0x00000002;
      cipher = 0;
      return this;
    }

    /**
     * <code>optional int32 Cipher = 2;</code>
     * @return the cipher
     */
    public int getCipher() {
      return cipher;
    }

    /**
     * <code>optional int32 Cipher = 2;</code>
     * @param value the cipher to set
     * @return this
     */
    public IKEResp setCipher(final int value) {
      bitField0_ |= 0x00000002;
      cipher = value;
      return this;
    }

    /**
     * <code>optional bytes PubKey = 4;</code>
     * @return whether the pubKey field is set
     */
    public boolean hasPubKey() {
      return (bitField0_ & 0x00000004) != 0;
    }

    /**
     * <code>optional bytes PubKey = 4;</code>
     * @return this
     */
    public IKEResp clearPubKey() {
      bitField0_ &= ~0x00000004;
      pubKey.clear();
      return this;
    }

    /**
     * <code>optional bytes PubKey = 4;</code>
     *
     * This method returns the internal storage object without modifying any has state.
     * The returned object should not be modified and be treated as read-only.
     *
     * Use {@link #getMutablePubKey()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public RepeatedByte getPubKey() {
      return pubKey;
    }

    /**
     * <code>optional bytes PubKey = 4;</code>
     *
     * This method returns the internal storage object and sets the corresponding
     * has state. The returned object will become part of this message and its
     * contents may be modified as long as the has state is not cleared.
     *
     * @return internal storage object for modifications
     */
    public RepeatedByte getMutablePubKey() {
      bitField0_ |= 0x00000004;
      return pubKey;
    }

    /**
     * <code>optional bytes PubKey = 4;</code>
     * @param value the pubKey to add
     * @return this
     */
    public IKEResp addPubKey(final byte value) {
      bitField0_ |= 0x00000004;
      pubKey.add(value);
      return this;
    }

    /**
     * <code>optional bytes PubKey = 4;</code>
     * @param values the pubKey to add
     * @return this
     */
    public IKEResp addAllPubKey(final byte... values) {
      bitField0_ |= 0x00000004;
      pubKey.addAll(values);
      return this;
    }

    /**
     * <code>optional bytes PubKey = 4;</code>
     * @param values the pubKey to set
     * @return this
     */
    public IKEResp setPubKey(final byte... values) {
      bitField0_ |= 0x00000004;
      pubKey.copyFrom(values);
      return this;
    }

    /**
     * <code>optional bytes NextPackage = 2047;</code>
     * @return whether the nextPackage field is set
     */
    public boolean hasNextPackage() {
      return (bitField0_ & 0x00000008) != 0;
    }

    /**
     * <code>optional bytes NextPackage = 2047;</code>
     * @return this
     */
    public IKEResp clearNextPackage() {
      bitField0_ &= ~0x00000008;
      nextPackage.clear();
      return this;
    }

    /**
     * <code>optional bytes NextPackage = 2047;</code>
     *
     * This method returns the internal storage object without modifying any has state.
     * The returned object should not be modified and be treated as read-only.
     *
     * Use {@link #getMutableNextPackage()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public RepeatedByte getNextPackage() {
      return nextPackage;
    }

    /**
     * <code>optional bytes NextPackage = 2047;</code>
     *
     * This method returns the internal storage object and sets the corresponding
     * has state. The returned object will become part of this message and its
     * contents may be modified as long as the has state is not cleared.
     *
     * @return internal storage object for modifications
     */
    public RepeatedByte getMutableNextPackage() {
      bitField0_ |= 0x00000008;
      return nextPackage;
    }

    /**
     * <code>optional bytes NextPackage = 2047;</code>
     * @param value the nextPackage to add
     * @return this
     */
    public IKEResp addNextPackage(final byte value) {
      bitField0_ |= 0x00000008;
      nextPackage.add(value);
      return this;
    }

    /**
     * <code>optional bytes NextPackage = 2047;</code>
     * @param values the nextPackage to add
     * @return this
     */
    public IKEResp addAllNextPackage(final byte... values) {
      bitField0_ |= 0x00000008;
      nextPackage.addAll(values);
      return this;
    }

    /**
     * <code>optional bytes NextPackage = 2047;</code>
     * @param values the nextPackage to set
     * @return this
     */
    public IKEResp setNextPackage(final byte... values) {
      bitField0_ |= 0x00000008;
      nextPackage.copyFrom(values);
      return this;
    }

    /**
     * <code>optional string Token = 1;</code>
     * @return whether the token field is set
     */
    public boolean hasToken() {
      return (bitField0_ & 0x00000010) != 0;
    }

    /**
     * <code>optional string Token = 1;</code>
     * @return this
     */
    public IKEResp clearToken() {
      bitField0_ &= ~0x00000010;
      token.clear();
      return this;
    }

    /**
     * <code>optional string Token = 1;</code>
     * @return the token
     */
    public String getToken() {
      return token.getString();
    }

    /**
     * <code>optional string Token = 1;</code>
     * @return internal {@code Utf8String} representation of token for reading
     */
    public Utf8String getTokenBytes() {
      return this.token;
    }

    /**
     * <code>optional string Token = 1;</code>
     * @return internal {@code Utf8String} representation of token for modifications
     */
    public Utf8String getMutableTokenBytes() {
      bitField0_ |= 0x00000010;
      return this.token;
    }

    /**
     * <code>optional string Token = 1;</code>
     * @param value the token to set
     * @return this
     */
    public IKEResp setToken(final CharSequence value) {
      bitField0_ |= 0x00000010;
      token.copyFrom(value);
      return this;
    }

    /**
     * <code>optional string Token = 1;</code>
     * @param value the token to set
     * @return this
     */
    public IKEResp setToken(final Utf8String value) {
      bitField0_ |= 0x00000010;
      token.copyFrom(value);
      return this;
    }

    @Override
    public IKEResp copyFrom(final IKEResp other) {
      cachedSize = other.cachedSize;
      if ((bitField0_ | other.bitField0_) != 0) {
        bitField0_ = other.bitField0_;
        serverTs = other.serverTs;
        cipher = other.cipher;
        pubKey.copyFrom(other.pubKey);
        nextPackage.copyFrom(other.nextPackage);
        token.copyFrom(other.token);
      }
      return this;
    }

    @Override
    public IKEResp mergeFrom(final IKEResp other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasServerTs()) {
        setServerTs(other.serverTs);
      }
      if (other.hasCipher()) {
        setCipher(other.cipher);
      }
      if (other.hasPubKey()) {
        getMutablePubKey().copyFrom(other.pubKey);
      }
      if (other.hasNextPackage()) {
        getMutableNextPackage().copyFrom(other.nextPackage);
      }
      if (other.hasToken()) {
        getMutableTokenBytes().copyFrom(other.token);
      }
      return this;
    }

    @Override
    public IKEResp clear() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      serverTs = 0L;
      cipher = 0;
      pubKey.clear();
      nextPackage.clear();
      token.clear();
      return this;
    }

    @Override
    public IKEResp clearQuick() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      pubKey.clear();
      nextPackage.clear();
      token.clear();
      return this;
    }

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (!(o instanceof IKEResp)) {
        return false;
      }
      IKEResp other = (IKEResp) o;
      return bitField0_ == other.bitField0_
        && (!hasServerTs() || serverTs == other.serverTs)
        && (!hasCipher() || cipher == other.cipher)
        && (!hasPubKey() || pubKey.equals(other.pubKey))
        && (!hasNextPackage() || nextPackage.equals(other.nextPackage))
        && (!hasToken() || token.equals(other.token));
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawByte((byte) 24);
        output.writeInt64NoTag(serverTs);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeRawByte((byte) 16);
        output.writeInt32NoTag(cipher);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeRawByte((byte) 34);
        output.writeBytesNoTag(pubKey);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        output.writeRawLittleEndian16((short) 32762);
        output.writeBytesNoTag(nextPackage);
      }
      if ((bitField0_ & 0x00000010) != 0) {
        output.writeRawByte((byte) 10);
        output.writeStringNoTag(token);
      }
    }

    @Override
    protected int computeSerializedSize() {
      int size = 0;
      if ((bitField0_ & 0x00000001) != 0) {
        size += 1 + ProtoSink.computeInt64SizeNoTag(serverTs);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        size += 1 + ProtoSink.computeInt32SizeNoTag(cipher);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        size += 1 + ProtoSink.computeBytesSizeNoTag(pubKey);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        size += 2 + ProtoSink.computeBytesSizeNoTag(nextPackage);
      }
      if ((bitField0_ & 0x00000010) != 0) {
        size += 1 + ProtoSink.computeStringSizeNoTag(token);
      }
      return size;
    }

    @Override
    @SuppressWarnings("fallthrough")
    public IKEResp mergeFrom(final ProtoSource input) throws IOException {
      // Enabled Fall-Through Optimization (QuickBuffers)
      int tag = input.readTag();
      while (true) {
        switch (tag) {
          case 24: {
            // serverTs
            serverTs = input.readInt64();
            bitField0_ |= 0x00000001;
            tag = input.readTag();
            if (tag != 16) {
              break;
            }
          }
          case 16: {
            // cipher
            cipher = input.readInt32();
            bitField0_ |= 0x00000002;
            tag = input.readTag();
            if (tag != 34) {
              break;
            }
          }
          case 34: {
            // pubKey
            input.readBytes(pubKey);
            bitField0_ |= 0x00000004;
            tag = input.readTag();
            if (tag != 16378) {
              break;
            }
          }
          case 16378: {
            // nextPackage
            input.readBytes(nextPackage);
            bitField0_ |= 0x00000008;
            tag = input.readTag();
            if (tag != 10) {
              break;
            }
          }
          case 10: {
            // token
            input.readString(token);
            bitField0_ |= 0x00000010;
            tag = input.readTag();
            if (tag != 0) {
              break;
            }
          }
          case 0: {
            return this;
          }
          default: {
            if (!input.skipField(tag)) {
              return this;
            }
            tag = input.readTag();
            break;
          }
        }
      }
    }

    @Override
    public void writeTo(final JsonSink output) throws IOException {
      output.beginObject();
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeInt64(FieldNames.serverTs, serverTs);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeInt32(FieldNames.cipher, cipher);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeBytes(FieldNames.pubKey, pubKey);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        output.writeBytes(FieldNames.nextPackage, nextPackage);
      }
      if ((bitField0_ & 0x00000010) != 0) {
        output.writeString(FieldNames.token, token);
      }
      output.endObject();
    }

    @Override
    public IKEResp mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case 1443748162: {
            if (input.isAtField(FieldNames.serverTs)) {
              if (!input.trySkipNullValue()) {
                serverTs = input.readInt64();
                bitField0_ |= 0x00000001;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 2018562603: {
            if (input.isAtField(FieldNames.cipher)) {
              if (!input.trySkipNullValue()) {
                cipher = input.readInt32();
                bitField0_ |= 0x00000002;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -1893588414: {
            if (input.isAtField(FieldNames.pubKey)) {
              if (!input.trySkipNullValue()) {
                input.readBytes(pubKey);
                bitField0_ |= 0x00000004;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -2082324045: {
            if (input.isAtField(FieldNames.nextPackage)) {
              if (!input.trySkipNullValue()) {
                input.readBytes(nextPackage);
                bitField0_ |= 0x00000008;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 80988633: {
            if (input.isAtField(FieldNames.token)) {
              if (!input.trySkipNullValue()) {
                input.readString(token);
                bitField0_ |= 0x00000010;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

    @Override
    public IKEResp clone() {
      return new IKEResp().copyFrom(this);
    }

    @Override
    public boolean isEmpty() {
      return ((bitField0_) == 0);
    }

    public static IKEResp parseFrom(final byte[] data) throws InvalidProtocolBufferException {
      return ProtoMessage.mergeFrom(new IKEResp(), data).checkInitialized();
    }

    public static IKEResp parseFrom(final ProtoSource input) throws IOException {
      return ProtoMessage.mergeFrom(new IKEResp(), input).checkInitialized();
    }

    public static IKEResp parseFrom(final JsonSource input) throws IOException {
      return ProtoMessage.mergeFrom(new IKEResp(), input).checkInitialized();
    }

    /**
     * @return factory for creating IKEResp messages
     */
    public static MessageFactory<IKEResp> getFactory() {
      return IKERespFactory.INSTANCE;
    }

    private enum IKERespFactory implements MessageFactory<IKEResp> {
      INSTANCE;

      @Override
      public IKEResp create() {
        return IKEResp.newInstance();
      }
    }

    /**
     * Contains name constants used for serializing JSON
     */
    static class FieldNames {
      static final FieldName serverTs = FieldName.forField("ServerTs");

      static final FieldName cipher = FieldName.forField("Cipher");

      static final FieldName pubKey = FieldName.forField("PubKey");

      static final FieldName nextPackage = FieldName.forField("NextPackage");

      static final FieldName token = FieldName.forField("Token");
    }
  }
}
