Java Code Examples for java.util.SortedSet.forEach()

The following are Jave code examples for showing how to use forEach() of the java.util.SortedSet class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: buenojo   File: CacheConfiguration.java   View Source Code Vote up 5 votes
@PreDestroy
public void destroy() {
    log.info("Remove Cache Manager metrics");
    SortedSet<String> names = metricRegistry.getNames();
    names.forEach(metricRegistry::remove);
    log.info("Closing Cache Manager");
    cacheManager.shutdown();
}
 
Example 2
Project: app-ms   File: JaxRsRouter.java   View Source Code Vote up 5 votes
/**
 * Register the routes.
 *
 * @param applicationClass
 *            application class to get the root
 * @param router
 *            router to apply the changes to
 * @param pathsProvider
 *            provides a list of Path classes
 * @param jaxRsHandler
 *            route handler
 */
public void register(final Class<? extends Application> applicationClass,
    final Router router,
    final PathsProvider pathsProvider,
    final Handler<RoutingContext> jaxRsHandler) {

    final String rootPath = Optional.ofNullable(applicationClass.getAnnotation(ApplicationPath.class)).map(ApplicationPath::value).orElse("");

    final SortedSet<JaxRsPath> paths = new TreeSet<>();
    pathsProvider.getPathAnnotatedClasses().forEach(clazz -> {
        final String classPath = Optional.ofNullable(clazz.getAnnotation(Path.class)).map(Path::value).orElse("");
        stream(clazz.getMethods()).filter(m -> m.getAnnotation(GET.class) != null
            || m.getAnnotation(POST.class) != null
            || m.getAnnotation(PUT.class) != null
            || m.getAnnotation(DELETE.class) != null).forEach(m -> {
                final String path = Optional.ofNullable(m.getAnnotation(Path.class)).map(Path::value).orElse("");
                final String[] consumes = Optional.ofNullable(m.getAnnotation(Consumes.class)).map(Consumes::value).orElse(new String[0]);
                final String[] produces = Optional.ofNullable(m.getAnnotation(Produces.class)).map(Produces::value).orElse(new String[0]);

                paths.add(new JaxRsPath(UriBuilder.fromPath(rootPath).path(classPath).path(path).toTemplate(), consumes, produces, getHttpMethod(m)));

            });
    });
    paths.forEach(p -> {
        p.apply(router, jaxRsHandler, failureHandler);
        LOG.debug("route={}", p);
    });

}