Example usage for org.apache.commons.collections4 SetUtils emptyIfNull

List of usage examples for org.apache.commons.collections4 SetUtils emptyIfNull

Introduction

In this page you can find the example usage for org.apache.commons.collections4 SetUtils emptyIfNull.

Prototype

public static <T> Set<T> emptyIfNull(final Set<T> set) 

Source Link

Document

Returns an immutable empty set if the argument is null, or the argument itself otherwise.

Usage

From source file:org.apache.syncope.core.misc.security.AuthDataAccessor.java

protected Set<? extends ExternalResource> getPassthroughResources(final User user) {
    Set<? extends ExternalResource> result = null;

    // 1. look for assigned resources, pick the ones whose account policy has authentication resources
    for (ExternalResource resource : userDAO.findAllResources(user)) {
        if (resource.getAccountPolicy() != null && !resource.getAccountPolicy().getResources().isEmpty()) {
            if (result == null) {
                result = resource.getAccountPolicy().getResources();
            } else {
                result.retainAll(resource.getAccountPolicy().getResources());
            }/*from  w w w  . j a  v a 2 s .  co  m*/
        }
    }

    // 2. look for realms, pick the ones whose account policy has authentication resources
    for (Realm realm : realmDAO.findAncestors(user.getRealm())) {
        if (realm.getAccountPolicy() != null && !realm.getAccountPolicy().getResources().isEmpty()) {
            if (result == null) {
                result = realm.getAccountPolicy().getResources();
            } else {
                result.retainAll(realm.getAccountPolicy().getResources());
            }
        }
    }

    return SetUtils.emptyIfNull(result);
}

From source file:org.apache.syncope.core.persistence.api.dao.AllowedSchemas.java

public Set<S> getForMembership(final Group group) {
    return SetUtils.emptyIfNull(forMemberships.get(group));
}