private void mergeLocalToBuilder() { if (this.states != null) { maybeInitBuilder(); builder.clearNodeStates(); Iterable<NodeStateProto> iterable = new Iterable<NodeStateProto>() { @Override public Iterator<NodeStateProto> iterator() { return new Iterator<NodeStateProto>() { Iterator<NodeState> iter = states.iterator(); @Override public boolean hasNext() { return iter.hasNext(); } @Override public NodeStateProto next() { return ProtoUtils.convertToProtoFormat(iter.next()); } @Override public void remove() { throw new UnsupportedOperationException(); } }; } }; builder.addAllNodeStates(iterable); } }
private void initNodeStates() { if (this.states != null) { return; } GetClusterNodesRequestProtoOrBuilder p = viaProto ? proto : builder; List<NodeStateProto> list = p.getNodeStatesList(); this.states = EnumSet.noneOf(NodeState.class); for (NodeStateProto c : list) { this.states.add(ProtoUtils.convertFromProtoFormat(c)); } }
public static NodeStateProto convertToProtoFormat(NodeState e) { return NodeStateProto.valueOf(NODE_STATE_PREFIX + e.name()); }
public static NodeState convertFromProtoFormat(NodeStateProto e) { return NodeState.valueOf(e.name().replace(NODE_STATE_PREFIX, "")); }