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

org.apache.avro.ipc.HandshakeRequest Maven / Gradle / Ivy

The newest version!
/**
 * Autogenerated by Avro
 *
 * DO NOT EDIT DIRECTLY
 */
package org.apache.avro.ipc;

import org.apache.avro.specific.SpecificData;
import org.apache.avro.util.Utf8;
import org.apache.avro.message.BinaryMessageEncoder;
import org.apache.avro.message.BinaryMessageDecoder;
import org.apache.avro.message.SchemaStore;
import java.util.Optional;
@org.apache.avro.specific.AvroGenerated
public class HandshakeRequest extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord {
  private static final long serialVersionUID = 6293635732927376057L;


  public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"HandshakeRequest\",\"namespace\":\"org.apache.avro.ipc\",\"fields\":[{\"name\":\"clientHash\",\"type\":{\"type\":\"fixed\",\"name\":\"MD5\",\"size\":16}},{\"name\":\"clientProtocol\",\"type\":[\"null\",{\"type\":\"string\",\"avro.java.string\":\"String\"}]},{\"name\":\"serverHash\",\"type\":\"MD5\"},{\"name\":\"meta\",\"type\":[\"null\",{\"type\":\"map\",\"values\":\"bytes\",\"avro.java.string\":\"String\"}]}]}");
  public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }

  private static final SpecificData MODEL$ = new SpecificData();

  private static final BinaryMessageEncoder ENCODER =
      new BinaryMessageEncoder<>(MODEL$, SCHEMA$);

  private static final BinaryMessageDecoder DECODER =
      new BinaryMessageDecoder<>(MODEL$, SCHEMA$);

  /**
   * Return the BinaryMessageEncoder instance used by this class.
   * @return the message encoder used by this class
   */
  public static BinaryMessageEncoder getEncoder() {
    return ENCODER;
  }

  /**
   * Return the BinaryMessageDecoder instance used by this class.
   * @return the message decoder used by this class
   */
  public static BinaryMessageDecoder getDecoder() {
    return DECODER;
  }

  /**
   * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}.
   * @param resolver a {@link SchemaStore} used to find schemas by fingerprint
   * @return a BinaryMessageDecoder instance for this class backed by the given SchemaStore
   */
  public static BinaryMessageDecoder createDecoder(SchemaStore resolver) {
    return new BinaryMessageDecoder<>(MODEL$, SCHEMA$, resolver);
  }

  /**
   * Serializes this HandshakeRequest to a ByteBuffer.
   * @return a buffer holding the serialized data for this instance
   * @throws java.io.IOException if this instance could not be serialized
   */
  public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException {
    return ENCODER.encode(this);
  }

  /**
   * Deserializes a HandshakeRequest from a ByteBuffer.
   * @param b a byte buffer holding serialized data for an instance of this class
   * @return a HandshakeRequest instance decoded from the given buffer
   * @throws java.io.IOException if the given bytes could not be deserialized into an instance of this class
   */
  public static HandshakeRequest fromByteBuffer(
      java.nio.ByteBuffer b) throws java.io.IOException {
    return DECODER.decode(b);
  }

  private org.apache.avro.ipc.MD5 clientHash;
  private java.lang.String clientProtocol;
  private org.apache.avro.ipc.MD5 serverHash;
  private java.util.Map meta;

  /**
   * Default constructor.  Note that this does not initialize fields
   * to their default values from the schema.  If that is desired then
   * one should use newBuilder().
   */
  public HandshakeRequest() {}

  /**
   * All-args constructor.
   * @param clientHash The new value for clientHash
   * @param clientProtocol The new value for clientProtocol
   * @param serverHash The new value for serverHash
   * @param meta The new value for meta
   */
  public HandshakeRequest(org.apache.avro.ipc.MD5 clientHash, java.lang.String clientProtocol, org.apache.avro.ipc.MD5 serverHash, java.util.Map meta) {
    this.clientHash = clientHash;
    this.clientProtocol = clientProtocol;
    this.serverHash = serverHash;
    this.meta = meta;
  }

  @Override
  public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; }

  @Override
  public org.apache.avro.Schema getSchema() { return SCHEMA$; }

  // Used by DatumWriter.  Applications should not call.
  @Override
  public java.lang.Object get(int field$) {
    switch (field$) {
    case 0: return clientHash;
    case 1: return clientProtocol;
    case 2: return serverHash;
    case 3: return meta;
    default: throw new IndexOutOfBoundsException("Invalid index: " + field$);
    }
  }

  // Used by DatumReader.  Applications should not call.
  @Override
  @SuppressWarnings(value="unchecked")
  public void put(int field$, java.lang.Object value$) {
    switch (field$) {
    case 0: clientHash = (org.apache.avro.ipc.MD5)value$; break;
    case 1: clientProtocol = value$ != null ? value$.toString() : null; break;
    case 2: serverHash = (org.apache.avro.ipc.MD5)value$; break;
    case 3: meta = (java.util.Map)value$; break;
    default: throw new IndexOutOfBoundsException("Invalid index: " + field$);
    }
  }

  /**
   * Gets the value of the 'clientHash' field.
   * @return The value of the 'clientHash' field.
   */
  public org.apache.avro.ipc.MD5 getClientHash() {
    return clientHash;
  }

  /**
   * Gets the value of the 'clientHash' field as an Optional<org.apache.avro.ipc.MD5>.
   * @return The value wrapped in an Optional<org.apache.avro.ipc.MD5>.
   */
  public Optional getOptionalClientHash() {
    return Optional.ofNullable(clientHash);
  }

  /**
   * Sets the value of the 'clientHash' field.
   * @param value the value to set.
   */
  public void setClientHash(org.apache.avro.ipc.MD5 value) {
    this.clientHash = value;
  }

  /**
   * Gets the value of the 'clientProtocol' field.
   * @return The value of the 'clientProtocol' field.
   */
  public java.lang.String getClientProtocol() {
    return clientProtocol;
  }

  /**
   * Gets the value of the 'clientProtocol' field as an Optional<java.lang.String>.
   * @return The value wrapped in an Optional<java.lang.String>.
   */
  public Optional getOptionalClientProtocol() {
    return Optional.ofNullable(clientProtocol);
  }

  /**
   * Sets the value of the 'clientProtocol' field.
   * @param value the value to set.
   */
  public void setClientProtocol(java.lang.String value) {
    this.clientProtocol = value;
  }

  /**
   * Gets the value of the 'serverHash' field.
   * @return The value of the 'serverHash' field.
   */
  public org.apache.avro.ipc.MD5 getServerHash() {
    return serverHash;
  }

  /**
   * Gets the value of the 'serverHash' field as an Optional<org.apache.avro.ipc.MD5>.
   * @return The value wrapped in an Optional<org.apache.avro.ipc.MD5>.
   */
  public Optional getOptionalServerHash() {
    return Optional.ofNullable(serverHash);
  }

  /**
   * Sets the value of the 'serverHash' field.
   * @param value the value to set.
   */
  public void setServerHash(org.apache.avro.ipc.MD5 value) {
    this.serverHash = value;
  }

  /**
   * Gets the value of the 'meta' field.
   * @return The value of the 'meta' field.
   */
  public java.util.Map getMeta() {
    return meta;
  }

  /**
   * Gets the value of the 'meta' field as an Optional<java.util.Map<java.lang.String,java.nio.ByteBuffer>>.
   * @return The value wrapped in an Optional<java.util.Map<java.lang.String,java.nio.ByteBuffer>>.
   */
  public Optional> getOptionalMeta() {
    return Optional.>ofNullable(meta);
  }

  /**
   * Sets the value of the 'meta' field.
   * @param value the value to set.
   */
  public void setMeta(java.util.Map value) {
    this.meta = value;
  }

  /**
   * Creates a new HandshakeRequest RecordBuilder.
   * @return A new HandshakeRequest RecordBuilder
   */
  public static org.apache.avro.ipc.HandshakeRequest.Builder newBuilder() {
    return new org.apache.avro.ipc.HandshakeRequest.Builder();
  }

  /**
   * Creates a new HandshakeRequest RecordBuilder by copying an existing Builder.
   * @param other The existing builder to copy.
   * @return A new HandshakeRequest RecordBuilder
   */
  public static org.apache.avro.ipc.HandshakeRequest.Builder newBuilder(org.apache.avro.ipc.HandshakeRequest.Builder other) {
    if (other == null) {
      return new org.apache.avro.ipc.HandshakeRequest.Builder();
    } else {
      return new org.apache.avro.ipc.HandshakeRequest.Builder(other);
    }
  }

  /**
   * Creates a new HandshakeRequest RecordBuilder by copying an existing HandshakeRequest instance.
   * @param other The existing instance to copy.
   * @return A new HandshakeRequest RecordBuilder
   */
  public static org.apache.avro.ipc.HandshakeRequest.Builder newBuilder(org.apache.avro.ipc.HandshakeRequest other) {
    if (other == null) {
      return new org.apache.avro.ipc.HandshakeRequest.Builder();
    } else {
      return new org.apache.avro.ipc.HandshakeRequest.Builder(other);
    }
  }

  /**
   * RecordBuilder for HandshakeRequest instances.
   */
  @org.apache.avro.specific.AvroGenerated
  public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase
    implements org.apache.avro.data.RecordBuilder {

    private org.apache.avro.ipc.MD5 clientHash;
    private java.lang.String clientProtocol;
    private org.apache.avro.ipc.MD5 serverHash;
    private java.util.Map meta;

    /** Creates a new Builder */
    private Builder() {
      super(SCHEMA$, MODEL$);
    }

    /**
     * Creates a Builder by copying an existing Builder.
     * @param other The existing Builder to copy.
     */
    private Builder(org.apache.avro.ipc.HandshakeRequest.Builder other) {
      super(other);
      if (isValidValue(fields()[0], other.clientHash)) {
        this.clientHash = data().deepCopy(fields()[0].schema(), other.clientHash);
        fieldSetFlags()[0] = other.fieldSetFlags()[0];
      }
      if (isValidValue(fields()[1], other.clientProtocol)) {
        this.clientProtocol = data().deepCopy(fields()[1].schema(), other.clientProtocol);
        fieldSetFlags()[1] = other.fieldSetFlags()[1];
      }
      if (isValidValue(fields()[2], other.serverHash)) {
        this.serverHash = data().deepCopy(fields()[2].schema(), other.serverHash);
        fieldSetFlags()[2] = other.fieldSetFlags()[2];
      }
      if (isValidValue(fields()[3], other.meta)) {
        this.meta = data().deepCopy(fields()[3].schema(), other.meta);
        fieldSetFlags()[3] = other.fieldSetFlags()[3];
      }
    }

    /**
     * Creates a Builder by copying an existing HandshakeRequest instance
     * @param other The existing instance to copy.
     */
    private Builder(org.apache.avro.ipc.HandshakeRequest other) {
      super(SCHEMA$, MODEL$);
      if (isValidValue(fields()[0], other.clientHash)) {
        this.clientHash = data().deepCopy(fields()[0].schema(), other.clientHash);
        fieldSetFlags()[0] = true;
      }
      if (isValidValue(fields()[1], other.clientProtocol)) {
        this.clientProtocol = data().deepCopy(fields()[1].schema(), other.clientProtocol);
        fieldSetFlags()[1] = true;
      }
      if (isValidValue(fields()[2], other.serverHash)) {
        this.serverHash = data().deepCopy(fields()[2].schema(), other.serverHash);
        fieldSetFlags()[2] = true;
      }
      if (isValidValue(fields()[3], other.meta)) {
        this.meta = data().deepCopy(fields()[3].schema(), other.meta);
        fieldSetFlags()[3] = true;
      }
    }

    /**
      * Gets the value of the 'clientHash' field.
      * @return The value.
      */
    public org.apache.avro.ipc.MD5 getClientHash() {
      return clientHash;
    }

    /**
      * Gets the value of the 'clientHash' field as an Optional<org.apache.avro.ipc.MD5>.
      * @return The value wrapped in an Optional<org.apache.avro.ipc.MD5>.
      */
    public Optional getOptionalClientHash() {
      return Optional.ofNullable(clientHash);
    }

    /**
      * Sets the value of the 'clientHash' field.
      * @param value The value of 'clientHash'.
      * @return This builder.
      */
    public org.apache.avro.ipc.HandshakeRequest.Builder setClientHash(org.apache.avro.ipc.MD5 value) {
      validate(fields()[0], value);
      this.clientHash = value;
      fieldSetFlags()[0] = true;
      return this;
    }

    /**
      * Checks whether the 'clientHash' field has been set.
      * @return True if the 'clientHash' field has been set, false otherwise.
      */
    public boolean hasClientHash() {
      return fieldSetFlags()[0];
    }


    /**
      * Clears the value of the 'clientHash' field.
      * @return This builder.
      */
    public org.apache.avro.ipc.HandshakeRequest.Builder clearClientHash() {
      clientHash = null;
      fieldSetFlags()[0] = false;
      return this;
    }

    /**
      * Gets the value of the 'clientProtocol' field.
      * @return The value.
      */
    public java.lang.String getClientProtocol() {
      return clientProtocol;
    }

    /**
      * Gets the value of the 'clientProtocol' field as an Optional<java.lang.String>.
      * @return The value wrapped in an Optional<java.lang.String>.
      */
    public Optional getOptionalClientProtocol() {
      return Optional.ofNullable(clientProtocol);
    }

    /**
      * Sets the value of the 'clientProtocol' field.
      * @param value The value of 'clientProtocol'.
      * @return This builder.
      */
    public org.apache.avro.ipc.HandshakeRequest.Builder setClientProtocol(java.lang.String value) {
      validate(fields()[1], value);
      this.clientProtocol = value;
      fieldSetFlags()[1] = true;
      return this;
    }

    /**
      * Checks whether the 'clientProtocol' field has been set.
      * @return True if the 'clientProtocol' field has been set, false otherwise.
      */
    public boolean hasClientProtocol() {
      return fieldSetFlags()[1];
    }


    /**
      * Clears the value of the 'clientProtocol' field.
      * @return This builder.
      */
    public org.apache.avro.ipc.HandshakeRequest.Builder clearClientProtocol() {
      clientProtocol = null;
      fieldSetFlags()[1] = false;
      return this;
    }

    /**
      * Gets the value of the 'serverHash' field.
      * @return The value.
      */
    public org.apache.avro.ipc.MD5 getServerHash() {
      return serverHash;
    }

    /**
      * Gets the value of the 'serverHash' field as an Optional<org.apache.avro.ipc.MD5>.
      * @return The value wrapped in an Optional<org.apache.avro.ipc.MD5>.
      */
    public Optional getOptionalServerHash() {
      return Optional.ofNullable(serverHash);
    }

    /**
      * Sets the value of the 'serverHash' field.
      * @param value The value of 'serverHash'.
      * @return This builder.
      */
    public org.apache.avro.ipc.HandshakeRequest.Builder setServerHash(org.apache.avro.ipc.MD5 value) {
      validate(fields()[2], value);
      this.serverHash = value;
      fieldSetFlags()[2] = true;
      return this;
    }

    /**
      * Checks whether the 'serverHash' field has been set.
      * @return True if the 'serverHash' field has been set, false otherwise.
      */
    public boolean hasServerHash() {
      return fieldSetFlags()[2];
    }


    /**
      * Clears the value of the 'serverHash' field.
      * @return This builder.
      */
    public org.apache.avro.ipc.HandshakeRequest.Builder clearServerHash() {
      serverHash = null;
      fieldSetFlags()[2] = false;
      return this;
    }

    /**
      * Gets the value of the 'meta' field.
      * @return The value.
      */
    public java.util.Map getMeta() {
      return meta;
    }

    /**
      * Gets the value of the 'meta' field as an Optional<java.util.Map<java.lang.String,java.nio.ByteBuffer>>.
      * @return The value wrapped in an Optional<java.util.Map<java.lang.String,java.nio.ByteBuffer>>.
      */
    public Optional> getOptionalMeta() {
      return Optional.>ofNullable(meta);
    }

    /**
      * Sets the value of the 'meta' field.
      * @param value The value of 'meta'.
      * @return This builder.
      */
    public org.apache.avro.ipc.HandshakeRequest.Builder setMeta(java.util.Map value) {
      validate(fields()[3], value);
      this.meta = value;
      fieldSetFlags()[3] = true;
      return this;
    }

    /**
      * Checks whether the 'meta' field has been set.
      * @return True if the 'meta' field has been set, false otherwise.
      */
    public boolean hasMeta() {
      return fieldSetFlags()[3];
    }


    /**
      * Clears the value of the 'meta' field.
      * @return This builder.
      */
    public org.apache.avro.ipc.HandshakeRequest.Builder clearMeta() {
      meta = null;
      fieldSetFlags()[3] = false;
      return this;
    }

    @Override
    @SuppressWarnings("unchecked")
    public HandshakeRequest build() {
      try {
        HandshakeRequest record = new HandshakeRequest();
        record.clientHash = fieldSetFlags()[0] ? this.clientHash : (org.apache.avro.ipc.MD5) defaultValue(fields()[0]);
        record.clientProtocol = fieldSetFlags()[1] ? this.clientProtocol : (java.lang.String) defaultValue(fields()[1]);
        record.serverHash = fieldSetFlags()[2] ? this.serverHash : (org.apache.avro.ipc.MD5) defaultValue(fields()[2]);
        record.meta = fieldSetFlags()[3] ? this.meta : (java.util.Map) defaultValue(fields()[3]);
        return record;
      } catch (org.apache.avro.AvroMissingFieldException e) {
        throw e;
      } catch (java.lang.Exception e) {
        throw new org.apache.avro.AvroRuntimeException(e);
      }
    }
  }

  @SuppressWarnings("unchecked")
  private static final org.apache.avro.io.DatumWriter
    WRITER$ = (org.apache.avro.io.DatumWriter)MODEL$.createDatumWriter(SCHEMA$);

  @Override public void writeExternal(java.io.ObjectOutput out)
    throws java.io.IOException {
    WRITER$.write(this, SpecificData.getEncoder(out));
  }

  @SuppressWarnings("unchecked")
  private static final org.apache.avro.io.DatumReader
    READER$ = (org.apache.avro.io.DatumReader)MODEL$.createDatumReader(SCHEMA$);

  @Override public void readExternal(java.io.ObjectInput in)
    throws java.io.IOException {
    READER$.read(this, SpecificData.getDecoder(in));
  }

  @Override protected boolean hasCustomCoders() { return true; }

  @Override public void customEncode(org.apache.avro.io.Encoder out)
    throws java.io.IOException
  {
    out.writeFixed(this.clientHash.bytes(), 0, 16);

    if (this.clientProtocol == null) {
      out.writeIndex(0);
      out.writeNull();
    } else {
      out.writeIndex(1);
      out.writeString(this.clientProtocol);
    }

    out.writeFixed(this.serverHash.bytes(), 0, 16);

    if (this.meta == null) {
      out.writeIndex(0);
      out.writeNull();
    } else {
      out.writeIndex(1);
      long size0 = this.meta.size();
      out.writeMapStart();
      out.setItemCount(size0);
      long actualSize0 = 0;
      for (java.util.Map.Entry e0: this.meta.entrySet()) {
        actualSize0++;
        out.startItem();
        out.writeString(e0.getKey());
        java.nio.ByteBuffer v0 = e0.getValue();
        out.writeBytes(v0);
      }
      out.writeMapEnd();
      if (actualSize0 != size0)
      throw new java.util.ConcurrentModificationException("Map-size written was " + size0 + ", but element count was " + actualSize0 + ".");
    }

  }

  @Override public void customDecode(org.apache.avro.io.ResolvingDecoder in)
    throws java.io.IOException
  {
    org.apache.avro.Schema.Field[] fieldOrder = in.readFieldOrderIfDiff();
    if (fieldOrder == null) {
      if (this.clientHash == null) {
        this.clientHash = new org.apache.avro.ipc.MD5();
      }
      in.readFixed(this.clientHash.bytes(), 0, 16);

      if (in.readIndex() != 1) {
        in.readNull();
        this.clientProtocol = null;
      } else {
        this.clientProtocol = in.readString();
      }

      if (this.serverHash == null) {
        this.serverHash = new org.apache.avro.ipc.MD5();
      }
      in.readFixed(this.serverHash.bytes(), 0, 16);

      if (in.readIndex() != 1) {
        in.readNull();
        this.meta = null;
      } else {
        long size0 = in.readMapStart();
        java.util.Map m0 = this.meta; // Need fresh name due to limitation of macro system
        if (m0 == null) {
          m0 = new java.util.HashMap((int)(size0 * 4)/3 + 1);
          this.meta = m0;
        } else m0.clear();
        for ( ; 0 < size0; size0 = in.mapNext()) {
          for ( ; size0 != 0; size0--) {
            java.lang.String k0 = null;
            k0 = in.readString();
            java.nio.ByteBuffer v0 = null;
            v0 = in.readBytes(v0);
            m0.put(k0, v0);
          }
        }
      }

    } else {
      for (int i = 0; i < 4; i++) {
        switch (fieldOrder[i].pos()) {
        case 0:
          if (this.clientHash == null) {
            this.clientHash = new org.apache.avro.ipc.MD5();
          }
          in.readFixed(this.clientHash.bytes(), 0, 16);
          break;

        case 1:
          if (in.readIndex() != 1) {
            in.readNull();
            this.clientProtocol = null;
          } else {
            this.clientProtocol = in.readString();
          }
          break;

        case 2:
          if (this.serverHash == null) {
            this.serverHash = new org.apache.avro.ipc.MD5();
          }
          in.readFixed(this.serverHash.bytes(), 0, 16);
          break;

        case 3:
          if (in.readIndex() != 1) {
            in.readNull();
            this.meta = null;
          } else {
            long size0 = in.readMapStart();
            java.util.Map m0 = this.meta; // Need fresh name due to limitation of macro system
            if (m0 == null) {
              m0 = new java.util.HashMap((int)(size0 * 4)/3 + 1);
              this.meta = m0;
            } else m0.clear();
            for ( ; 0 < size0; size0 = in.mapNext()) {
              for ( ; size0 != 0; size0--) {
                java.lang.String k0 = null;
                k0 = in.readString();
                java.nio.ByteBuffer v0 = null;
                v0 = in.readBytes(v0);
                m0.put(k0, v0);
              }
            }
          }
          break;

        default:
          throw new java.io.IOException("Corrupt ResolvingDecoder.");
        }
      }
    }
  }
}














© 2015 - 2025 Weber Informatics LLC | Privacy Policy