private void initPreemptionResourceRequests() { if (resources != null) { return; } PreemptionContractProtoOrBuilder p = viaProto ? proto : builder; List<PreemptionResourceRequestProto> list = p.getResourceList(); resources = new ArrayList<PreemptionResourceRequest>(); for (PreemptionResourceRequestProto rr : list) { resources.add(convertFromProtoFormat(rr)); } }
private void addResourcesToProto() { maybeInitBuilder(); builder.clearResource(); if (null == resources) { return; } Iterable<PreemptionResourceRequestProto> iterable = new Iterable<PreemptionResourceRequestProto>() { @Override public Iterator<PreemptionResourceRequestProto> iterator() { return new Iterator<PreemptionResourceRequestProto>() { Iterator<PreemptionResourceRequest> iter = resources.iterator(); @Override public boolean hasNext() { return iter.hasNext(); } @Override public PreemptionResourceRequestProto next() { return convertToProtoFormat(iter.next()); } @Override public void remove() { throw new UnsupportedOperationException(); } }; } }; builder.addAllResource(iterable); }
public PreemptionResourceRequestPBImpl() { builder = PreemptionResourceRequestProto.newBuilder(); }
public PreemptionResourceRequestPBImpl(PreemptionResourceRequestProto proto) { this.proto = proto; viaProto = true; }
public synchronized PreemptionResourceRequestProto getProto() { mergeLocalToProto(); proto = viaProto ? proto : builder.build(); viaProto = true; return proto; }
private void maybeInitBuilder() { if (viaProto || builder == null) { builder = PreemptionResourceRequestProto.newBuilder(proto); } viaProto = false; }
private PreemptionResourceRequestPBImpl convertFromProtoFormat(PreemptionResourceRequestProto p) { return new PreemptionResourceRequestPBImpl(p); }
private PreemptionResourceRequestProto convertToProtoFormat(PreemptionResourceRequest t) { return ((PreemptionResourceRequestPBImpl)t).getProto(); }
@Test public void testPreemptionResourceRequestPBImpl() throws Exception { validatePBImplRecord(PreemptionResourceRequestPBImpl.class, PreemptionResourceRequestProto.class); }