Example usage for java.util Collections EMPTY_SET

List of usage examples for java.util Collections EMPTY_SET

Introduction

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

Prototype

Set EMPTY_SET

To view the source code for java.util Collections EMPTY_SET.

Click Source Link

Document

The empty set (immutable).

Usage

From source file:org.talend.updates.runtime.ui.feature.form.FeaturesSearchForm.java

private void doSearch(IProgressMonitor monitor, SearchOption searchOption) {
    monitor.beginTask(Messages.getString("ComponentsManager.form.install.label.progress.begin"), //$NON-NLS-1$
            IProgressMonitor.UNKNOWN);
    List<IFeatureItem> features = new ArrayList<>();
    Collection<IFeatureItem> featureItems = Collections.EMPTY_SET;
    SearchResult searchResult = null;
    FeaturesManager componentsManager = getRuntimeData().getFeaturesManager();

    try {//  w ww  . j  a v a 2 s  .  c o  m
        searchResult = componentsManager.searchFeatures(monitor, searchOption);
        Collection<ExtraFeature> allComponentFeatures = searchResult.getCurrentPageResult();
        allComponentFeatures = checkFeatures(allComponentFeatures);
        featureItems = ModelAdapter.convert(allComponentFeatures, false);
    } catch (Exception e) {
        ExceptionHandler.process(e);
    }

    if (featureItems == null) {
        featureItems = Collections.EMPTY_SET;
    }

    boolean showTitleBar = true;

    String titleMsg = ""; //$NON-NLS-1$
    Collection<Message> detailMessages = new ArrayList<>();
    if (featureItems.isEmpty()) {
        titleMsg = Messages.getString("ComponentsManager.form.install.label.head.searchResult.empty"); //$NON-NLS-1$
    } else {
        titleMsg = Messages.getString("ComponentsManager.form.install.label.head.featured"); //$NON-NLS-1$
        detailMessages = getRuntimeData().getFeaturesManager().createDefaultMessage();
    }

    if (searchOption.getType() == Type.ALL && searchOption.getCategory() == Category.ALL
            && StringUtils.isBlank(searchOption.getKeyword())) {
        try {
            monitor.setTaskName(Messages.getString("ComponentsManager.form.install.label.progress.waitUpdate")); //$NON-NLS-1$
            FeaturesCheckUpdateJob checkUpdateJob = getRuntimeData().getCheckUpdateJob();
            while (true) {
                if (checkUpdateJob.isFinished()) {
                    break;
                }
                UIUtils.checkMonitor(monitor);
                Thread.sleep(50);
            }
            Exception exception = checkUpdateJob.getException();
            if (exception != null) {
                ExceptionHandler.process(exception);
            }
            SearchResult checkUpdateResult = checkUpdateJob.getSearchResult();
            if (checkUpdateResult != null) {
                Collection<ExtraFeature> currentPageResult = checkUpdateResult.getCurrentPageResult();
                currentPageResult = checkFeatures(currentPageResult);
                if (currentPageResult != null && !currentPageResult.isEmpty()) {
                    FeatureUpdateNotification update = getRuntimeData().getFeaturesManager()
                            .createUpdateNotificationItem(false);
                    features.add(update);
                }
            }
        } catch (InterruptedException e) {
            // search function can skip the check udpate
            monitor.setCanceled(false);
            ExceptionHandler.process(e);
        } catch (Exception e) {
            ExceptionHandler.process(e);
        }
    }

    monitor.setTaskName(Messages.getString("ComponentsManager.form.install.label.generatingResult")); //$NON-NLS-1$

    if (showTitleBar) {
        FeatureTitle title = new FeatureTitle();
        title.setTitle(titleMsg);
        title.setMessages(detailMessages);
        features.add(title);
    }

    features.addAll(featureItems);

    if (searchResult != null && searchResult.hasMultiplePages()) {
        IFeatureNavigator navigator = createFeatureNavigator(searchResult);
        features.add(navigator);
    }

    Display.getDefault().asyncExec(new Runnable() {

        @Override
        public void run() {
            if (!featureListViewer.getControl().isDisposed()) {
                featureListViewer.setInput(features);
            }
            checkStatus();
        }
    });
}

From source file:org.eclipse.mylyn.internal.tasks.ui.TaskTrimWidget.java

private boolean contributeObjectActionsNew(IMenuManager manager) {
    try {//from w ww  . ja  v a2 s .  c om
        MethodUtils.invokeExactMethod(ObjectActionContributorManager.getManager(), "contributeObjectActions", //$NON-NLS-1$
                new Object[] { null, manager, activeTaskSelectionProvider, Collections.EMPTY_SET },
                new Class[] { IWorkbenchPart.class, IMenuManager.class, ISelectionProvider.class, Set.class });
    } catch (NoSuchMethodException e) {
        return false;
    } catch (IllegalAccessException e) {
        return false;
    } catch (InvocationTargetException e) {
        return false;
    }
    return true;
}

From source file:org.lockss.scheduler.TestTaskRunner.java

public void testAddToScheduleOkAfterDrops() {
    log.debug("testAddToScheduleOkAfterDrops()");
    ConfigurationUtil.addFromArgs(TaskRunner.PARAM_DROP_TASK_MAX, "10", TaskRunner.PARAM_MIN_CLEANUP_INTERVAL,
            "0");
    StepTask t1 = task(100, 200, 50);// w ww  .j  a v a  2 s . co m
    StepTask t2 = task(100, 200, 100);
    Schedule sched1 = sched(ListUtil.list(t1));
    Schedule sched2 = sched(ListUtil.list(t2));
    fact.setResults(ListUtil.list(sched1, null, null, sched2, sched2));
    TimeBase.step(101);
    assertTrue(tr.addToSchedule(t1));
    assertIsomorphic(ListUtil.list(t1), fact.scheduler.tasks);
    assertEquals(SetUtil.set(t1), SetUtil.theSet(tr.getAcceptedTasks()));
    assertForegroundStat(1, TaskRunner.STAT_ACCEPTED);
    assertForegroundStat(0, TaskRunner.STAT_REFUSED);
    assertForegroundStat(1, TaskRunner.STAT_WAITING);
    assertForegroundStat(0, TaskRunner.STAT_DROPPED);

    assertTrue(tr.addToSchedule(t2));
    assertEquals(ListUtil.list(ListUtil.list(t1), ListUtil.list(t1, t2), ListUtil.list(t1),
            Collections.EMPTY_SET, ListUtil.list(t1, t2)), fact.createArgs);
    assertEquals(SetUtil.set(t1, t2), SetUtil.theSet(fact.scheduler.tasks));
    assertTrue(t1.isDropped());
    assertEquals(sched2, tr.getCurrentSchedule());
    assertEquals(SetUtil.set(t1, t2), SetUtil.theSet(tr.getAcceptedTasks()));
    assertEquals(SetUtil.set(t1), SetUtil.theSet(tr.getOverrunTasks()));
    assertForegroundStat(2, TaskRunner.STAT_ACCEPTED);
    assertForegroundStat(0, TaskRunner.STAT_REFUSED);
    assertForegroundStat(1, TaskRunner.STAT_WAITING);
    assertForegroundStat(1, TaskRunner.STAT_DROPPED);

    t2.cancel();
    assertForegroundStat(2, TaskRunner.STAT_ACCEPTED);
    assertForegroundStat(0, TaskRunner.STAT_REFUSED);
    assertForegroundStat(0, TaskRunner.STAT_WAITING);
    assertForegroundStat(1, TaskRunner.STAT_DROPPED);
    assertForegroundStat(1, TaskRunner.STAT_CANCELLED);
}

From source file:uk.ac.ebi.intact.dataexchange.psimi.solr.ontology.OntologySearcher.java

private List<OntologyTerm> processOntologyTermHits(final QueryResponse queryResponse, final String id,
        final String termIdKey, final String termNameKey, final String termSynonymsKey)
        throws SolrServerException {

    final SolrDocumentList results = queryResponse.getResults();
    List<OntologyTerm> terms = new ArrayList<OntologyTerm>(results.size());

    List<String> processedIds = new ArrayList<String>(results.size() + 1);
    processedIds.add(id);/* w ww  .  j a  v  a 2 s.c  o  m*/

    for (SolrDocument solrDocument : results) {

        String parentId = (String) solrDocument.getFieldValue(termIdKey);
        String parentName = (String) solrDocument.getFieldValue(termNameKey);

        Collection<Object> fieldValues = solrDocument.getFieldValues(termSynonymsKey);
        Set<OntologyTerm> synonyms = new HashSet<OntologyTerm>();

        if (parentId != null && parentId.length() > 0 && fieldValues != null) {
            for (Object fieldValue : fieldValues) {
                synonyms.add(new LazyLoadedOntologyTerm(this, parentId, fieldValue.toString(),
                        Collections.EMPTY_SET));
            }
        }

        if (parentId != null && parentId.length() > 0 && !processedIds.contains(parentId)) {
            terms.add(newInternalOntologyTerm(parentId, parentName, synonyms));
            processedIds.add(parentId);
        }
    }

    return terms;
}

From source file:org.apache.fop.render.pdf.pdfbox.PDFBoxAdapter.java

private Object readCOSStream(COSStream originalStream, Object keyBase) throws IOException {
    InputStream in;//from  w ww . j  av a2  s .  c  om
    Set filter;
    if (pdfDoc.isEncryptionActive() || (originalStream.containsKey(COSName.DECODE_PARMS)
            && !originalStream.containsKey(COSName.FILTER))) {
        in = originalStream.getUnfilteredStream();
        filter = FILTER_FILTER;
    } else {
        //transfer encoded data (don't reencode)
        in = originalStream.getFilteredStream();
        filter = Collections.EMPTY_SET;
    }
    PDFStream stream = new PDFStream();
    OutputStream out = stream.getBufferOutputStream();
    IOUtils.copyLarge(in, out);
    transferDict(originalStream, stream, filter);
    return cacheClonedObject(keyBase, stream);
}

From source file:com.vmware.vfabric.ide.eclipse.tcserver.livegraph.LiveBeansGraphEditorSection.java

private void updateTableInput() {
    Display.getDefault().asyncExec(new Runnable() {
        public void run() {
            Set input = Collections.EMPTY_SET;
            try {
                input = listCommand.execute();
            } catch (TimeoutException e1) {
                // ignore, server may not be running
            } catch (CoreException e1) {
                // ignore, server may not be running
            }/*from   w w  w.  j  av  a2 s.  co  m*/
            if (appsViewer != null && appsViewer.getControl() != null
                    && !appsViewer.getControl().isDisposed()) {
                appsViewer.setInput(input);
                appsViewer.refresh();
            }
        }
    });
}

From source file:gov.nih.nci.evs.browser.utils.TreeUtils.java

/**
 * The given path represents a multi-tier association with associated
 * concepts and targets.  This method expands the association content
 * and adds results to the given tree item, recursing as necessary to
 * process each level in the path.//from w w  w  .  j a  v a  2  s  .  c  o m
 * <p>
 * Nodes in the association acts as the backbone for the display.
 * For each backbone node, additional children are resolved one level
 * deep along with an indication of further expandability.
 */
protected void addPathFromRoot(TreeItem ti, LexBIGService lbsvc, LexBIGServiceConvenienceMethods lbscm,
        String scheme, CodingSchemeVersionOrTag csvt, Association path, String[] associationsToNavigate,
        boolean associationsNavigatedFwd, Map<String, EntityDescription> codesToDescriptions)
        throws LBException {

    // First, add the branch point from the path ...
    ConceptReference branchRoot = path.getAssociationReference();
    String branchCode = branchRoot.getConceptCode();
    String branchCodeDescription = codesToDescriptions.containsKey(branchCode)
            ? codesToDescriptions.get(branchCode).getContent()
            : getCodeDescription(lbsvc, scheme, csvt, branchCode);

    TreeItem branchPoint = new TreeItem(branchCode, branchCodeDescription);
    String branchNavText = getDirectionalLabel(lbscm, scheme, csvt, path, associationsNavigatedFwd);

    // Now process elements in the branch ...
    AssociatedConceptList concepts = path.getAssociatedConcepts();
    for (int i = 0; i < concepts.getAssociatedConceptCount(); i++) {

        // Add all immediate leafs in the branch, and indication of
        // sub-nodes. Do not process codes already in the backbone here;
        // they will be printed in the recursive call ...
        AssociatedConcept concept = concepts.getAssociatedConcept(i);
        String code = concept.getConceptCode();
        TreeItem branchItem = new TreeItem(code, getCodeDescription(concept));
        branchPoint.addChild(branchNavText, branchItem);

        addChildren(branchItem, lbsvc, lbscm, scheme, csvt, code, codesToDescriptions.keySet(),
                associationsToNavigate, associationsNavigatedFwd);

        // Recurse to process the remainder of the backbone ...
        AssociationList nextLevel = concept.getSourceOf();
        if (nextLevel != null) {
            if (nextLevel.getAssociationCount() != 0) {
                // More levels left to process ...
                for (int j = 0; j < nextLevel.getAssociationCount(); j++)
                    addPathFromRoot(branchPoint, lbsvc, lbscm, scheme, csvt, nextLevel.getAssociation(j),
                            associationsToNavigate, associationsNavigatedFwd, codesToDescriptions);
            } else {
                // End of the line ...
                // Always add immediate children ot the focus code.
                addChildren(branchItem, lbsvc, lbscm, scheme, csvt, concept.getConceptCode(),
                        Collections.EMPTY_SET, associationsToNavigate, associationsNavigatedFwd);
            }
        }
    }

    // Add the populated tree item to those tracked from root.
    ti.addChild(branchNavText, branchPoint);
}

From source file:com.epam.cme.core.validation.CustomValidationService.java

@Override
public Collection<ConstraintGroupModel> getActiveConstraintGroups() {
    final Object groups = getSessionService().getAttribute(SESSIONCONSTRAINTGROUPS);
    return groups == null ? Collections.EMPTY_SET : (Collection<ConstraintGroupModel>) groups;
}

From source file:nl.alders.openam.YubikeyModule.java

/**
 * Gets the AMIdentity of a user with username equal to uName.
 *
 * @param uName username of the user to get.
 * @return The AMIdentity of user with username equal to uName.
 *//*  w ww  .  ja  v a2  s .  c  o m*/
private AMIdentity getIdentity(String uName) {
    AMIdentity theID = null;
    AMIdentityRepository amIdRepo = getAMIdentityRepository(getRequestOrg());
    IdSearchControl idsc = new IdSearchControl();
    idsc.setAllReturnAttributes(true);
    // search for the identity
    Set<AMIdentity> results = Collections.EMPTY_SET;
    try {
        idsc.setMaxResults(0);
        IdSearchResults searchResults = amIdRepo.searchIdentities(IdType.USER, uName, idsc);
        if (searchResults != null) {
            results = searchResults.getSearchResults();
        }
        if (results == null || results.size() != 1) {
            throw new IdRepoException("Yubikey" + ".getIdentity : " + "More than one user found");

        }
        theID = results.iterator().next();
    } catch (IdRepoException e) {
        debug.error("Yubikey.getIdentity : error searching Identities with username : " + userName, e);
    } catch (SSOException e) {
        debug.error("Yubikey.getIdentity : AuthOATH module exception : ", e);
    }
    return theID;
}

From source file:org.intermine.web.struts.InitialiserPlugin.java

private void loadAspectsConfig(ServletContext servletContext) {
    InputStream xmlInputStream = servletContext.getResourceAsStream("/WEB-INF/aspects.xml");
    InputStream xmlInputStreamForValidate = servletContext.getResourceAsStream("/WEB-INF/aspects.xml");
    if (xmlInputStream == null) {
        LOG.info("Unable to find /WEB-INF/aspects.xml, there will be no aspects");
        SessionMethods.setAspects(servletContext, Collections.EMPTY_MAP);
        SessionMethods.setCategories(servletContext, Collections.EMPTY_SET);
    } else {// w  ww .j a va  2s . co  m
        StringWriter writer = new StringWriter();
        try {
            IOUtils.copy(xmlInputStreamForValidate, writer);
        } catch (IOException ioe) {
            LOG.error("Problems converting xmlInputStream into a String ", ioe);
            blockingErrorKeys.put("errors.init.aspects.generic", ioe.getMessage());
            return;
        }
        String xml = writer.toString();
        String xmlSchemaUrl = "";
        try {
            xmlSchemaUrl = servletContext.getResource("/WEB-INF/aspects.xsd").toString();
        } catch (MalformedURLException mue) {
            LOG.warn("Problems retrieving url fo aspects.xsd ", mue);
        }
        Map<String, Aspect> aspects;
        if (validateXML(xml, xmlSchemaUrl, "errors.init.aspects.validation")) {
            try {
                aspects = AspectBinding.unmarhsal(xmlInputStream);
            } catch (Exception e) {
                LOG.error("problem while reading aspect configuration file", e);
                blockingErrorKeys.put("errors.init.aspects", e.getMessage());
                return;
            }
            SessionMethods.setAspects(servletContext, aspects);
            SessionMethods.setCategories(servletContext, Collections.unmodifiableSet(aspects.keySet()));
        }
    }
}