Skip to content

Instantly share code, notes, and snippets.

@rmannibucau
Created April 19, 2021 09:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rmannibucau/7ff2bea1e4ca1f3204a16e84afee5f87 to your computer and use it in GitHub Desktop.
Save rmannibucau/7ff2bea1e4ca1f3204a16e84afee5f87 to your computer and use it in GitHub Desktop.
@HandlesTypes(Foo.class)
public class FooStarter implements ServletContainerInitializer {
@Override
public void onStartup(final Set<Class<?>> set, final ServletContext servletContext) {
System.out.println(set.stream().map(Class::getName).collect(joining("\n", "\nClasses:\n\n", "\n\n")));
if (set.stream()
.filter(it -> it.isAnnotationPresent(Foo.class))
.count() != set.size()) {
throw new IllegalArgumentException("Invalid scanning");
}
}
}
/*
with foo:
*/
@Target({TYPE, FIELD})
@Retention(RUNTIME)
public @interface Foo {
}
/** and beans */
@Foo
public class OnClass {
}
public class OnField {
@Foo
private String name;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment