@Test public void testInOperatorEquality() { assertEquals( HostSelector.parse("a in (foo,bar)"), HostSelector.parse("a in (foo, bar)") ); assertEquals( HostSelector.parse("a in (foo,bar)"), HostSelector.parse("a in (bar,foo)") ); assertEquals( HostSelector.parse("a in (foo)"), HostSelector.parse("a in (foo,foo)") ); }
public static HostSelector parse(final String str) { checkNotNull(str); final Matcher matcher = PATTERN.matcher(str); if (matcher.matches()) { final String label = matcher.group(1); final String opStr = matcher.group(2); final String value = matcher.group(3); Operator operator = null; for (final Operator op : Operator.values()) { if (op.operatorName.equals(opStr)) { operator = op; } } if (operator == null) { throw new IllegalArgumentException(format("Unknown operator '%s'", opStr)); } if (operator == Operator.IN || operator == Operator.NOT_IN) { final List<String> parts = Lists.newArrayList(Sets.newHashSet( Arrays.asList(value.replaceAll("\\(|\\)| ", "").split(",")))); return new HostSelector(label, operator, parts); } else { return new HostSelector(label, operator, value); } } else { return null; } }
HostSelector extends Descriptor { public static HostSelector parse(final String str) { checkNotNull(str); final Matcher matcher = PATTERN.matcher(str); if (matcher.matches()) { final String label = matcher.group(1); final String opStr = matcher.group(2); final String value = matcher.group(3); Operator operator = null; for (final Operator op : Operator.values()) { if (op.operatorName.equals(opStr)) { operator = op; } } if (operator == null) { throw new IllegalArgumentException(format("Unknown operator '%s'", opStr)); } if (operator == Operator.IN || operator == Operator.NOT_IN) { final List<String> parts = Lists.newArrayList(Sets.newHashSet( Arrays.asList(value.replaceAll("\\(|\\)| ", "").split(",")))); return new HostSelector(label, operator, parts); } else { return new HostSelector(label, operator, value); } } else { return null; } } }
HostSelector extends Descriptor { public static HostSelector parse(final String str) { checkNotNull(str); final Matcher matcher = PATTERN.matcher(str); if (matcher.matches()) { final String label = matcher.group(1); final String opStr = matcher.group(2); final String value = matcher.group(3); Operator operator = null; for (final Operator op : Operator.values()) { if (op.operatorName.equals(opStr)) { operator = op; } } if (operator == null) { throw new IllegalArgumentException(format("Unknown operator '%s'", opStr)); } if (operator == Operator.IN || operator == Operator.NOT_IN) { final List<String> parts = Lists.newArrayList(Sets.newHashSet( Arrays.asList(value.replaceAll("\\(|\\)| ", "").split(",")))); return new HostSelector(label, operator, parts); } else { return new HostSelector(label, operator, value); } } else { return null; } } HostSelector(
      @JsonProperty("label") final String label,
      @JsonProperty("operator") final Operator operator,
      @JsonProperty("operand") final Object operand); }
HostSelector extends Descriptor { public static HostSelector parse(final String str) { checkNotNull(str); final Matcher matcher = PATTERN.matcher(str); if (matcher.matches()) { final String label = matcher.group(1); final String opStr = matcher.group(2); final String value = matcher.group(3); Operator operator = null; for (final Operator op : Operator.values()) { if (op.operatorName.equals(opStr)) { operator = op; } } if (operator == null) { throw new IllegalArgumentException(format("Unknown operator '%s'", opStr)); } if (operator == Operator.IN || operator == Operator.NOT_IN) { final List<String> parts = Lists.newArrayList(Sets.newHashSet( Arrays.asList(value.replaceAll("\\(|\\)| ", "").split(",")))); return new HostSelector(label, operator, parts); } else { return new HostSelector(label, operator, value); } } else { return null; } } HostSelector(
      @JsonProperty("label") final String label,
      @JsonProperty("operator") final Operator operator,
      @JsonProperty("operand") final Object operand); static HostSelector parse(final String str); String getLabel(); Operator getOperator(); Object getOperand(); boolean matches(@Nullable final String value); String toPrettyString(); @Override boolean equals(final Object obj); @Override int hashCode(); @Override String toString(); }
HostSelector extends Descriptor { public static HostSelector parse(final String str) { checkNotNull(str); final Matcher matcher = PATTERN.matcher(str); if (matcher.matches()) { final String label = matcher.group(1); final String opStr = matcher.group(2); final String value = matcher.group(3); Operator operator = null; for (final Operator op : Operator.values()) { if (op.operatorName.equals(opStr)) { operator = op; } } if (operator == null) { throw new IllegalArgumentException(format("Unknown operator '%s'", opStr)); } if (operator == Operator.IN || operator == Operator.NOT_IN) { final List<String> parts = Lists.newArrayList(Sets.newHashSet( Arrays.asList(value.replaceAll("\\(|\\)| ", "").split(",")))); return new HostSelector(label, operator, parts); } else { return new HostSelector(label, operator, value); } } else { return null; } } HostSelector(
      @JsonProperty("label") final String label,
      @JsonProperty("operator") final Operator operator,
      @JsonProperty("operand") final Object operand); static HostSelector parse(final String str); String getLabel(); Operator getOperator(); Object getOperand(); boolean matches(@Nullable final String value); String toPrettyString(); @Override boolean equals(final Object obj); @Override int hashCode(); @Override String toString();  }