BetweenMatcherType implements MatcherType<Range<C>> { @Override public String encode(Range<C> object, Type<?> type, Matcher matcher) { BetweenMatcher betweenMatcher = (BetweenMatcher) matcher; String from = encodeValue(object.from(), type); String to = encodeValue(object.to(), type); char separator = findSeparator(from, to, betweenMatcher.separators()); return from + separator + to; }  @Override Range<C> decode(String value, Type<?> type, Matcher matcher); @Override String encode(Range<C> object, Type<?> type, Matcher matcher);  }
@Test public void shouldEncodeRangeAsEncodedValuesSeparatedByFirstSeparatorThatDoesNotExistInAnyEncodedValue() { BetweenMatcher matcher = new BetweenMatcher(true, true, "~#"); String encoded = type.encode(new Range<String>("A~", "B"), null, matcher); assertThat(encoded).isEqualTo("A~#B"); }