Example usage for java.util Set remove

List of usage examples for java.util Set remove

Introduction

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

Prototype

boolean remove(Object o);

Source Link

Document

Removes the specified element from this set if it is present (optional operation).

Usage

From source file:com.l2jfree.util.Introspection.java

private static void deepToString(Object obj, StringBuilder dest, Set<Object> dejaVu)
        throws SecurityException, NoSuchMethodException {
    if (obj == null) {
        dest.append("null");
        return;//  ww  w  .j ava 2s  .co  m
    }

    if (obj.getClass().isArray()) {
        final int length = Array.getLength(obj);

        if (length == 0) {
            dest.append("[]");
            return;
        }

        if (dejaVu == null)
            dejaVu = new HashSet<Object>();
        dejaVu.add(obj);

        dest.append('[');
        for (int i = 0; i < length; i++) {
            if (i != 0)
                dest.append(", ");

            final Object element = Array.get(obj, i);

            if (dejaVu.contains(element))
                dest.append("[...]");
            else
                deepToString(element, dest, dejaVu);
        }
        dest.append(']');

        dejaVu.remove(obj);
    } else {
        if (obj.getClass().getMethod("toString").getDeclaringClass() == Object.class)
            dest.append(Introspection.toString(obj));
        else
            dest.append(obj.toString());
    }
}

From source file:de.ingrid.admin.security.AbstractLoginModule.java

@Override
public boolean logout() throws LoginException {
    Set<Principal> principals = _subject.getPrincipals();
    principals.remove(_currentPrincipal);
    return true;// ww w  .  j  a v a 2  s  .  com
}

From source file:com.doculibre.constellio.solr.context.SolrCoreContext.java

public static synchronized void initCores() {
    try {/*from w  w w  .  j a va 2  s  .com*/

        // do not use CoreAdminRequest
        Set<String> collectionNameSet = new HashSet<String>();
        mainSolrServer.connect();
        ZkStateReader reader = mainSolrServer.getZkStateReader();
        ClusterState state = reader.getClusterState();

        // do synchronization between coreServers and solrCloud
        for (String collectionName : state.getCollections()) {
            if (!collectionName.startsWith("_") || DEFAULT_COLLECTION_NAME.equals(collectionName)) {
                // "_xxx" is for system only, not for users
                collectionNameSet.add(collectionName);
            }
        }

        Map<String, String> aliasMap = reader.getAliases().getCollectionAliasMap();
        if (aliasMap != null) {
            for (String aliasName : aliasMap.keySet()) {
                if (!aliasName.startsWith("_")) {
                    // "_xxx" is for system only, not for users
                    collectionNameSet.remove(aliasMap.get(aliasName));
                    collectionNameSet.add(aliasName);
                }
            }
        }

        for (String collectionName : collectionNameSet) {
            if (!coreServers.containsKey(collectionName)) {
                setHttpSolrServer(collectionName, ConstellioSpringUtils.getSolrServerAddress());
            }
        }

        userCoreNames.clear();
        Iterator<Map.Entry<String, SolrServer>> iter = coreServers.entrySet().iterator();
        while (iter.hasNext()) {
            Map.Entry<String, SolrServer> entry = iter.next();
            if (!collectionNameSet.contains(entry.getKey())) {
                entry.getValue().shutdown();
                iter.remove();
            } else if (!DEFAULT_COLLECTION_NAME.equals(entry.getKey())) {
                userCoreNames.add(entry.getKey());
            }
        }

        // CoreAdminRequest adminRequest = new CoreAdminRequest();
        // adminRequest.setAction(CoreAdminAction.STATUS);
        // CoreAdminResponse adminResponse =
        // adminRequest.process(solrServer);
        // NamedList<NamedList<Object>> coreStatus =
        // adminResponse.getCoreStatus();
        // for (Object core : coreStatus) {
        // String coreName = StringUtils.substringBefore(core.toString(),
        // "=");
        // if (!coreName.startsWith("_"))// "_xxx" is for system only, like
        // "_log", "_fetch_db"
        // setHttpSolrServer(coreName, ((HttpSolrServer)
        // solrServer).getBaseURL());
        // }
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}

From source file:egat.cli.removeaction.RemoveActionCommandHandler.java

protected void processSymmetricGame(MutableSymmetricGame game) throws CommandProcessingException {
    Set<Action> actions = new HashSet<Action>(game.getActions());
    actions.remove(Games.createAction(actionId));

    try {// w  w w .  j  a  v a 2  s .  co m

        SymmetricGameWriter writer = new SymmetricGameWriter(System.out);

        writer.write(new ActionReducedSymmetricGame(game, actions));

    } catch (IOException e) {
        throw new CommandProcessingException(e);
    }
}

From source file:org.osiam.resource_server.security.authorization.DynamicHTTPMethodScopeEnhancer.java

private Set<ConfigAttribute> ifScopeDynamicAddMethodScope(final Object object,
        final Collection<ConfigAttribute> attributes) {
    Set<ConfigAttribute> dynamicConfigs = new HashSet<>(attributes);
    if (object instanceof FilterInvocation && dynamicConfigs.remove(dynamic)) {
        addMethodScope(object, dynamicConfigs);
    }//from  w w  w  .  j ava2s.com
    return dynamicConfigs;
}

From source file:net.dv8tion.jda.handle.ReadyHandler.java

public void onGuildInit(Guild guild) {
    Set<String> ids = guildIds.get(api);
    ids.remove(guild.getId());
    if (ids.isEmpty()) {
        finishReady(cachedJson.get(api));
    } else if (ids.size() == chunkIds.get(api).size()) {
        sendChunks();/*from w ww. j  a  va 2  s .c  o m*/
    }
}

From source file:org.iwethey.forums.web.post.ExpandedHistory.java

/**
 * Remove an entry from the set of expanded entries. If there are
 * no more expanded entries for this post, remove the set completely
 * to clean it up./*from   ww  w.  j a va2s  . co  m*/
 * <p>
 * @param postExpanded The set of currently expanded history entries.
 * @param id The ID of the post being checked.
 * @param index The index of the history entry to remove. 
 */
private void checkRemove(Set postExpanded, Integer id, Integer index) {
    postExpanded.remove(index);

    if (postExpanded.size() == 0)
        remove(id);
}

From source file:egat.cli.removeaction.RemoveActionCommandHandler.java

protected void processStrategicGame(MutableStrategicGame game) throws CommandProcessingException {
    Player player = Games.createPlayer(playerId);
    Set<Action> actions = new HashSet<Action>(game.getActions(player));
    actions.remove(Games.createAction(actionId));

    try {/*from  w  ww . j av  a2 s . c o m*/

        StrategicGameWriter writer = new StrategicGameWriter(System.out);

        writer.write(new ActionReducedStrategicGame(game, player, actions));

    } catch (IOException e) {
        throw new CommandProcessingException(e);
    }
}

From source file:com.navercorp.pinpoint.collector.cluster.zookeeper.PinpointServerRepository.java

public boolean removeAndGetIsKeyRemoved(String key, PinpointServer pinpointServer) {
    synchronized (this) {
        boolean isContains = pinpointServerRepository.containsKey(key);
        if (isContains) {
            Set<PinpointServer> pinpointServerSet = pinpointServerRepository.get(key);
            pinpointServerSet.remove(pinpointServer);

            if (pinpointServerSet.isEmpty()) {
                pinpointServerRepository.remove(key);
                return true;
            }//from w ww  . ja va2 s .c o  m
        }
        return false;
    }
}

From source file:de.kaiserpfalzEdv.iam.core.role.AttachedPermission.java

protected void clearPermission(Set<Permission> permissions) {
    while (permissions.contains(this)) {
        permissions.remove(this);
    }/*from   w  w w.  j  a  v  a 2s.  c o m*/
}