public static <F, C, T, R> PropertyPattern<F, C, R> of(Property<F, C, T> property, Pattern<R> pattern) { return new PropertyPattern<>(property, pattern); }
public Pattern<?> getPattern() { return propertyPattern.getPattern(); }
public Property<? super T, ?, ?> getProperty() { return propertyPattern.getProperty(); }
@Override public <C> Stream<Match> accept(Object object, Captures captures, C context) { //TODO remove cast BiFunction<? super T, C, Optional<?>> property = (BiFunction<? super T, C, Optional<?>>) propertyPattern.getProperty().getFunction(); Optional<?> propertyValue = property.apply((T) object, context); return propertyValue.map(value -> propertyPattern.getPattern().match(value, captures, context)) .orElse(Stream.of()); }
public static <F, C, T extends Iterable<S>, S> PropertyPattern<F, C, T> empty(Property<F, C, T> property) { return PropertyPattern.upcast(property.matching(Iterables::isEmpty)); }
public <R> PropertyPattern<F, R> matching(Pattern<R> pattern) { return PropertyPattern.of(this, pattern); }
public static <F, T extends Iterable<S>, S> PropertyPattern<F, T> empty(Property<F, T> property) { return PropertyPattern.upcast(property.matching(Iterables::isEmpty)); }
public <R> PropertyPattern<F, C, R> matching(Pattern<R> pattern) { return PropertyPattern.of(this, pattern); }
public static <F, C, T extends Iterable<S>, S> PropertyPattern<F, C, T> nonEmpty(Property<F, C, T> property) { return PropertyPattern.upcast(property.matching(not(Iterables::isEmpty))); }
public Pattern<?> getPattern() { return propertyPattern.getPattern(); }
public static <F, T, R> PropertyPattern<F, R> of(Property<F, T> property, Pattern<R> pattern) { return new PropertyPattern<>(property, pattern); }
public Property<? super T, ?> getProperty() { return propertyPattern.getProperty(); }
public static <F, T extends Iterable<S>, S> PropertyPattern<F, T> nonEmpty(Property<F, T> property) { return PropertyPattern.upcast(property.matching(not(Iterables::isEmpty))); }