CollectionPattern<T> (final ElementPattern<? extends T> elementPattern) { return with(new PatternCondition<Collection<T>>("first") { @Override public boolean accepts(final @NotNull Collection<T> collection, final ProcessingContext context) { return !collection.isEmpty() && elementPattern.accepts(collection.iterator().next(), context); } }); }