@Test public void testMap() { Match<String> m1 = Match.ifNull(); assertEquals(m1.map(s -> "bar"), Match.ifNull()); Match<String> m2 = Match.ifValue("foo"); Match<String> m3 = m2.map(s -> "bar"); assertTrue(m3.matches("bar")); }
public <V> Match<V> map(Function<T, V> mapper) { if (matchAny) { return any(); } else if (value == null) { return negation ? ifNotNull() : ifNull(); } else { return negation ? ifNotValue(mapper.apply(value)) : ifValue(mapper.apply(value)); } }
Match { public <V> Match<V> map(Function<T, V> mapper) { if (matchAny) { return any(); } else if (value == null) { return negation ? ifNotNull() : ifNull(); } else { return negation ? ifNotValue(mapper.apply(value)) : ifValue(mapper.apply(value)); } } }
Match { public <V> Match<V> map(Function<T, V> mapper) { if (matchAny) { return any(); } else if (value == null) { return negation ? ifNotNull() : ifNull(); } else { return negation ? ifNotValue(mapper.apply(value)) : ifValue(mapper.apply(value)); } } private  Match(); private  Match(T value, boolean negation); }
Match { public <V> Match<V> map(Function<T, V> mapper) { if (matchAny) { return any(); } else if (value == null) { return negation ? ifNotNull() : ifNull(); } else { return negation ? ifNotValue(mapper.apply(value)) : ifValue(mapper.apply(value)); } } private  Match(); private  Match(T value, boolean negation); static Match<T> any(); static Match<T> ifNull(); static Match<T> ifNotNull(); static Match<T> ifValue(T value); static Match<T> ifNotValue(T value); Match<V> map(Function<T, V> mapper); boolean matches(T other); @Override int hashCode(); @Override boolean equals(Object other); @Override String toString(); }
Match { public <V> Match<V> map(Function<T, V> mapper) { if (matchAny) { return any(); } else if (value == null) { return negation ? ifNotNull() : ifNull(); } else { return negation ? ifNotValue(mapper.apply(value)) : ifValue(mapper.apply(value)); } } private  Match(); private  Match(T value, boolean negation); static Match<T> any(); static Match<T> ifNull(); static Match<T> ifNotNull(); static Match<T> ifValue(T value); static Match<T> ifNotValue(T value); Match<V> map(Function<T, V> mapper); boolean matches(T other); @Override int hashCode(); @Override boolean equals(Object other); @Override String toString(); static final Match ANY; static final Match NULL; static final Match NOT_NULL; }