Example usage for java.util HashSet isEmpty

List of usage examples for java.util HashSet isEmpty

Introduction

In this page you can find the example usage for java.util HashSet isEmpty.

Prototype

public boolean isEmpty() 

Source Link

Document

Returns true if this set contains no elements.

Usage

From source file:com.mousefeed.eclipse.GlobalSelectionListener.java

/**
 * Checks if for the current action a keyboard shortcut can be configured.
 * /*  w  ww.jav a  2s  . co m*/
 * @param actionDesc ActionDesc for the current action. Not null.
 * @return true, if the current action has at least one ParameterizedCommand
 * (only those are listed in the keys preference page), false else.
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
protected boolean isConfigurableAction(final AbstractActionDesc actionDesc) {
    final String actionId = actionDesc.getId();

    final Command command = commandService.getCommand(actionId);
    if (command != null) {
        final HashSet allParameterizedCommands = new HashSet();
        try {
            allParameterizedCommands.addAll(ParameterizedCommand.generateCombinations(command));
        } catch (final NotDefinedException e) {
            // It is safe to just ignore undefined commands.
        }
        return !allParameterizedCommands.isEmpty();
    }
    return false;
}

From source file:org.kuali.coeus.common.impl.custom.attr.CustomAttributeServiceImpl.java

@Override
public Map<String, CustomAttributeDocument> getDefaultCustomAttributeDocuments(String documentTypeCode,
        List<? extends DocumentCustomData> customDataList) {
    Map<String, CustomAttributeDocument> customAttributeDocuments = new HashMap<String, CustomAttributeDocument>();
    Map<String, String> queryMap = new HashMap<String, String>();
    queryMap.put(PropertyConstants.DOCUMENT.TYPE_NAME.toString(), documentTypeCode);

    List<CustomAttributeDocument> customAttributeDocumentList = (List<CustomAttributeDocument>) businessObjectService
            .findMatching(CustomAttributeDocument.class, queryMap);

    HashSet<Long> customIds = new HashSet<Long>();
    if (customDataList != null) {
        customIds = getCurrentCustomAttributeIds(customDataList);
    }/*from w  ww  .  j  a  va  2s  .  co m*/
    for (CustomAttributeDocument customAttributeDocument : customAttributeDocumentList) {
        boolean customAttributeExists = false;
        if (!customIds.isEmpty() && customIds.contains(customAttributeDocument.getId().longValue())) {
            customAttributeExists = true;
        }

        if (customAttributeDocument.isActive() || customAttributeExists) {
            customAttributeDocuments.put(customAttributeDocument.getId().toString(), customAttributeDocument);
        }
    }
    return customAttributeDocuments;
}

From source file:org.abs_models.backend.erlang.ClassGenerator.java

private void generateExports() {
    ecs.println(/* w w  w.j  a  va  2  s .  com*/
            "-export([get_val_internal/2,set_val_internal/3,init_internal/0,get_state_for_modelapi/1,implemented_interfaces/0,exported/0]).");
    ecs.println("-compile(export_all).");
    ecs.println();

    HashSet<MethodSig> callable_sigs = new HashSet<>();
    HashSet<InterfaceDecl> visited = new HashSet<>();
    for (InterfaceTypeUse i : classDecl.getImplementedInterfaceUseList()) {
        visited.add((InterfaceDecl) i.getDecl());
    }

    while (!visited.isEmpty()) {
        InterfaceDecl id = visited.iterator().next();
        visited.remove(id);
        for (MethodSig ms : id.getBodyList()) {
            if (ms.isHTTPCallable()) {
                callable_sigs.add(ms);
            }
        }
        for (InterfaceTypeUse i : id.getExtendedInterfaceUseList()) {
            visited.add((InterfaceDecl) i.getDecl());
        }
    }

    ecs.print("implemented_interfaces() -> [ ");
    String separator = "";
    for (InterfaceDecl i : classDecl.getSuperTypes()) {
        ecs.format("%s<<\"%s\">>", separator, i.getName());
        separator = ", ";
    }
    ecs.println(" ].");
    ecs.println();

    ecs.print("exported() -> #{ ");
    boolean first = true;
    for (MethodSig ms : callable_sigs) {
        if (ms.isHTTPCallable()) {
            if (!first)
                ecs.print(", ");
            first = false;
            ecs.print("<<\"" + ms.getName() + "\">> => { ");
            ecs.print("'m_" + ms.getName() + "'");
            ecs.print(", ");
            ecs.print("<<\"" + ms.getReturnType().getType().toString() + "\">>");
            ecs.print(", ");
            ecs.print("[ ");
            boolean innerfirst = true;
            for (ParamDecl p : ms.getParamList()) {
                // For each parameter, we need name, human-readable type,
                // ABS type, and ABS type arguments (if present)
                if (!innerfirst)
                    ecs.print(", ");
                innerfirst = false;
                ecs.print("{ ");
                ecs.print("<<\"" + p.getName() + "\">>, ");
                ecs.print("<<\"" + p.getType().toString() + "\">>, ");
                generateParameterDescription(p.getType());
                ecs.print(" }");
            }
            ecs.print("] ");
            ecs.print("}");
        }
    }
    ecs.println(" }.");
    ecs.println();
}

From source file:org.apache.storm.utils.Utils.java

private static InputStream getConfigFileInputStream(String configFilePath) throws IOException {
    if (null == configFilePath) {
        throw new IOException("Could not find config file, name not specified");
    }/*from w  w w . ja  v  a  2  s .c  o m*/

    HashSet<URL> resources = new HashSet<URL>(findResources(configFilePath));
    if (resources.isEmpty()) {
        File configFile = new File(configFilePath);
        if (configFile.exists()) {
            return new FileInputStream(configFile);
        }
    } else if (resources.size() > 1) {
        throw new IOException("Found multiple " + configFilePath
                + " resources. You're probably bundling the Storm jars with your topology jar. " + resources);
    } else {
        LOG.debug("Using " + configFilePath + " from resources");
        URL resource = resources.iterator().next();
        return resource.openStream();
    }
    return null;
}

From source file:com.wellsandwhistles.android.redditsp.reddit.prepared.RedditPreparedPost.java

public static void onActionMenuItemSelected(final RedditPreparedPost post, final AppCompatActivity activity,
        final Action action) {

    switch (action) {

    case UPVOTE://from w ww .  ja  va  2 s .  c o  m
        post.action(activity, RedditAPI.ACTION_UPVOTE);
        break;

    case DOWNVOTE:
        post.action(activity, RedditAPI.ACTION_DOWNVOTE);
        break;

    case UNVOTE:
        post.action(activity, RedditAPI.ACTION_UNVOTE);
        break;

    case SAVE:
        post.action(activity, RedditAPI.ACTION_SAVE);
        break;

    case UNSAVE:
        post.action(activity, RedditAPI.ACTION_UNSAVE);
        break;

    case HIDE:
        post.action(activity, RedditAPI.ACTION_HIDE);
        break;

    case UNHIDE:
        post.action(activity, RedditAPI.ACTION_UNHIDE);
        break;
    case EDIT:
        final Intent editIntent = new Intent(activity, CommentEditActivity.class);
        editIntent.putExtra("commentIdAndType", post.src.getIdAndType());
        editIntent.putExtra("commentText", StringEscapeUtils.unescapeHtml4(post.src.getRawSelfText()));
        editIntent.putExtra("isSelfPost", true);
        activity.startActivity(editIntent);
        break;

    case DELETE:
        new AlertDialog.Builder(activity).setTitle(R.string.accounts_delete).setMessage(R.string.delete_confirm)
                .setPositiveButton(R.string.action_delete, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(final DialogInterface dialog, final int which) {
                        post.action(activity, RedditAPI.ACTION_DELETE);
                    }
                }).setNegativeButton(R.string.dialog_cancel, null).show();
        break;

    case REPORT:

        new AlertDialog.Builder(activity).setTitle(R.string.action_report)
                .setMessage(R.string.action_report_sure)
                .setPositiveButton(R.string.action_report, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(final DialogInterface dialog, final int which) {
                        post.action(activity, RedditAPI.ACTION_REPORT);
                        // TODO update the view to show the result
                        // TODO don't forget, this also hides
                    }
                }).setNegativeButton(R.string.dialog_cancel, null).show();

        break;

    case EXTERNAL: {
        final Intent intent = new Intent(Intent.ACTION_VIEW);
        String url = (activity instanceof WebViewActivity) ? ((WebViewActivity) activity).getCurrentUrl()
                : post.src.getUrl();
        intent.setData(Uri.parse(url));
        activity.startActivity(intent);
        break;
    }

    case SELFTEXT_LINKS: {

        final HashSet<String> linksInComment = LinkHandler
                .computeAllLinks(StringEscapeUtils.unescapeHtml4(post.src.getRawSelfText()));

        if (linksInComment.isEmpty()) {
            General.quickToast(activity, R.string.error_toast_no_urls_in_self);

        } else {

            final String[] linksArr = linksInComment.toArray(new String[linksInComment.size()]);

            final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
            builder.setItems(linksArr, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    LinkHandler.onLinkClicked(activity, linksArr[which], false, post.src.getSrc());
                    dialog.dismiss();
                }
            });

            final AlertDialog alert = builder.create();
            alert.setTitle(R.string.action_selftext_links);
            alert.setCanceledOnTouchOutside(true);
            alert.show();
        }

        break;
    }

    case SAVE_IMAGE: {

        ((BaseActivity) activity).requestPermissionWithCallback(Manifest.permission.WRITE_EXTERNAL_STORAGE,
                new SaveImageCallback(activity, post.src.getUrl()));
        break;
    }

    case SHARE: {

        final Intent mailer = new Intent(Intent.ACTION_SEND);
        mailer.setType("text/plain");
        mailer.putExtra(Intent.EXTRA_SUBJECT, post.src.getTitle());
        mailer.putExtra(Intent.EXTRA_TEXT, post.src.getUrl());
        activity.startActivity(Intent.createChooser(mailer, activity.getString(R.string.action_share)));
        break;
    }

    case SHARE_COMMENTS: {

        final boolean shareAsPermalink = PrefsUtility.pref_behaviour_share_permalink(activity,
                PreferenceManager.getDefaultSharedPreferences(activity));

        final Intent mailer = new Intent(Intent.ACTION_SEND);
        mailer.setType("text/plain");
        mailer.putExtra(Intent.EXTRA_SUBJECT, "Comments for " + post.src.getTitle());
        if (shareAsPermalink) {
            mailer.putExtra(Intent.EXTRA_TEXT,
                    Constants.Reddit.getNonAPIUri(post.src.getPermalink()).toString());
        } else {
            mailer.putExtra(Intent.EXTRA_TEXT, Constants.Reddit
                    .getNonAPIUri(Constants.Reddit.PATH_COMMENTS + post.src.getIdAlone()).toString());
        }
        activity.startActivity(
                Intent.createChooser(mailer, activity.getString(R.string.action_share_comments)));
        break;
    }

    case SHARE_IMAGE: {

        ((BaseActivity) activity).requestPermissionWithCallback(Manifest.permission.WRITE_EXTERNAL_STORAGE,
                new ShareImageCallback(activity, post.src.getUrl()));

        break;
    }

    case COPY: {

        ClipboardManager manager = (ClipboardManager) activity.getSystemService(Context.CLIPBOARD_SERVICE);
        manager.setText(post.src.getUrl());
        break;
    }

    case GOTO_SUBREDDIT: {

        try {
            final Intent intent = new Intent(activity, PostListingActivity.class);
            intent.setData(SubredditPostListURL.getSubreddit(post.src.getSubreddit()).generateJsonUri());
            activity.startActivityForResult(intent, 1);

        } catch (RedditSubreddit.InvalidSubredditNameException e) {
            Toast.makeText(activity, R.string.invalid_subreddit_name, Toast.LENGTH_LONG).show();
        }

        break;
    }

    case USER_PROFILE:
        LinkHandler.onLinkClicked(activity, new UserProfileURL(post.src.getAuthor()).toString());
        break;

    case PROPERTIES:
        PostPropertiesDialog.newInstance(post.src.getSrc()).show(activity.getSupportFragmentManager(), null);
        break;

    case COMMENTS:
        ((PostSelectionListener) activity).onPostCommentsSelected(post);

        new Thread() {
            @Override
            public void run() {
                post.markAsRead(activity);
            }
        }.start();

        break;

    case LINK:
        ((PostSelectionListener) activity).onPostSelected(post);
        break;

    case COMMENTS_SWITCH:
        if (!(activity instanceof MainActivity))
            activity.finish();
        ((PostSelectionListener) activity).onPostCommentsSelected(post);
        break;

    case LINK_SWITCH:
        if (!(activity instanceof MainActivity))
            activity.finish();
        ((PostSelectionListener) activity).onPostSelected(post);
        break;

    case ACTION_MENU:
        showActionMenu(activity, post);
        break;

    case REPLY:
        final Intent intent = new Intent(activity, CommentReplyActivity.class);
        intent.putExtra(CommentReplyActivity.PARENT_ID_AND_TYPE_KEY, post.src.getIdAndType());
        intent.putExtra(CommentReplyActivity.PARENT_MARKDOWN_KEY, post.src.getUnescapedSelfText());
        activity.startActivity(intent);
        break;

    case BACK:
        activity.onBackPressed();
        break;

    case PIN:

        try {
            String subredditCanonicalName = RedditSubreddit.getCanonicalName(post.src.getSubreddit());
            List<String> pinnedSubreddits = PrefsUtility.pref_pinned_subreddits(activity,
                    PreferenceManager.getDefaultSharedPreferences(activity));
            if (!pinnedSubreddits.contains(subredditCanonicalName)) {
                PrefsUtility.pref_pinned_subreddits_add(activity,
                        PreferenceManager.getDefaultSharedPreferences(activity), subredditCanonicalName);
            } else {
                Toast.makeText(activity, R.string.mainmenu_toast_pinned, Toast.LENGTH_SHORT).show();
            }
        } catch (RedditSubreddit.InvalidSubredditNameException e) {
            throw new RuntimeException(e);
        }

        break;

    case UNPIN:

        try {
            String subredditCanonicalName = RedditSubreddit.getCanonicalName(post.src.getSubreddit());
            List<String> pinnedSubreddits = PrefsUtility.pref_pinned_subreddits(activity,
                    PreferenceManager.getDefaultSharedPreferences(activity));
            if (pinnedSubreddits.contains(subredditCanonicalName)) {
                PrefsUtility.pref_pinned_subreddits_remove(activity,
                        PreferenceManager.getDefaultSharedPreferences(activity), subredditCanonicalName);
            } else {
                Toast.makeText(activity, R.string.mainmenu_toast_not_pinned, Toast.LENGTH_SHORT).show();
            }
        } catch (RedditSubreddit.InvalidSubredditNameException e) {
            throw new RuntimeException(e);
        }
        break;

    case BLOCK:

        try {
            String subredditCanonicalName = RedditSubreddit.getCanonicalName(post.src.getSubreddit());
            List<String> blockedSubreddits = PrefsUtility.pref_blocked_subreddits(activity,
                    PreferenceManager.getDefaultSharedPreferences(activity));
            if (!blockedSubreddits.contains(subredditCanonicalName)) {
                PrefsUtility.pref_blocked_subreddits_add(activity,
                        PreferenceManager.getDefaultSharedPreferences(activity), subredditCanonicalName);
            } else {
                Toast.makeText(activity, R.string.mainmenu_toast_blocked, Toast.LENGTH_SHORT).show();
            }
        } catch (RedditSubreddit.InvalidSubredditNameException e) {
            throw new RuntimeException(e);
        }
        break;

    case UNBLOCK:

        try {
            String subredditCanonicalName = RedditSubreddit.getCanonicalName(post.src.getSubreddit());
            List<String> blockedSubreddits = PrefsUtility.pref_blocked_subreddits(activity,
                    PreferenceManager.getDefaultSharedPreferences(activity));
            if (blockedSubreddits.contains(subredditCanonicalName)) {
                PrefsUtility.pref_blocked_subreddits_remove(activity,
                        PreferenceManager.getDefaultSharedPreferences(activity), subredditCanonicalName);
            } else {
                Toast.makeText(activity, R.string.mainmenu_toast_not_blocked, Toast.LENGTH_SHORT).show();
            }
        } catch (RedditSubreddit.InvalidSubredditNameException e) {
            throw new RuntimeException(e);
        }
        break;

    case SUBSCRIBE:

        try {
            String subredditCanonicalName = RedditSubreddit.getCanonicalName(post.src.getSubreddit());
            RedditSubredditSubscriptionManager subMan = RedditSubredditSubscriptionManager
                    .getSingleton(activity, RedditAccountManager.getInstance(activity).getDefaultAccount());

            if (subMan.getSubscriptionState(
                    subredditCanonicalName) == RedditSubredditSubscriptionManager.SubredditSubscriptionState.NOT_SUBSCRIBED) {
                subMan.subscribe(subredditCanonicalName, activity);
                Toast.makeText(activity, R.string.options_subscribing, Toast.LENGTH_SHORT).show();
            } else {
                Toast.makeText(activity, R.string.mainmenu_toast_subscribed, Toast.LENGTH_SHORT).show();
            }
        } catch (RedditSubreddit.InvalidSubredditNameException e) {
            throw new RuntimeException(e);
        }
        break;

    case UNSUBSCRIBE:

        try {
            String subredditCanonicalName = RedditSubreddit.getCanonicalName(post.src.getSubreddit());
            RedditSubredditSubscriptionManager subMan = RedditSubredditSubscriptionManager
                    .getSingleton(activity, RedditAccountManager.getInstance(activity).getDefaultAccount());
            if (subMan.getSubscriptionState(
                    subredditCanonicalName) == RedditSubredditSubscriptionManager.SubredditSubscriptionState.SUBSCRIBED) {
                subMan.unsubscribe(subredditCanonicalName, activity);
                Toast.makeText(activity, R.string.options_unsubscribing, Toast.LENGTH_SHORT).show();
            } else {
                Toast.makeText(activity, R.string.mainmenu_toast_not_subscribed, Toast.LENGTH_SHORT).show();
            }
        } catch (RedditSubreddit.InvalidSubredditNameException e) {
            throw new RuntimeException(e);
        }
        break;
    }
}

From source file:com.metaparadigm.jsonrpc.JSONRPCBridge.java

/**
 * Unregisters a LocalArgResolver</b>.
 * //from  w  w  w .j  av  a  2 s  .  co  m
 * @param argClazz
 *            The previously registered local class
 * @param argResolver
 *            The previously registered LocalArgResolver object
 * @param contextInterface
 *            The previously registered transport Context interface.
 */
public static void unregisterLocalArgResolver(Class argClazz, Class contextInterface,
        LocalArgResolver argResolver) {
    synchronized (localArgResolverMap) {
        HashSet resolverSet = (HashSet) localArgResolverMap.get(argClazz);
        if (resolverSet == null
                || !resolverSet.remove(new LocalArgResolverData(argResolver, argClazz, contextInterface))) {
            log.warning("local arg resolver " + argResolver.getClass().getName()
                    + " not registered for local class " + argClazz.getName() + " with context "
                    + contextInterface.getName());
            return;
        }
        if (resolverSet.isEmpty())
            localArgResolverMap.remove(argClazz);
        classCache = new HashMap(); // invalidate class cache
    }
    log.info("unregistered local arg resolver " + argResolver.getClass().getName() + " for local class "
            + argClazz.getName() + " with context " + contextInterface.getName());
}

From source file:edu.tum.cs.conqat.quamoco.qiesl.QIESLEngine.java

/**
 * @param expression//from  ww w  .j  a va 2  s .co  m
 * @param mandatoryVariables
 * @param nameMapping
 * @param usedTechnicalNames
 * @throws QIESLException
 */
private void checkMandatoryVariables(String expression, Map<String, Object> mandatoryVariables,
        Map<String, String> nameMapping, HashSet<String> usedTechnicalNames) throws QIESLException {
    HashSet<String> unusedModelVariables = new HashSet<String>(mandatoryVariables.keySet());
    for (String technicalName : usedTechnicalNames) {
        unusedModelVariables.remove(nameMapping.get(technicalName));
    }

    if (!unusedModelVariables.isEmpty() && !usedTechnicalNames.contains(ALL_IMPACTS_AND_REFINEMENTS_LITERAL)) {
        throw new QIESLException("Expression " + expression + " does not use mandatory variables: "
                + StringUtils.concat(unusedModelVariables, ", "));
    }
}

From source file:org.eclipse.ecr.core.api.repository.cache.DocumentModelCacheUpdater.java

@Override
public void handleEvents(OperationEvent[] events, boolean urgent) {
    HashSet<DocumentModel> updatedDocs = new HashSet<DocumentModel>(events.length);
    HashSet<DocumentModel> updatedTrees = new HashSet<DocumentModel>(events.length);
    for (OperationEvent event : events) {
        try {//from  w w  w.j  a  va2 s.com
            handleEvent(cache, updatedDocs, updatedTrees, event);
        } catch (Exception e) {
            log.error("Exception handling event", e);
        }
    }
    if (!listeners.isEmpty()) {
        if (!updatedDocs.isEmpty()) {
            DocumentModel[] docs = updatedDocs.toArray(new DocumentModel[updatedDocs.size()]);
            for (DocumentModelCacheListener listener : listeners) {
                try {
                    listener.documentsChanged(docs, urgent);
                } catch (Throwable error) {
                    log.error("An error while trying fire listener for document modifications", error);
                }
            }
        }
        if (!updatedTrees.isEmpty()) {
            DocumentModel[] docs = updatedTrees.toArray(new DocumentModel[updatedTrees.size()]);
            for (DocumentModelCacheListener listener : listeners) {
                try {
                    listener.subreeChanged(docs, urgent);
                } catch (Throwable error) {
                    log.error("An error while trying fire listener for document modifications", error);
                }
            }
        }
    }
}

From source file:de.steilerdev.myVerein.server.model.Event.java

/**
 * This function updates the list of invited user of this event
 * @param divisionRepository An active division repository used to expand the division set
 *//*from   ww  w.  j  a  v  a  2 s .c o m*/
public void updateInvitedUser(DivisionRepository divisionRepository) {
    if (invitedDivision == null || (invitedDivision = Division.getExpandedSetOfDivisions(invitedDivision,
            divisionRepository)) == null) {
        logger.error("Unable to update invited user, because invited divisions are null!");
    } else {
        logger.info("Updating invited user for event " + this);
        Set<String> oldInvitedUser = invitedUser == null ? new HashSet<>() : invitedUser.keySet();
        HashSet<String> newInvitedUser = new HashSet<>();
        invitedDivision.stream().forEach(div -> newInvitedUser.addAll(div.getMemberList()));

        if (oldInvitedUser.isEmpty() || newInvitedUser.isEmpty()) {
            logger.debug("Old set of invited user or new set of invited user is empty");
            invitedUser = new HashMap<>();
            if (oldInvitedUser.isEmpty() && !newInvitedUser.isEmpty()) {
                logger.debug("Old set of invited user is empty and new set of invited user is not empty");
                newInvitedUser.stream().forEach(userID -> invitedUser.put(userID, EventStatus.PENDING));
            } else if (newInvitedUser.isEmpty() && !oldInvitedUser.isEmpty()) {
                logger.debug("New set of invited user is empty and old set of invited user is not empty");
                oldInvitedUser.stream().forEach(userID -> invitedUser.put(userID, EventStatus.REMOVED));
                lastChanged = LocalDateTime.now();
            }
        } else {
            logger.debug("Old and new set of invited user is not empty");
            oldInvitedUser.removeAll(newInvitedUser);
            oldInvitedUser.stream().forEach(userID -> invitedUser.put(userID, EventStatus.REMOVED));
            newInvitedUser.stream().forEach(userID -> invitedUser.putIfAbsent(userID, EventStatus.PENDING));
            lastChanged = LocalDateTime.now();
        }
    }
}

From source file:org.fusesource.mop.support.Database.java

public TreeSet<String> uninstall(final String mainArtifact) throws IOException {
    assertOpen();//from  w  w  w. j a  v  a2s .c o m
    return pageFile.tx().execute(new Transaction.CallableClosure<TreeSet<String>, IOException>() {
        public TreeSet<String> execute(Transaction tx) throws IOException {
            RootEntity root = RootEntity.load(tx);
            BTreeIndex<String, HashSet<String>> artifacts = root.artifacts.get(tx);
            BTreeIndex<String, HashSet<String>> artifactIdIndex = root.artifactIdIndex.get(tx);
            BTreeIndex<String, HashSet<String>> typeIndex = root.typeIndex.get(tx);
            BTreeIndex<String, HashSet<String>> explicityInstalledArtifacts = root.explicityInstalledArtifacts
                    .get(tx);

            TreeSet<String> unused = new TreeSet<String>();
            HashSet<String> artifiactIds = explicityInstalledArtifacts.remove(tx, mainArtifact);
            for (String id : artifiactIds) {
                ArtifactId a = ArtifactId.strictParse(id);
                if (id == null) {
                    throw new IOException("Invalid artifact id: " + id);
                }
                HashSet<String> rc = artifacts.get(tx, id);
                rc.remove(mainArtifact);
                if (rc.isEmpty()) {
                    unused.add(id);
                    artifacts.remove(tx, id);
                    indexRemove(tx, artifactIdIndex, id, a.getArtifactId());
                    indexRemove(tx, typeIndex, id, a.getType());
                } else {
                    artifacts.put(tx, id, rc);
                }
            }

            root.tx_sequence++;
            root.store(tx);
            return unused;
        }
    });
}