Example usage for java.util Set isEmpty

List of usage examples for java.util Set isEmpty

Introduction

In this page you can find the example usage for java.util Set isEmpty.

Prototype

boolean isEmpty();

Source Link

Document

Returns true if this set contains no elements.

Usage

From source file:com.vrem.wifianalyzer.wifi.predicate.FilterPredicate.java

private Predicate<WiFiDetail> makeSSIDPredicate(Set<String> ssids) {
    if (ssids.isEmpty()) {
        return PredicateUtils.truePredicate();
    }//from  w  w w.j  av  a  2s .  c o  m
    return PredicateUtils.anyPredicate(CollectionUtils.collect(ssids, new SSIDTransformer()));
}

From source file:fr.esiea.esieaddress.service.validation.implementation.ValidationService.java

@Override
public Map<String, String> validate(T model) {

    Set<ConstraintViolation<T>> violations = validator.validate(model);

    if (violations.isEmpty())
        return Collections.EMPTY_MAP;

    HashMap<String, String> errorMap = new HashMap<String, String>();
    for (ConstraintViolation<T> violation : violations) {
        String[] propertyPath = violation.getPropertyPath().toString().split("\\.");
        errorMap.put(propertyPath[propertyPath.length - 1], violation.getMessage());
    }/*from   www. ja  v a2  s  .c  o  m*/

    return errorMap;
}

From source file:fr.esiea.windmeal.service.validation.implementation.ValidationService.java

@Override
public Map<Object, String> validate(T model) {

    Set<ConstraintViolation<T>> violations = validator.validate(model);

    if (violations.isEmpty())
        return Collections.EMPTY_MAP;

    HashMap<Object, String> errorMap = new HashMap<Object, String>();
    for (ConstraintViolation<T> violation : violations) {
        String[] propertyPath = violation.getPropertyPath().toString().split("\\.");
        errorMap.put(propertyPath[propertyPath.length - 1], violation.getMessage());
    }/*from   ww w  .ja v a2  s  .c  o m*/

    return errorMap;
}

From source file:com.github.javarch.persistence.orm.hibernate.spi.multitenant.CurrentTenantIdentifierFinder.java

private void registrarBeanDefinitions(BeanDefinitionRegistry registry, Set<BeanDefinition> beanDefinitions) {
    if (beanDefinitions.isEmpty() || beanDefinitions.size() > 1) {
        throw new CurrentTenantIdentifierResolverException();
    }//  w  w w  .j ava 2s  .  com

    for (BeanDefinition bd : beanDefinitions) {
        LOGGER.debug("Encontrado CurrentTenantIdentifierResolver: {}", bd.getBeanClassName());
        if (!registry.containsBeanDefinition(bd.getBeanClassName())) {
            String beanName = bd.getBeanClassName();
            registry.registerBeanDefinition(beanName, bd);
        }
    }
}

From source file:org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions.java

public static void markCycleInjection(final Relationship relationship, final Set<List<Relationship>> cycles) {
    relationship.setProperty(CYCLE_INJECTION, true);
    final List<Long> collapsed = new ArrayList<Long>();
    final Set<List<Long>> existing = getInjectedCycles(relationship);
    if (existing != null && !existing.isEmpty()) {
        for (final List<Long> cycle : existing) {
            if (!collapsed.isEmpty()) {
                collapsed.add(-1L);/* www  . j  ava 2s . c om*/
            }

            collapsed.addAll(cycle);
        }
    }

    for (final List<Relationship> cycle : cycles) {
        if (existing.contains(cycle)) {
            continue;
        }

        if (!collapsed.isEmpty()) {
            collapsed.add(-1L);
        }

        boolean containsGivenRelationship = false;
        for (final Relationship r : cycle) {
            final long rid = r.getId();

            collapsed.add(rid);
            if (rid == relationship.getId()) {
                containsGivenRelationship = true;
            }
        }

        if (!containsGivenRelationship) {
            collapsed.add(relationship.getId());
        }
    }

    final long[] arry = new long[collapsed.size()];
    int i = 0;
    for (final Long l : collapsed) {
        arry[i] = l;
        i++;
    }

    relationship.setProperty(CYCLES_INJECTED, arry);
}

From source file:ddf.catalog.data.inject.AttributeInjectorImpl.java

private boolean isInjected(Set<String> metacardTypes, String metacardTypeName) {
    return metacardTypes.isEmpty() || metacardTypes.contains(metacardTypeName);
}

From source file:gov.nih.nci.caarray.security.SecurityUtils.java

private static User getOwner(Protectable p) {
    final Set<User> owners = getOwners(p);
    if (owners.isEmpty()) {
        return null;
    }//from  w  w  w . ja v a 2  s  .  co m
    return owners.iterator().next();
}

From source file:pt.ist.fenix.ui.spring.NewsController.java

@RequestMapping
public String news(Model model, @RequestParam(defaultValue = "5", required = false) int posts) {
    model.addAttribute("posts", posts);
    Set<Category> bookmarks = Authenticate.getUser().getBookmarksSet();
    if (!bookmarks.isEmpty()) {
        model.addAttribute("allPosts",
                bookmarks.stream().flatMap(cat -> cat.getPostsSet().stream()).filter(Post::isVisible)
                        .filter(Post::isAccessible).sorted(Post.CREATION_DATE_COMPARATOR).limit(posts)
                        .collect(Collectors.toList()));
    } else if (Bennu.getInstance().getDefaultSite() != null) {
        model.addAttribute("allPosts",
                Bennu.getInstance().getDefaultSite().getPostSet().stream().filter(Post::isVisible)
                        .filter(Post::isAccessible).sorted(Post.CREATION_DATE_COMPARATOR).limit(posts)
                        .collect(Collectors.toList()));
    }//w  w  w .j a  v a2s .  c  om
    return "fenix-learning/news";
}

From source file:org.synyx.hades.eclipse.beans.ui.model.HadesModelContentProvider.java

@Override
protected Object[] getJavaTypeChildren(IType type) {

    IProject project = type.getJavaProject().getProject();
    Set<IBean> beans = HadesUtils.getDaoBeansFor(project, type);

    if (!beans.isEmpty()) {
        return new Object[] { new BeanClassReferences(type, beans) };
    }/*from   w  ww . j  a  v a 2  s .c o  m*/

    return IModelElement.NO_CHILDREN;
}

From source file:com.haulmont.cuba.security.jmx.ServerTokenStore.java

@Override
public String removeTokensByUserLogin(String userLogin) {
    if (StringUtils.isEmpty(userLogin)) {
        return "Please specify the user's login";
    }// ww w .j av a2s.  c o  m

    try {
        Set<String> tokens = serverTokenStore.getAccessTokenValuesByUserLogin(userLogin);
        if (tokens.isEmpty()) {
            return String.format("No tokens found for user '%s'", userLogin);
        }

        tokens.forEach(serverTokenStore::removeAccessToken);

        return String.format("%s tokens were removed for user '%s' successfully.", tokens.size(), userLogin);
    } catch (Throwable t) {
        return ExceptionUtils.getStackTrace(t);
    }
}