Пример #1
0
 public KillJobRequestPBImpl() {
   builder = KillJobRequestProto.newBuilder();
 }
Пример #2
0
 private void maybeInitBuilder() {
   if (viaProto || builder == null) {
     builder = KillJobRequestProto.newBuilder(proto);
   }
   viaProto = false;
 }
Пример #3
0
public class KillJobRequestPBImpl extends ProtoBase<KillJobRequestProto> implements KillJobRequest {
  KillJobRequestProto proto = KillJobRequestProto.getDefaultInstance();
  KillJobRequestProto.Builder builder = null;
  boolean viaProto = false;

  private JobId jobId = null;

  public KillJobRequestPBImpl() {
    builder = KillJobRequestProto.newBuilder();
  }

  public KillJobRequestPBImpl(KillJobRequestProto proto) {
    this.proto = proto;
    viaProto = true;
  }

  public KillJobRequestProto getProto() {
    mergeLocalToProto();
    proto = viaProto ? proto : builder.build();
    viaProto = true;
    return proto;
  }

  private void mergeLocalToBuilder() {
    if (this.jobId != null) {
      builder.setJobId(convertToProtoFormat(this.jobId));
    }
  }

  private void mergeLocalToProto() {
    if (viaProto) maybeInitBuilder();
    mergeLocalToBuilder();
    proto = builder.build();
    viaProto = true;
  }

  private void maybeInitBuilder() {
    if (viaProto || builder == null) {
      builder = KillJobRequestProto.newBuilder(proto);
    }
    viaProto = false;
  }

  @Override
  public JobId getJobId() {
    KillJobRequestProtoOrBuilder p = viaProto ? proto : builder;
    if (this.jobId != null) {
      return this.jobId;
    }
    if (!p.hasJobId()) {
      return null;
    }
    this.jobId = convertFromProtoFormat(p.getJobId());
    return this.jobId;
  }

  @Override
  public void setJobId(JobId jobId) {
    maybeInitBuilder();
    if (jobId == null) builder.clearJobId();
    this.jobId = jobId;
  }

  private JobIdPBImpl convertFromProtoFormat(JobIdProto p) {
    return new JobIdPBImpl(p);
  }

  private JobIdProto convertToProtoFormat(JobId t) {
    return ((JobIdPBImpl) t).getProto();
  }
}