private TrafficSelector buildSelector(Criterion... criteria) { TrafficSelector.Builder sBuilder = DefaultTrafficSelector.builder(); for (Criterion c : criteria) { sBuilder.add(c); } return sBuilder.build(); }
@Override public TrafficSelector decode(ObjectNode json, CodecContext context) { final JsonCodec<Criterion> criterionCodec = context.codec(Criterion.class); JsonNode criteriaJson = json.get(CRITERIA); TrafficSelector.Builder builder = DefaultTrafficSelector.builder(); if (criteriaJson != null) { IntStream.range(0, criteriaJson.size()) .forEach(i -> builder.add(criterionCodec.decode(get(criteriaJson, i), context))); } return builder.build(); }