Example usage for java.util Collections emptySet

List of usage examples for java.util Collections emptySet

Introduction

In this page you can find the example usage for java.util Collections emptySet.

Prototype

@SuppressWarnings("unchecked")
public static final <T> Set<T> emptySet() 

Source Link

Document

Returns an empty set (immutable).

Usage

From source file:io.seldon.clustering.recommender.BaseClusterCountsRecommender.java

public ItemRecommendationResultSet recommend(String recommenderName, String recommenderType, String client,
        RecommendationContext ctxt, Long user, int dimensionId, int maxRecsCount) {
    CountRecommender r = cUtils.getCountRecommender(client);
    RecommendationContext.OptionsHolder optionsHolder = ctxt.getOptsHolder();
    if (r != null) {
        long t1 = System.currentTimeMillis();
        Set<Long> exclusions = Collections.emptySet();
        if (ctxt.getMode() == RecommendationContext.MODE.EXCLUSION) {
            exclusions = ctxt.getContextItems();
        }// w w w.  java  2 s  .  c o m
        boolean includeShortTermClusters = recommenderType.equals("CLUSTER_COUNTS_DYNAMIC");
        Double longTermWeight = optionsHolder.getDoubleOption(LONG_TERM_WEIGHT_OPTION_NAME);
        Double shortTermWeight = optionsHolder.getDoubleOption(SHORT_TERM_WEIGHT_OPTION_NAME);
        Integer minClusterItems = optionsHolder.getIntegerOption(MIN_ITEMS_FOR_VALID_CLUSTER_OPTION_NAME);
        Double decayRate = optionsHolder.getDoubleOption(DECAY_RATE_OPTION_NAME);
        Map<Long, Double> recommendations = r.recommend(recommenderType, user, null, dimensionId, maxRecsCount,
                exclusions, includeShortTermClusters, longTermWeight, shortTermWeight, decayRate,
                minClusterItems);
        long t2 = System.currentTimeMillis();
        logger.debug("Recommendation via cluster counts for user " + user + " took " + (t2 - t1)
                + " and got back " + recommendations.size() + " recommednations");
        List<ItemRecommendationResultSet.ItemRecommendationResult> results = new ArrayList<>();
        for (Map.Entry<Long, Double> entry : recommendations.entrySet()) {
            results.add(new ItemRecommendationResultSet.ItemRecommendationResult(entry.getKey(),
                    entry.getValue().floatValue()));
        }
        return new ItemRecommendationResultSet(results, recommenderName);
    } else {
        return new ItemRecommendationResultSet(
                Collections.<ItemRecommendationResultSet.ItemRecommendationResult>emptyList(), recommenderName);
    }
}

From source file:py.una.pol.karaku.replication.client.ReplicationLogic.java

@Override
public Set<ReplicationInfo> getActiveReplications() {

    List<ReplicationInfo> ri = dao.getAll(getBaseWhere(), null);
    if (ri == null) {
        return Collections.emptySet();
    }/* w w w  . j av  a2  s.  c o m*/
    return loadClass(ri);
}

From source file:fr.ortolang.diffusion.api.message.MessageRepresentation.java

public MessageRepresentation() {
    attachments = Collections.emptySet();
    question = false;
    answer = false;
}

From source file:com.hp.autonomy.frontend.configuration.authentication.IdolPreAuthenticatedAuthenticationProvider.java

@Override
public Authentication authenticate(final Authentication authentication) throws AuthenticationException {
    final Object principal = authentication.getPrincipal();

    if (principal == null) {
        throw new BadCredentialsException("Principal not supplied");
    }/*from w  w w.j ava  2  s . c om*/

    final String username = principal.toString().toLowerCase();

    final UserRoles user = userService.getUser(username, true);

    final Collection<SimpleGrantedAuthority> grantedAuthorities = preAuthenticatedRoles.stream()
            .map(SimpleGrantedAuthority::new).collect(Collectors.toSet());

    final CommunityPrincipal communityPrincipal = new CommunityPrincipal(user.getUid(), username,
            user.getSecurityInfo(), Collections.emptySet());
    final Collection<? extends GrantedAuthority> authorities = authoritiesMapper
            .mapAuthorities(grantedAuthorities);
    return new UsernamePasswordAuthenticationToken(communityPrincipal, null, authorities);
}

From source file:org.eel.kitchen.jsonschema.keyword.AdditionalPropertiesKeywordValidator.java

public AdditionalPropertiesKeywordValidator(final JsonNode schema) {
    super("additionalProperties", NodeType.OBJECT);
    additionalOK = schema.get(keyword).asBoolean(true);

    if (additionalOK) {
        properties = Collections.emptySet();
        patternProperties = Collections.emptySet();
        return;//from www .  j a  v a  2s  .  co  m
    }

    ImmutableSet.Builder<String> builder;

    builder = new ImmutableSet.Builder<String>();
    if (schema.has("properties"))
        builder.addAll(schema.get("properties").fieldNames());
    properties = builder.build();

    builder = new ImmutableSet.Builder<String>();
    if (schema.has("patternProperties"))
        builder.addAll(schema.get("patternProperties").fieldNames());
    patternProperties = builder.build();
}

From source file:Main.java

/**
 * Functions as per {@link Collections#unmodifiableSet(Set)} with the exception that if the
 * given set is null, this method will return an unmodifiable empty set as per
 * {@link Collections#emptySet()}./*w  ww .j  a  v  a  2s  . c  o  m*/
 * 
 * @param set the set for which an unmodifiable view is to be returned
 * @return an unmodifiable view of the specified set, or an unmodifiable empty set if the given
 *         set is null
 */
public static <T> Set<T> unmodifiableSetNullSafe(Set<? extends T> set) {
    if (set == null) {
        return Collections.emptySet();
    }
    return Collections.unmodifiableSet(set);
}

From source file:com.hp.autonomy.iod.client.api.search.FieldNames.java

/**
 * @param fieldName The name of the field
 * @return A set of all the values for the given field name
 *///from   www. j a v a  2 s.com
public Set<String> getValuesForFieldName(final String fieldName) {
    final Map<String, Integer> map = parametricValuesMap.get(fieldName);

    if (map != null) {
        return map.keySet();
    }

    return Collections.emptySet();
}

From source file:org.commonjava.cartographer.request.RepositoryContentRequest.java

public Set<String> getMetas() {
    if (metas == null || metas.isEmpty()) {
        return DEFAULT_METAS;
    } else if (metas.size() == 1 && metas.contains(NO_METAS)) {
        return Collections.emptySet();
    } else {/*from   w w  w .j  a  va 2 s.c o m*/
        return metas;
    }
}

From source file:org.beanlet.springframework.impl.SpringBeanFactoryDependencyInjectionFactoryImpl.java

public Set<String> getDependencies(ElementAnnotation<? extends Element, Inject> ea) {
    return Collections.emptySet();
}

From source file:com.eurodisney.streamit.solr.product.web.SearchController.java

@ResponseBody
@RequestMapping(value = "/autocomplete", produces = "application/json")
public Set<String> autoComplete(Model model, @RequestParam("term") String query,
        @PageableDefault(page = 0, size = 1) Pageable pageable) {
    if (!StringUtils.hasText(query)) {
        return Collections.emptySet();
    }/*from   www.j a  va  2  s.  c o  m*/

    FacetPage<Product> result = productService.autocompleteNameFragment(query, pageable);

    Set<String> titles = new LinkedHashSet<String>();
    for (Page<FacetFieldEntry> page : result.getFacetResultPages()) {
        for (FacetFieldEntry entry : page) {
            if (entry.getValue().contains(query)) { // we have to do this as we do not use terms vector or a string field
                titles.add(entry.getValue());
            }
        }
    }
    return titles;
}