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.aerofs.baseline.config.Configuration.java

public static <C extends Configuration> void validateConfiguration(Validator validator, C configuration)
        throws ConstraintViolationException {
    Set<ConstraintViolation<C>> violations = validator.validate(configuration);
    if (!violations.isEmpty()) {
        throw new ConstraintViolationException(violations);
    }/*from   www  .j a va 2  s . com*/
}

From source file:com.glaf.core.util.AnnotationUtils.java

public static Collection<String> findJPAEntity(String packagePrefix) {
    AnnotationDB db = getAnnotationDB(packagePrefix);
    Map<String, Set<String>> annotationIndex = db.getAnnotationIndex();
    Set<String> entities = annotationIndex.get("javax.persistence.Entity");
    Collection<String> sortSet = new TreeSet<String>();
    if (entities != null && !entities.isEmpty()) {
        for (String str : entities) {
            if (packagePrefix != null && str.contains(packagePrefix)) {
                sortSet.add(str);/*from  w  w w . j av a  2s  . c  o m*/
            }
        }
    }
    return sortSet;
}

From source file:com.github.javarch.jsf.tags.security.SpringSecurityELLibrary.java

/**
 * Method that checks if the user holds <b>any</b> of the given roles.
 * Returns <code>true, when the first match is found, <code>false</code> if no match is found and
 * also <code>false</code> if no roles are given
 *
 * @param grantedRoles a comma seperated list of roles
 * @return true if any of the given roles are granted to the current user, false otherwise
 *//*from  w  w w.ja  v  a2s.c  om*/
public static boolean ifAnyGranted(final String grantedRoles) {
    Set<String> parsedAuthorities = parseAuthorities(grantedRoles);
    if (parsedAuthorities.isEmpty())
        return false;

    GrantedAuthority[] authorities = getUserAuthorities();

    for (GrantedAuthority authority : authorities) {
        if (parsedAuthorities.contains(authority.getAuthority()))
            return true;
    }
    return false;
}

From source file:org.eclipse.cft.server.standalone.core.internal.application.StandAloneModuleFactory.java

/**
 * @return true if and only if it is possible to determine that the project
 *         has no facets. False otherwise
 *//*  w w w  . j  av  a  2 s . co  m*/
private static boolean hasNoFacets(IProject project) {
    // As adding facets can corrupt projects that are deployable to other
    // WST server instances, if facets
    // cannot be resolved, assume the project has facets.
    boolean hasNoFacets = false;
    try {
        IFacetedProject facetedProject = ProjectFacetsManager.create(project);
        if (facetedProject != null) {
            Set<IProjectFacetVersion> facets = facetedProject.getProjectFacets();
            hasNoFacets = facets == null || facets.isEmpty();
        } else {
            hasNoFacets = true;
        }
    } catch (CoreException e) {
        CloudFoundryPlugin.logError(e);
    }
    return hasNoFacets;
}

From source file:Main.java

/**
 *
 * @param columnName//w  w w . jav a 2s.  co m
 * @param objects
 * @return
 */
private static String getQueryPartId(final String columnName, final Set<String> objects) {

    final StringBuilder queryPart = new StringBuilder();
    String queryPartString = "";

    // TODO or rule for every id
    if (objects != null && !objects.isEmpty()) {
        final Iterator<String> it = objects.iterator();

        while (it.hasNext()) {
            final String id = it.next();

            queryPart.append(columnName).append('=' + "\'\"").append(id).append("\"\'");
            if (it.hasNext()) {
                queryPart.append(" OR ");
            }
        }
        queryPartString = queryPart.toString();
    }

    return queryPartString;
}

From source file:com.github.javarch.jsf.tags.security.SpringSecurityELLibrary.java

/**
 * Method that checks if <b>none</b> of the given roles is hold by the user.
 * Returns <code>true</code> if no roles are given, or none of the given roles match the users roles.
 * Returns <code>false</code> on the first matching role.
 *
 * @param notGrantedRoles a comma seperated list of roles
 * @return true if none of the given roles is granted to the current user, false otherwise
 *///from   w w w. j  a  v  a2  s  .co  m
public static boolean ifNotGranted(final String notGrantedRoles) {
    Set<String> parsedAuthorities = parseAuthorities(notGrantedRoles);
    if (parsedAuthorities.isEmpty())
        return true;

    GrantedAuthority[] authorities = getUserAuthorities();

    for (GrantedAuthority authority : authorities) {
        if (parsedAuthorities.contains(authority.getAuthority()))
            return false;
    }
    return true;
}

From source file:crow.util.JsonUtil.java

private static JSONArray toJSONObject(Set<Object> set) throws JSONException {
    JSONArray jsonOb = new JSONArray();
    if ((set == null) || (set.isEmpty()))
        return jsonOb;
    Iterator<Object> iter = set.iterator();
    while (iter.hasNext()) {
        Object value = iter.next();
        if ((value instanceof String) || (value instanceof Integer) || (value instanceof Double)
                || (value instanceof Long) || (value instanceof Float)) {
            jsonOb.put(value);/* w  ww.j  a v  a  2s  .  c om*/
            continue;
        }
        if ((value instanceof Map<?, ?>)) {
            try {
                @SuppressWarnings("unchecked")
                Map<String, Object> valueMap = (Map<String, Object>) value;
                jsonOb.put(toJSONObject(valueMap));
            } catch (ClassCastException e) {
                Log.w(TAG, "Unknown map type in json serialization: ", e);
            }
            continue;
        }
        if ((value instanceof Set<?>)) {
            try {
                @SuppressWarnings("unchecked")
                Set<Object> valueSet = (Set<Object>) value;
                jsonOb.put(toJSONObject(valueSet));
            } catch (ClassCastException e) {
                Log.w(TAG, "Unknown map type in json serialization: ", e);
            }
            continue;
        }
        Log.e(TAG, "Unknown value in json serialization: " + value.toString() + " : "
                + value.getClass().getCanonicalName().toString());
    }
    return jsonOb;
}

From source file:piecework.util.ContentUtility.java

public static boolean validateRemoteLocation(Set<String> acceptableRegularExpressions, URI uri) {
    String location = uri.toString();
    if (acceptableRegularExpressions != null && !acceptableRegularExpressions.isEmpty()) {
        for (String acceptableRegularExpression : acceptableRegularExpressions) {
            Pattern pattern = Pattern.compile(acceptableRegularExpression);
            if (pattern.matcher(location).matches())
                return true;
        }/*from   w  ww . j  av  a  2s.  c  om*/
    }
    return false;
}

From source file:com.javaid.bolaky.carpool.service.acl.userregistration.impl.UserRegistrationAclTranslator.java

public static Set<CarPoolError> convertToCarPoolErrorCodes(Set<PersonErrorCode> personErrorCodes) {

    Set<CarPoolError> carPoolErrorCodes = null;

    if (personErrorCodes != null && !personErrorCodes.isEmpty()) {

        carPoolErrorCodes = new ListOrderedSet<CarPoolError>();

        for (PersonErrorCode personErrorCode : personErrorCodes) {

            CarPoolError carPoolError = CarPoolError.convertFrom(personErrorCode);

            if (carPoolError != null) {
                carPoolErrorCodes.add(carPoolError);
            }//from   ww  w. j  ava 2  s  .  c o  m
        }
    }

    return carPoolErrorCodes;
}

From source file:com.glaf.core.util.AnnotationUtils.java

public static Collection<String> findMapper(String packagePrefix) {
    AnnotationDB db = getAnnotationDB(packagePrefix);
    Map<String, Set<String>> annotationIndex = db.getAnnotationIndex();
    Set<String> entities = annotationIndex.get("org.springframework.stereotype.Component");
    Collection<String> sortSet = new TreeSet<String>();
    if (entities != null && !entities.isEmpty()) {
        for (String str : entities) {
            if (packagePrefix != null && str.contains(packagePrefix) && StringUtils.contains(str, ".mapper.")) {
                sortSet.add(str);/*from www  .  jav  a  2 s.  c o  m*/
            }
        }
    }
    return sortSet;
}