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

scray.service.qservice.thriftjava.ScrayTServiceEndpoint Maven / Gradle / Ivy

There is a newer version: 1.1.2
Show newest version
/**
 * generated by Scrooge ${project.version}
 */

package scray.service.qservice.thriftjava;

import com.twitter.scrooge.Option;
import com.twitter.scrooge.Utilities;
import com.twitter.scrooge.ThriftStruct;
import com.twitter.scrooge.ThriftStructCodec;
import com.twitter.scrooge.ThriftStructCodec3;
import org.apache.thrift.protocol.*;
import java.nio.ByteBuffer;
import java.net.InetSocketAddress;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import java.util.Set;
import java.util.HashSet;

/**
 * Scray service endpoint
 */
@javax.annotation.Generated(value = "com.twitter.scrooge.Compiler", date = "2017-04-25T16:52:50.412+0200")
public class ScrayTServiceEndpoint implements ThriftStruct {
  private static final TStruct STRUCT = new TStruct("ScrayTServiceEndpoint");
  private static final TField HostField = new TField("host", TType.STRING, (short) 1);
  final String host;
  private static final TField PortField = new TField("port", TType.I32, (short) 2);
  final int port;
  private static final TField EndpointIdField = new TField("endpointId", TType.STRUCT, (short) 3);
  final Option endpointId;
  private static final TField ExpiresField = new TField("expires", TType.I64, (short) 4);
  final Option expires;

  public static class Builder {
    private String _host = null;
    private Boolean _got_host = false;

    public Builder host(String value) {
      this._host = value;
      this._got_host = true;
      return this;
    }

    public Builder unsetHost() {
      this._host = null;
      this._got_host = false;
      return this;
    }
    private int _port = 0;
    private Boolean _got_port = false;

    public Builder port(int value) {
      this._port = value;
      this._got_port = true;
      return this;
    }

    public Builder unsetPort() {
      this._port = 0;
      this._got_port = false;
      return this;
    }
    private scray.service.qmodel.thriftjava.ScrayUUID _endpointId = null;
    private Boolean _got_endpointId = false;

    public Builder endpointId(scray.service.qmodel.thriftjava.ScrayUUID value) {
      this._endpointId = value;
      this._got_endpointId = true;
      return this;
    }

    public Builder unsetEndpointId() {
      this._endpointId = null;
      this._got_endpointId = false;
      return this;
    }
    private long _expires = 0L;
    private Boolean _got_expires = false;

    public Builder expires(long value) {
      this._expires = value;
      this._got_expires = true;
      return this;
    }

    public Builder unsetExpires() {
      this._expires = 0L;
      this._got_expires = false;
      return this;
    }

    public ScrayTServiceEndpoint build() {
      return new ScrayTServiceEndpoint(
        this._host,
        this._port,
      Option.make(this._got_endpointId, this._endpointId),
      Option.make(this._got_expires, this._expires)    );
    }
  }

  public Builder copy() {
    Builder builder = new Builder();
    builder.host(this.host);
    builder.port(this.port);
    if (this.endpointId.isDefined()) builder.endpointId(this.endpointId.get());
    if (this.expires.isDefined()) builder.expires(this.expires.get());
    return builder;
  }

  public static ThriftStructCodec CODEC = new ThriftStructCodec3() {
    @Override
    public ScrayTServiceEndpoint decode(TProtocol _iprot) throws org.apache.thrift.TException {
      Builder builder = new Builder();
      String host = null;
      int port = 0;
      scray.service.qmodel.thriftjava.ScrayUUID endpointId = null;
      long expires = 0L;
      Boolean _done = false;
      _iprot.readStructBegin();
      while (!_done) {
        TField _field = _iprot.readFieldBegin();
        if (_field.type == TType.STOP) {
          _done = true;
        } else {
          switch (_field.id) {
            case 1: /* host */
              switch (_field.type) {
                case TType.STRING:
                  String host_item;
                  host_item = _iprot.readString();
                  host = host_item;
                  break;
                default:
                  TProtocolUtil.skip(_iprot, _field.type);
              }
              builder.host(host);
              break;
            case 2: /* port */
              switch (_field.type) {
                case TType.I32:
                  Integer port_item;
                  port_item = _iprot.readI32();
                  port = port_item;
                  break;
                default:
                  TProtocolUtil.skip(_iprot, _field.type);
              }
              builder.port(port);
              break;
            case 3: /* endpointId */
              switch (_field.type) {
                case TType.STRUCT:
                  scray.service.qmodel.thriftjava.ScrayUUID endpointId_item;
                  endpointId_item = scray.service.qmodel.thriftjava.ScrayUUID.decode(_iprot);
                  endpointId = endpointId_item;
                  break;
                default:
                  TProtocolUtil.skip(_iprot, _field.type);
              }
              builder.endpointId(endpointId);
              break;
            case 4: /* expires */
              switch (_field.type) {
                case TType.I64:
                  Long expires_item;
                  expires_item = _iprot.readI64();
                  expires = expires_item;
                  break;
                default:
                  TProtocolUtil.skip(_iprot, _field.type);
              }
              builder.expires(expires);
              break;
            default:
              TProtocolUtil.skip(_iprot, _field.type);
          }
          _iprot.readFieldEnd();
        }
      }
      _iprot.readStructEnd();
      try {
        return builder.build();
      } catch (IllegalStateException stateEx) {
        throw new TProtocolException(stateEx.getMessage());
      }
    }

    @Override
    public void encode(ScrayTServiceEndpoint struct, TProtocol oprot) throws org.apache.thrift.TException {
      struct.write(oprot);
    }
  };

  public static ScrayTServiceEndpoint decode(TProtocol _iprot) throws org.apache.thrift.TException {
    return CODEC.decode(_iprot);
  }

  public static void encode(ScrayTServiceEndpoint struct, TProtocol oprot) throws org.apache.thrift.TException {
    CODEC.encode(struct, oprot);
  }

  public ScrayTServiceEndpoint(
    String host, 
    int port, 
    Option endpointId, 
    Option expires
  ) {
    this.host = host;
    this.port = port;
    this.endpointId = endpointId;
    this.expires = expires;
  }

  public ScrayTServiceEndpoint(
    String host, 
    int port
  ) {
    this.host = host;
    this.port = port;
    this.endpointId = Option.none();
    this.expires = Option.none();
  }

  public String getHost() {
    return this.host;
  }
  public boolean isSetHost() {
    return this.host != null;
  }
  public int getPort() {
    return this.port;
  }
  public scray.service.qmodel.thriftjava.ScrayUUID getEndpointId() {
    return this.endpointId.get();
  }
  public boolean isSetEndpointId() {
    return this.endpointId.isDefined();
  }
  public long getExpires() {
    return this.expires.get();
  }
  public boolean isSetExpires() {
    return this.expires.isDefined();
  }

  public void write(TProtocol _oprot) throws org.apache.thrift.TException {
    validate();
    _oprot.writeStructBegin(STRUCT);
      _oprot.writeFieldBegin(HostField);
      String host_item = host;
      _oprot.writeString(host_item);
      _oprot.writeFieldEnd();
      _oprot.writeFieldBegin(PortField);
      Integer port_item = port;
      _oprot.writeI32(port_item);
      _oprot.writeFieldEnd();
    if (endpointId.isDefined()) {  _oprot.writeFieldBegin(EndpointIdField);
      scray.service.qmodel.thriftjava.ScrayUUID endpointId_item = endpointId.get();
      endpointId_item.write(_oprot);
      _oprot.writeFieldEnd();
    }
    if (expires.isDefined()) {  _oprot.writeFieldBegin(ExpiresField);
      Long expires_item = expires.get();
      _oprot.writeI64(expires_item);
      _oprot.writeFieldEnd();
    }
    _oprot.writeFieldStop();
    _oprot.writeStructEnd();
  }

  private void validate() throws org.apache.thrift.protocol.TProtocolException {
  }


  @Override
  public boolean equals(Object other) {
    if (!(other instanceof ScrayTServiceEndpoint)) return false;
    ScrayTServiceEndpoint that = (ScrayTServiceEndpoint) other;
    return
this.host.equals(that.host) &&
      this.port == that.port
 &&
this.endpointId.equals(that.endpointId) &&
      this.expires.equals(that.expires)
;
  }

  @Override
  public String toString() {
    return "ScrayTServiceEndpoint(" + this.host + "," + this.port + "," + this.endpointId + "," + this.expires + ")";
  }

  @Override
  public int hashCode() {
    int hash = 1;
    hash = hash * (this.host == null ? 0 : this.host.hashCode());
    hash = hash * new Integer(this.port).hashCode();
    hash = hash * (this.endpointId.isDefined() ? 0 : this.endpointId.get().hashCode());
    hash = hash * (this.expires.isDefined() ? 0 : new Long(this.expires.get()).hashCode());
    return hash;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy