@Override public Set<Object> getSingletons() { return Sets.<Object>newHashSet( new AbstractBinder() { @Override protected void configure() { bindFactory(SingletonFactory.class).to(SingletonInstance.class).in(Singleton.class); } }); }
private void checkFilteredDocuments( final JsonArray filtered, final int size, final String... properties) { assertEquals(size, filtered.size()); final HashSet<String> strings = Sets.newHashSet(properties); for (final JsonObject document : filtered.getValuesAs(JsonObject.class)) { for (final String property : document.keySet()) { assertTrue(strings.contains(property)); } } }
@Override @LogPerformances(layer = "domain", operation = "find_player_by_instrument_category") public List<Player> find(Category instrumentCategory) { Set<Player> players = Sets.newHashSet(); for (Map.Entry<String, Player> entry : playerById.entrySet()) { for (Instrument inst : entry.getValue().getInstruments()) { if (inst.getCategory().equals(instrumentCategory)) players.add(entry.getValue()); } } return Lists.newArrayList(players); }
private Set<String> getScopesForField(final String fieldName) { final Set<String> scopes = Sets.newHashSet(); // add specific scope in case of specific request final String[] fields = Tokenizer.tokenize(fieldName, ","); for (final String field : fields) { final String[] subfields = Tokenizer.tokenize(field, "."); // in case of nested path, add first level as stand-alone to ensure subgraph is added scopes.add(SelectableScopeResolver.PREFIX + subfields[0]); if (subfields.length > 1) { scopes.add(SelectableScopeResolver.PREFIX + field); } } return scopes; }
private static Set<String> getPropertyNames(final Class<?> propertiesClass) { final Set<String> propertyNames = Sets.newHashSet(); for (final Field field : AccessController.doPrivileged(ReflectionHelper.getDeclaredFieldsPA(propertiesClass))) { if (String.class == field.getType() && Modifier.isStatic(field.getModifiers())) { try { propertyNames.add((String) field.get(null)); } catch (IllegalAccessException e) { // NOOP. } } } return propertyNames; }
/** * Retrieves a list of root loggers. * * @return list of root loggers. */ private Set<Logger> getRootLoggers() { final LogManager logManager = LogManager.getLogManager(); final Enumeration<String> loggerNames = logManager.getLoggerNames(); final Set<Logger> rootLoggers = Sets.newHashSet(); while (loggerNames.hasMoreElements()) { Logger logger = logManager.getLogger(loggerNames.nextElement()); if (logger != null) { while (logger.getParent() != null) { logger = logger.getParent(); } rootLoggers.add(logger); } } return rootLoggers; }
@Override public Set<Class<?>> getClasses() { return Sets.<Class<?>>newHashSet( Resource.class, MyFilter.class, MyWriter.class, MyContainerLifecycleListener.class); }