Example usage for java.util Set contains

List of usage examples for java.util Set contains

Introduction

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

Prototype

boolean contains(Object o);

Source Link

Document

Returns true if this set contains the specified element.

Usage

From source file:com.tealcube.minecraft.bukkit.mythicdrops.utils.ChatColorUtil.java

public static ChatColor getRandomChatColorWithoutColors(ChatColor... colors) {
    Set<ChatColor> colors1 = Sets.newHashSet(ChatColor.values());
    for (ChatColor c : colors) {
        if (colors1.contains(c)) {
            colors1.remove(c);//from ww w.  ja  v a 2  s .c o  m
        }
    }
    return getRandomChatColorFromSet(colors1);
}

From source file:Main.java

public static String[] getAllCategories(Set<String> set) {
    List<String> result = new ArrayList<String>();
    for (String key : categoryMapping.keySet()) {
        if (set.contains(categoryMapping.get(key))) {
            // if (key.equals(EVENT_NONCATEGORIZED) ||
            // key.equals(POI_NONCATEGORIZED) ||
            // key.equals(STORY_NONCATEGORIZED)) {
            ///*from  w  w w . ja v a  2  s  .  c om*/
            // result.add(null);
            // }
            result.add(key);
            // set.remove(categoryMapping.get(key));
        }
    }
    return result.toArray(new String[result.size()]);
}

From source file:SetUtils.java

public static Set intersection(Set a, Set b) {
    Set c = new HashSet();
    for (Iterator iter = b.iterator(); iter.hasNext();) {
        Object e = iter.next();//from  w w  w. ja  v a  2  s  . c  o m
        if (a.contains(e)) {
            c.add(e);
        }
    }
    return c;
}

From source file:Main.java

private static Set<String> filter(final List<String> enabledCiphers, final Set<String> supportedCiphers) {
    Set<String> result = new LinkedHashSet<String>();
    for (String enabledCipher : enabledCiphers) {
        if (supportedCiphers.contains(enabledCipher)) {
            result.add(enabledCipher);//from  ww  w.j av  a 2  s . c o  m
        }
    }
    return result;
}

From source file:com.liferay.sync.engine.util.MSOfficeFileUtil.java

protected static boolean hasExtension(String extension, Set<String> extensions) {

    if ((extension != null) && extensions.contains(extension.toLowerCase())) {

        return true;
    }//from w ww . ja  va 2 s.co m

    return false;
}

From source file:Comparing.java

public static <T> boolean haveEqualElements(T[] a, T[] b) {
    if (a == null || b == null) {
        return a == b;
    }/*from   w  w  w  .ja v a2  s  .c o m*/

    if (a.length != b.length) {
        return false;
    }

    Set<T> aSet = new HashSet<T>(Arrays.asList(a));
    for (T t : b) {
        if (!aSet.contains(t)) {
            return false;
        }
    }
    return true;
}

From source file:com.vmware.identity.openidconnect.common.Scope.java

private static void validate(Set<ScopeValue> valueSet) throws ParseException {
    if (!valueSet.contains(ScopeValue.OPENID)) {
        throw new ParseException(ErrorObject.invalidScope("missing openid scope value"));
    }//from   w  w w  . j  a  v a 2 s .c o  m

    if (valueSet.contains(ScopeValue.ID_TOKEN_GROUPS)
            && valueSet.contains(ScopeValue.ID_TOKEN_GROUPS_FILTERED)) {
        throw new ParseException(
                ErrorObject.invalidScope("id_groups together with id_groups_filtered is not allowed"));
    }

    if (valueSet.contains(ScopeValue.ACCESS_TOKEN_GROUPS)
            && valueSet.contains(ScopeValue.ACCESS_TOKEN_GROUPS_FILTERED)) {
        throw new ParseException(
                ErrorObject.invalidScope("at_groups together with at_groups_filtered is not allowed"));
    }

    boolean resourceServerRequested = false;
    for (ScopeValue scopeValue : valueSet) {
        if (scopeValue.denotesResourceServer()) {
            resourceServerRequested = true;
            break;
        }
    }

    if (valueSet.contains(ScopeValue.ID_TOKEN_GROUPS_FILTERED) && !resourceServerRequested) {
        throw new ParseException(ErrorObject
                .invalidScope("id_token filtered groups requested but no resource server requested"));
    }

    if ((valueSet.contains(ScopeValue.ACCESS_TOKEN_GROUPS)
            || valueSet.contains(ScopeValue.ACCESS_TOKEN_GROUPS_FILTERED)) && !resourceServerRequested) {
        throw new ParseException(
                ErrorObject.invalidScope("access_token groups requested but no resource server requested"));
    }
}

From source file:io.apiman.gateway.vertx.http.HttpServiceFactory.java

private static void parseHeaders(Map<String, String> map, MultiMap multimap, Set<String> suppressHeaders) {
    for (Map.Entry<String, String> entry : multimap) {
        if (!suppressHeaders.contains(entry.getKey())) {
            map.put(entry.getKey(), entry.getValue());
        }/*  w  w  w . ja  v  a2  s  . c o m*/
    }
}

From source file:Main.java

public static <K, V> Set<V> valueToTreeSet(Map<K, V> map) {
    if (isNotNull(map)) {
        Set<V> set = new TreeSet<>();
        for (V v : map.values()) {
            System.out.println(v.hashCode());
            System.out.println(set.contains(v));
            set.add(v);//from   www .  j a  va  2s .co  m
        }
        return set;
    }
    return null;
}

From source file:Main.java

/**
 * Tests if two collections have the same elements without considering the order
 * //from   www .j  a va 2  s  .c  om
 * @param collection1
 * @param collection2
 * 
 * @return true if both collections have the same elements or both collections are null or empty, fasle otherwise
 */
public static boolean elementsEqual(final Collection<?> collection1, final Collection<?> collection2) {
    if (collection1 == null && collection2 == null) {
        return true;
    } else if (collection1 == null) {
        return false;
    } else if (collection2 == null) {
        return false;
    } else if (collection1 == collection2) {
        return true;
    } else {
        final int size1 = collection1.size();
        final int size2 = collection2.size();
        if (size1 != size2) {
            return false;
        } else {//size1 == size2
            final Set<Object> set2 = new HashSet<Object>(collection2);
            for (final Object objectOfCollection1 : collection1) {
                if (!set2.contains(objectOfCollection1)) {
                    return false;
                }
            }
            return true;
        }
    }
}