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