CollectionPattern<T> (final ElementPattern elementPattern) { return with(new PatternCondition<Collection<T>>("last") { @Override public boolean accepts(final @NotNull Collection<T> collection, final ProcessingContext context) { if (collection.isEmpty()) { return false; } T last = null; for (final T t : collection) { last = t; } return elementPattern.accepts(last, context); } }); }