private void initNodeToLabels() { if (this.nodeToLabels != null) { return; } GetNodesToLabelsResponseProtoOrBuilder p = viaProto ? proto : builder; List<NodeIdToLabelsProto> list = p.getNodeToLabelsList(); this.nodeToLabels = new HashMap<NodeId, Set<String>>(); for (NodeIdToLabelsProto c : list) { this.nodeToLabels.put(new NodeIdPBImpl(c.getNodeId()), Sets.newHashSet(c.getNodeLabelsList())); } }
private void addNodeToLabelsToProto() { maybeInitBuilder(); builder.clearNodeToLabels(); if (nodeToLabels == null) { return; } Iterable<NodeIdToLabelsProto> iterable = new Iterable<NodeIdToLabelsProto>() { @Override public Iterator<NodeIdToLabelsProto> iterator() { return new Iterator<NodeIdToLabelsProto>() { Iterator<Entry<NodeId, Set<String>>> iter = nodeToLabels .entrySet().iterator(); @Override public void remove() { throw new UnsupportedOperationException(); } @Override public NodeIdToLabelsProto next() { Entry<NodeId, Set<String>> now = iter.next(); return NodeIdToLabelsProto.newBuilder() .setNodeId(convertToProtoFormat(now.getKey())) .addAllNodeLabels(now.getValue()).build(); } @Override public boolean hasNext() { return iter.hasNext(); } }; } }; builder.addAllNodeToLabels(iterable); }
private void initNodeToLabels() { if (this.nodeIdToLabels != null) { return; } ReplaceLabelsOnNodeRequestProtoOrBuilder p = viaProto ? proto : builder; List<NodeIdToLabelsProto> list = p.getNodeToLabelsList(); this.nodeIdToLabels = new HashMap<NodeId, Set<String>>(); for (NodeIdToLabelsProto c : list) { this.nodeIdToLabels.put(new NodeIdPBImpl(c.getNodeId()), Sets.newHashSet(c.getNodeLabelsList())); } }
private void addNodeToLabelsToProto() { maybeInitBuilder(); builder.clearNodeToLabels(); if (nodeIdToLabels == null) { return; } Iterable<NodeIdToLabelsProto> iterable = new Iterable<NodeIdToLabelsProto>() { @Override public Iterator<NodeIdToLabelsProto> iterator() { return new Iterator<NodeIdToLabelsProto>() { Iterator<Entry<NodeId, Set<String>>> iter = nodeIdToLabels .entrySet().iterator(); @Override public void remove() { throw new UnsupportedOperationException(); } @Override public NodeIdToLabelsProto next() { Entry<NodeId, Set<String>> now = iter.next(); return NodeIdToLabelsProto.newBuilder() .setNodeId(convertToProtoFormat(now.getKey())).clearNodeLabels() .addAllNodeLabels(now.getValue()).build(); } @Override public boolean hasNext() { return iter.hasNext(); } }; } }; builder.addAllNodeToLabels(iterable); }