// 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.RepeatedMessage;
import us.hebi.quickbuf.Utf8String;

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

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

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

    private FriendNameSearchReq() {
    }

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

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

    /**
     * <code>optional bytes NextPackage = 2047;</code>
     * @return this
     */
    public FriendNameSearchReq clearNextPackage() {
      bitField0_ &= ~0x00000001;
      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_ |= 0x00000001;
      return nextPackage;
    }

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

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

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

    /**
     * <code>optional string Name = 1;</code>
     * @return whether the name field is set
     */
    public boolean hasName() {
      return (bitField0_ & 0x00000002) != 0;
    }

    /**
     * <code>optional string Name = 1;</code>
     * @return this
     */
    public FriendNameSearchReq clearName() {
      bitField0_ &= ~0x00000002;
      name.clear();
      return this;
    }

    /**
     * <code>optional string Name = 1;</code>
     * @return the name
     */
    public String getName() {
      return name.getString();
    }

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

    /**
     * <code>optional string Name = 1;</code>
     * @return internal {@code Utf8String} representation of name for modifications
     */
    public Utf8String getMutableNameBytes() {
      bitField0_ |= 0x00000002;
      return this.name;
    }

    /**
     * <code>optional string Name = 1;</code>
     * @param value the name to set
     * @return this
     */
    public FriendNameSearchReq setName(final CharSequence value) {
      bitField0_ |= 0x00000002;
      name.copyFrom(value);
      return this;
    }

    /**
     * <code>optional string Name = 1;</code>
     * @param value the name to set
     * @return this
     */
    public FriendNameSearchReq setName(final Utf8String value) {
      bitField0_ |= 0x00000002;
      name.copyFrom(value);
      return this;
    }

    @Override
    public FriendNameSearchReq copyFrom(final FriendNameSearchReq other) {
      cachedSize = other.cachedSize;
      if ((bitField0_ | other.bitField0_) != 0) {
        bitField0_ = other.bitField0_;
        nextPackage.copyFrom(other.nextPackage);
        name.copyFrom(other.name);
      }
      return this;
    }

    @Override
    public FriendNameSearchReq mergeFrom(final FriendNameSearchReq other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasNextPackage()) {
        getMutableNextPackage().copyFrom(other.nextPackage);
      }
      if (other.hasName()) {
        getMutableNameBytes().copyFrom(other.name);
      }
      return this;
    }

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

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

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (!(o instanceof FriendNameSearchReq)) {
        return false;
      }
      FriendNameSearchReq other = (FriendNameSearchReq) o;
      return bitField0_ == other.bitField0_
        && (!hasNextPackage() || nextPackage.equals(other.nextPackage))
        && (!hasName() || name.equals(other.name));
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawLittleEndian16((short) 32762);
        output.writeBytesNoTag(nextPackage);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeRawByte((byte) 10);
        output.writeStringNoTag(name);
      }
    }

    @Override
    protected int computeSerializedSize() {
      int size = 0;
      if ((bitField0_ & 0x00000001) != 0) {
        size += 2 + ProtoSink.computeBytesSizeNoTag(nextPackage);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        size += 1 + ProtoSink.computeStringSizeNoTag(name);
      }
      return size;
    }

    @Override
    @SuppressWarnings("fallthrough")
    public FriendNameSearchReq mergeFrom(final ProtoSource input) throws IOException {
      // Enabled Fall-Through Optimization (QuickBuffers)
      int tag = input.readTag();
      while (true) {
        switch (tag) {
          case 16378: {
            // nextPackage
            input.readBytes(nextPackage);
            bitField0_ |= 0x00000001;
            tag = input.readTag();
            if (tag != 10) {
              break;
            }
          }
          case 10: {
            // name
            input.readString(name);
            bitField0_ |= 0x00000002;
            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.writeBytes(FieldNames.nextPackage, nextPackage);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeString(FieldNames.name, name);
      }
      output.endObject();
    }

    @Override
    public FriendNameSearchReq mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case -2082324045: {
            if (input.isAtField(FieldNames.nextPackage)) {
              if (!input.trySkipNullValue()) {
                input.readBytes(nextPackage);
                bitField0_ |= 0x00000001;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 2420395: {
            if (input.isAtField(FieldNames.name)) {
              if (!input.trySkipNullValue()) {
                input.readString(name);
                bitField0_ |= 0x00000002;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum FriendNameSearchReqFactory implements MessageFactory<FriendNameSearchReq> {
      INSTANCE;

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

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

      static final FieldName name = FieldName.forField("Name");
    }
  }

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

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

    /**
     * <code>repeated .Friend Friends = 1;</code>
     */
    private final RepeatedMessage<Public.Friend> friends = RepeatedMessage.newEmptyInstance(Public.Friend.getFactory());

    private FriendNameSearchResp() {
    }

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

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

    /**
     * <code>optional bytes NextPackage = 2047;</code>
     * @return this
     */
    public FriendNameSearchResp clearNextPackage() {
      bitField0_ &= ~0x00000001;
      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_ |= 0x00000001;
      return nextPackage;
    }

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

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

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

    /**
     * <code>repeated .Friend Friends = 1;</code>
     * @return whether the friends field is set
     */
    public boolean hasFriends() {
      return (bitField0_ & 0x00000002) != 0;
    }

    /**
     * <code>repeated .Friend Friends = 1;</code>
     * @return this
     */
    public FriendNameSearchResp clearFriends() {
      bitField0_ &= ~0x00000002;
      friends.clear();
      return this;
    }

    /**
     * <code>repeated .Friend Friends = 1;</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 #getMutableFriends()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public RepeatedMessage<Public.Friend> getFriends() {
      return friends;
    }

    /**
     * <code>repeated .Friend Friends = 1;</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 RepeatedMessage<Public.Friend> getMutableFriends() {
      bitField0_ |= 0x00000002;
      return friends;
    }

    /**
     * <code>repeated .Friend Friends = 1;</code>
     * @param value the friends to add
     * @return this
     */
    public FriendNameSearchResp addFriends(final Public.Friend value) {
      bitField0_ |= 0x00000002;
      friends.add(value);
      return this;
    }

    /**
     * <code>repeated .Friend Friends = 1;</code>
     * @param values the friends to add
     * @return this
     */
    public FriendNameSearchResp addAllFriends(final Public.Friend... values) {
      bitField0_ |= 0x00000002;
      friends.addAll(values);
      return this;
    }

    @Override
    public FriendNameSearchResp copyFrom(final FriendNameSearchResp other) {
      cachedSize = other.cachedSize;
      if ((bitField0_ | other.bitField0_) != 0) {
        bitField0_ = other.bitField0_;
        nextPackage.copyFrom(other.nextPackage);
        friends.copyFrom(other.friends);
      }
      return this;
    }

    @Override
    public FriendNameSearchResp mergeFrom(final FriendNameSearchResp other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasNextPackage()) {
        getMutableNextPackage().copyFrom(other.nextPackage);
      }
      if (other.hasFriends()) {
        getMutableFriends().addAll(other.friends);
      }
      return this;
    }

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

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

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (!(o instanceof FriendNameSearchResp)) {
        return false;
      }
      FriendNameSearchResp other = (FriendNameSearchResp) o;
      return bitField0_ == other.bitField0_
        && (!hasNextPackage() || nextPackage.equals(other.nextPackage))
        && (!hasFriends() || friends.equals(other.friends));
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawLittleEndian16((short) 32762);
        output.writeBytesNoTag(nextPackage);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        for (int i = 0; i < friends.length(); i++) {
          output.writeRawByte((byte) 10);
          output.writeMessageNoTag(friends.get(i));
        }
      }
    }

    @Override
    protected int computeSerializedSize() {
      int size = 0;
      if ((bitField0_ & 0x00000001) != 0) {
        size += 2 + ProtoSink.computeBytesSizeNoTag(nextPackage);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        size += (1 * friends.length()) + ProtoSink.computeRepeatedMessageSizeNoTag(friends);
      }
      return size;
    }

    @Override
    @SuppressWarnings("fallthrough")
    public FriendNameSearchResp mergeFrom(final ProtoSource input) throws IOException {
      // Enabled Fall-Through Optimization (QuickBuffers)
      int tag = input.readTag();
      while (true) {
        switch (tag) {
          case 16378: {
            // nextPackage
            input.readBytes(nextPackage);
            bitField0_ |= 0x00000001;
            tag = input.readTag();
            if (tag != 10) {
              break;
            }
          }
          case 10: {
            // friends
            tag = input.readRepeatedMessage(friends, tag);
            bitField0_ |= 0x00000002;
            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.writeBytes(FieldNames.nextPackage, nextPackage);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeRepeatedMessage(FieldNames.friends, friends);
      }
      output.endObject();
    }

    @Override
    public FriendNameSearchResp mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case -2082324045: {
            if (input.isAtField(FieldNames.nextPackage)) {
              if (!input.trySkipNullValue()) {
                input.readBytes(nextPackage);
                bitField0_ |= 0x00000001;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 1064558965: {
            if (input.isAtField(FieldNames.friends)) {
              if (!input.trySkipNullValue()) {
                input.readRepeatedMessage(friends);
                bitField0_ |= 0x00000002;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum FriendNameSearchRespFactory implements MessageFactory<FriendNameSearchResp> {
      INSTANCE;

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

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

      static final FieldName friends = FieldName.forField("Friends");
    }
  }
}
