/** * Applies a subtype constraint on the current pattern. This means that an event has * to be of the given subtype in order to be matched. * * @param subtypeClass Class of the subtype * @param <S> Type of the subtype * @return The same pattern with the new subtype constraint */ public <S extends F> Pattern<T, S> subtype(final Class<S> subtypeClass) { Preconditions.checkNotNull(subtypeClass, "The class cannot be null."); if (condition == null) { this.condition = new SubtypeCondition<F>(subtypeClass); } else { this.condition = new RichAndCondition<>(condition, new SubtypeCondition<F>(subtypeClass)); } @SuppressWarnings("unchecked") Pattern<T, S> result = (Pattern<T, S>) this; return result; }
/** * Applies a subtype constraint on the current pattern. This means that an event has * to be of the given subtype in order to be matched. * * @param subtypeClass Class of the subtype * @param <S> Type of the subtype * @return The same pattern with the new subtype constraint */ public <S extends F> Pattern<T, S> subtype(final Class<S> subtypeClass) { Preconditions.checkNotNull(subtypeClass, "The class cannot be null."); if (condition == null) { this.condition = new SubtypeCondition<F>(subtypeClass); } else { this.condition = new AndCondition<>(condition, new SubtypeCondition<F>(subtypeClass)); } @SuppressWarnings("unchecked") Pattern<T, S> result = (Pattern<T, S>) this; return result; }
/** * Applies a subtype constraint on the current pattern. This means that an event has * to be of the given subtype in order to be matched. * * @param subtypeClass Class of the subtype * @param <S> Type of the subtype * @return The same pattern with the new subtype constraint */ public <S extends F> Pattern<T, S> subtype(final Class<S> subtypeClass) { Preconditions.checkNotNull(subtypeClass, "The class cannot be null."); if (condition == null) { this.condition = new SubtypeCondition<F>(subtypeClass); } else { this.condition = new AndCondition<>(condition, new SubtypeCondition<F>(subtypeClass)); } @SuppressWarnings("unchecked") Pattern<T, S> result = (Pattern<T, S>) this; return result; }
/** * Applies a subtype constraint on the current pattern. This means that an event has * to be of the given subtype in order to be matched. * * @param subtypeClass Class of the subtype * @param <S> Type of the subtype * @return The same pattern with the new subtype constraint */ public <S extends F> Pattern<T, S> subtype(final Class<S> subtypeClass) { Preconditions.checkNotNull(subtypeClass, "The class cannot be null."); if (condition == null) { this.condition = new SubtypeCondition<F>(subtypeClass); } else { this.condition = new AndCondition<>(condition, new SubtypeCondition<F>(subtypeClass)); } @SuppressWarnings("unchecked") Pattern<T, S> result = (Pattern<T, S>) this; return result; }