Exemplo n.º 1
0
  private TrafficSelector buildSelector(Criterion... criteria) {

    TrafficSelector.Builder sBuilder = DefaultTrafficSelector.builder();

    for (Criterion c : criteria) {
      sBuilder.add(c);
    }

    return sBuilder.build();
  }
Exemplo n.º 2
0
  @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();
  }