class SimpleMatcherType implements MatcherType<Object> {

    @Override
    @SuppressWarnings("unchecked")
    public String encode(Object object, Type type, Matcher matcher) {
        if (object instanceof Star) {
            return "*";
        }

        String value;
        if (type != null) {
            value = type.encode(type.convert(object));
        } else {
            value = object == null ? "" : object.toString();
        }

        return value == null ? "*" : value;
    }

}

class SimpleMatcherTypeTest {

    private final SimpleMatcherType type;

    @Test
    public void shouldEncodeStarObjectAsStar() {

        // when
        String encoded = type.encode(Star.star(), null, null);

        // then
        assertThat(encoded).isEqualTo("*");
    }

}