예제 #1
0
  /**
   * Get a {@link java.util.LinkedHashSet collection} of available template processors.
   *
   * @return set of template processors.
   */
  private Set<TemplateProcessor> getTemplateProcessors() {
    final Set<TemplateProcessor> templateProcessors = Sets.newLinkedHashSet();

    templateProcessors.addAll(
        Providers.getCustomProviders(serviceLocator, TemplateProcessor.class));
    templateProcessors.addAll(Providers.getProviders(serviceLocator, TemplateProcessor.class));

    return templateProcessors;
  }
예제 #2
0
 @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);
  }
예제 #5
0
 public void createMissingPullGames(Event event, Set<Team> participants) {
   List<Game> existingGames = gameDAO.findByEvent(event);
   for (Team team1 : participants) {
     for (Team team2 : participants) {
       if (!team1.equals(team2)) {
         if (!hasMatch(existingGames, team1) && !hasMatch(existingGames, team2)) {
           // make sure that players are distinct
           if (Sets.intersection(team1.getPlayers(), team2.getPlayers()).isEmpty()) {
             existingGames.add(createGame(event, team1, team2, null));
           }
         }
       }
     }
   }
 }
예제 #6
0
  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;
  }
예제 #8
0
  /**
   * 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;
  }
예제 #9
0
 @Override
 public Set<Class<?>> getClasses() {
   return Sets.<Class<?>>newHashSet(
       Resource.class, MyFilter.class, MyWriter.class, MyContainerLifecycleListener.class);
 }