Set<Object> (Set<Object> elements) { Set<Object> result = new LinkedHashSet<>(); for (Object o : elements) { if (myElementClass.isInstance(o) && getFilter().isAccepted((T)o)) { result.add(o); } } return result; }