AssignableFromFilter implements Filter<Class<?>> { @Override public boolean accept(Class<?> type) { if (type != null) { if (this.excludeSuperType) { if (this.superClass.equals(type)) { return false; } } return this.superClass.isAssignableFrom(type); } return false; } AssignableFromFilter(Class<?> superClass);  AssignableFromFilter(Class<?> superClass, boolean excludeSuperClass); @Override boolean accept(Class<?> type);  }
@Test public void testFilter() { AssignableFromFilter filter = new AssignableFromFilter(Object.class); assertFalse(filter.accept(null)); assertTrue(filter.accept(Object.class)); assertTrue(filter.accept(String.class)); assertTrue(filter.accept(Integer.class)); assertTrue(filter.accept(Long.class)); assertTrue(filter.accept(Double.class)); assertTrue(filter.accept(Thread.class)); filter = new AssignableFromFilter(Number.class); assertFalse(filter.accept(Object.class)); assertFalse(filter.accept(String.class)); assertTrue(filter.accept(Integer.class)); assertTrue(filter.accept(Long.class)); assertTrue(filter.accept(Double.class)); assertFalse(filter.accept(Thread.class)); }