Example usage for java.util Collections unmodifiableSet

List of usage examples for java.util Collections unmodifiableSet

Introduction

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

Prototype

public static <T> Set<T> unmodifiableSet(Set<? extends T> s) 

Source Link

Document

Returns an unmodifiable view of the specified set.

Usage

From source file:org.italiangrid.storm.webdav.authz.vomap.DefaultVOMapDetailsService.java

@Override
public Set<String> getPrincipalVOs(X500Principal principal) {

    Assert.notNull(principal, "Principal cannot be null");

    HashSet<String> voNames = new HashSet<String>();

    for (VOMembershipProvider p : providers) {

        if (p.hasSubjectAsMember(principal.getName())) {
            voNames.add(p.getVOName());/*from  w w  w. j a  va2  s.c o m*/
        }
    }

    return Collections.unmodifiableSet(voNames);
}

From source file:net.sourceforge.fenixedu.domain.phd.PhdElementsList.java

public Set<T> getSortedTypes() {
    return Collections.unmodifiableSet(new TreeSet<T>(types));
}

From source file:com.handu.open.dubbo.monitor.RegistryContainer.java

public Set<String> getApplications() {
    return Collections.unmodifiableSet(applications);
}

From source file:com.oreilly.springdata.neo4j.order.Order.java

public Set<LineItem> getLineItems() {
    return Collections.unmodifiableSet(lineItems);
}

From source file:edu.uci.ics.jung.graph.impl.BipartiteGraph.java

/**
 * Returns the set of all vertices from that class. 
 * All vertices in the return set will be of class
 * A or class B, depending on the parameter.
 *///from w  ww.j  a v a 2  s. c  o  m
public Set getAllVertices(Choice choice) {
    if (choice == CLASSA) {
        return Collections.unmodifiableSet(aSet);
    } else if (choice == CLASSB) {
        return Collections.unmodifiableSet(bSet);
    } else
        throw new IllegalArgumentException("Invalid partition specification " + choice);
}

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()}./*  ww w .j a v a  2  s  .co 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:alpha.portal.model.AlphaCaseCRA.java

/**
 * Gets the list of participants.//  w  w  w. j a v  a  2  s  .co m
 * 
 * @return list of participants as <b>unmodifiable</b> set
 */
public Set<User> getListOfParticipants() {
    return Collections.unmodifiableSet(this.participants);
}

From source file:de.xirp.profile.ProfileManager.java

/**
 * Returns the unique/*w  ww.  j  a v  a 2 s . co m*/
 * {@link de.xirp.profile.Profile profile} names.
 * 
 * @return An unmodifiable list with the profile names.
 * @see de.xirp.profile.Profile
 */
public static Set<String> getProfileNames() {
    return Collections.unmodifiableSet(profileNames);
}

From source file:Main.java

/**
 * Copies the given {@link Set} into a new {@link Set}.<br>
 * //  w w  w.ja v a  2s.  c  o  m
 * 
 * @param <T>
 *            the type of the entries of the set
 * @param data
 *            the given set
 * @return If the given set was empty, a {@link Collections#emptySet()} is
 *         returned<br>
 *         If the given set contained only one element, a
 *         {@link Collections#singleton(Object)}, containing said element,
 *         is returned <br>
 *         If the given set contained more than one element, a
 *         {@link Collections#unmodifiableSet(Set)}, containing the
 *         elements of the given set, is returned.
 */
public static <T> Set<T> copy(Set<T> data) {
    final int size = data.size();

    switch (size) {
    case 0:
        return Collections.emptySet();
    case 1:
        return Collections.singleton(data.iterator().next());
    default:
        return Collections.unmodifiableSet(new HashSet<T>(data));
    }
}

From source file:com.clustercontrol.notify.util.MonitorStatusCache.java

private static Set<MonitorStatusEntityPK> cacheKeys() {
    ICacheManager cm = CacheManagerFactory.instance().create();
    Set<MonitorStatusEntityPK> cacheKeys = cm.getKeySet(MonitorStatusEntityPK.class);
    return cacheKeys != null ? Collections.unmodifiableSet(cacheKeys) : null;
}