private void initAsks() { if (this.ask != null) { return; } AllocateRequestProtoOrBuilder p = viaProto ? proto : builder; List<ResourceRequestProto> list = p.getAskList(); this.ask = new ArrayList<ResourceRequest>(); for (ResourceRequestProto c : list) { this.ask.add(convertFromProtoFormat(c)); } }
private void addAsksToProto() { maybeInitBuilder(); builder.clearAsk(); if (ask == null) return; Iterable<ResourceRequestProto> iterable = new Iterable<ResourceRequestProto>() { @Override public Iterator<ResourceRequestProto> iterator() { return new Iterator<ResourceRequestProto>() { Iterator<ResourceRequest> iter = ask.iterator(); @Override public boolean hasNext() { return iter.hasNext(); } @Override public ResourceRequestProto next() { return convertToProtoFormat(iter.next()); } @Override public void remove() { throw new UnsupportedOperationException(); } }; } }; builder.addAllAsk(iterable); }
private ResourceRequestPBImpl convertFromProtoFormat(ResourceRequestProto p) { return new ResourceRequestPBImpl(p); }
private ResourceRequestProto convertToProtoFormat(ResourceRequest t) { return ((ResourceRequestPBImpl)t).getProto(); }
public ResourceRequestPBImpl() { builder = ResourceRequestProto.newBuilder(); }
public ResourceRequestPBImpl(ResourceRequestProto proto) { this.proto = proto; viaProto = true; }
public ResourceRequestProto getProto() { mergeLocalToProto(); proto = viaProto ? proto : builder.build(); viaProto = true; return proto; }
private void maybeInitBuilder() { if (viaProto || builder == null) { builder = ResourceRequestProto.newBuilder(proto); } viaProto = false; }
@Test public void testResourceRequestPBImpl() throws Exception { validatePBImplRecord(ResourceRequestPBImpl.class, ResourceRequestProto.class); }