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.forgerock.openam.authentication.modules.impersonation.ImpersonationModule.java

/**
 * Gets the group's AMIdentity from LDAP.
 *
 * @param groupName The group name./*from   w  w  w.  j a v a 2s  .c o  m*/
 * @return The AMIdentity for the group.
 */
public AMIdentity getGroupIdentity(String groupName) {
    AMIdentity amIdentity = null;
    AMIdentityRepository amIdRepo = getAMIdentityRepository(getRequestOrg());

    IdSearchControl idsc = new IdSearchControl();
    idsc.setAllReturnAttributes(true);
    Set<AMIdentity> results = Collections.EMPTY_SET;

    try {
        idsc.setMaxResults(0);
        IdSearchResults searchResults = amIdRepo.searchIdentities(IdType.GROUP, groupName, idsc);
        if (searchResults != null) {
            results = searchResults.getSearchResults();
            System.out.println("results: " + results);
        }

        if (results.isEmpty()) {
            throw new IdRepoException("getIdentity : group " + groupName + " is not found");
        } else if (results.size() > 1) {
            throw new IdRepoException(
                    "getIdentity : More than one result found for the groupName " + groupName);
        }

        amIdentity = results.iterator().next();
    } catch (IdRepoException e) {
        debug.error("Error searching Identities with groupName : " + groupName, e);
    } catch (SSOException e) {
        debug.error("Module exception : ", e);
    }

    return amIdentity;
}

From source file:io.github.jeddict.jcode.util.POMManager.java

private void registerRepository(List<org.apache.maven.model.Repository> sourceRepositories) {
    if (sourceRepositories.size() > 0) {
        operations.add(pomModel -> {//ww w.  j  a  v a 2 s.c  om
            Set<String> existingRepositories = getPOMProject().getRepositories() != null
                    ? getPOMProject().getRepositories().stream().map(Repository::getId).collect(toSet())
                    : Collections.EMPTY_SET;
            for (org.apache.maven.model.Repository sourceRepository : sourceRepositories) {
                if (!existingRepositories.contains(sourceRepository.getId())) {
                    Repository repo = pomModel.getFactory().createRepository();
                    repo.setId(sourceRepository.getId());//isSnapshot ? MavenNbModuleImpl.NETBEANS_SNAPSHOT_REPO_ID : MavenNbModuleImpl.NETBEANS_REPO_ID);
                    repo.setName(sourceRepository.getName());
                    repo.setLayout(sourceRepository.getLayout());
                    repo.setUrl(sourceRepository.getUrl());
                    if (sourceRepository.getSnapshots() != null) {
                        RepositoryPolicy policy = pomModel.getFactory().createReleaseRepositoryPolicy();
                        policy.setEnabled(Boolean.valueOf(sourceRepository.getSnapshots().getEnabled()));
                        repo.setReleases(policy);
                    }
                    getPOMProject().addRepository(repo);
                }
            }
        });
    }
}

From source file:com.espertech.esper.core.service.StatementLifecycleSvcImpl.java

private Set<EventType> populateSubqueryTypes(ExprSubselectNode[] subSelectExpressions) {
    Set<EventType> set = null;
    for (ExprSubselectNode subselect : subSelectExpressions) {
        for (StreamSpecCompiled streamSpec : subselect.getStatementSpecCompiled().getStreamSpecs()) {
            if (streamSpec instanceof FilterStreamSpecCompiled) {
                EventType type = ((FilterStreamSpecCompiled) streamSpec).getFilterSpec()
                        .getFilterForEventType();
                if (set == null) {
                    set = new HashSet<EventType>();
                }//from   ww w  . j av a2  s .  com
                set.add(type);
            } else if (streamSpec instanceof PatternStreamSpecCompiled) {
                EvalNodeAnalysisResult evalNodeAnalysisResult = EvalNodeUtil.recursiveAnalyzeChildNodes(
                        ((PatternStreamSpecCompiled) streamSpec).getEvalFactoryNode());
                List<EvalFilterFactoryNode> filterNodes = evalNodeAnalysisResult.getFilterNodes();
                for (EvalFilterFactoryNode filterNode : filterNodes) {
                    if (set == null) {
                        set = new HashSet<EventType>();
                    }
                    set.add(filterNode.getFilterSpec().getFilterForEventType());
                }
            }
        }
    }
    if (set == null) {
        return Collections.EMPTY_SET;
    }
    return set;
}

From source file:module.mission.domain.MissionProcess.java

public Collection<MissionProcess> getAssociatedMissionProcesses() {
    if (!hasMissionProcessAssociation()) {
        return Collections.EMPTY_SET;
    }//from   w  w  w .ja v  a2s.  c o  m
    List<MissionProcess> associatedProcesses = new ArrayList<MissionProcess>();
    associatedProcesses.addAll(getMissionProcessAssociation().getMissionProcesses());
    associatedProcesses.remove(this);

    return associatedProcesses;
}

From source file:de.csw.expertfinder.expertise.ExpertiseModel.java

/**
 * Returns all topic names the given author has contributed to.
 * @param authorName the author's name//w  w w  .  j a  va  2  s  .c  om
 * @return a list containing all topic names the given author has contributed to.
 */
@SuppressWarnings("unchecked")
public Set<String> getTopicsForAuthor(String authorName) {

    Set<String> result = new TreeSet<String>();

    OntModel model = OntologyIndex.get().getModel();

    persistenceStore.beginTransaction();

    Author author = persistenceStore.getAuthor(authorName);
    List<AuthorContribution> contributions = persistenceStore.getCachedAuthorContributions(author);

    persistenceStore.endTransaction();

    if (!contributions.isEmpty()) {
        for (AuthorContribution authorContribution : contributions) {
            String uri = authorContribution.getConcept().getUri();
            OntClass clazz = model.getOntClass(uri);
            ExtendedIterator iter = clazz.listLabels(Config.getAppProperty(Config.Key.LANGUAGE));
            while (iter.hasNext()) {
                String label = ((Literal) iter.next()).getString();
                result.add(label);
            }
        }
        return result;
    }

    if (author == null) {
        return Collections.EMPTY_SET;
    }

    persistenceStore.beginTransaction();
    List<Concept> directContributions = persistenceStore.getContributedTopics(author);
    List<Concept> indirectContributions = persistenceStore.getIndirectContributedTopics(author);
    persistenceStore.endTransaction();

    for (Concept topic : directContributions) {
        OntClass clazz = model.getOntClass(topic.getUri());
        ExtendedIterator iter = clazz.listLabels(Config.getAppProperty(Config.Key.LANGUAGE));
        while (iter.hasNext()) {
            String label = ((Literal) iter.next()).getString();
            result.add(label);
        }
    }

    for (Concept topic : indirectContributions) {
        OntClass clazz = model.getOntClass(topic.getUri());
        ExtendedIterator iter = clazz.listLabels(Config.getAppProperty(Config.Key.LANGUAGE));
        while (iter.hasNext()) {
            String label = ((Literal) iter.next()).getString();
            result.add(label);
        }
    }

    return result;
}

From source file:net.sourceforge.fenixedu.domain.StudentCurricularPlan.java

public Set<CurriculumGroup> getAllCurriculumGroups() {
    return isBoxStructure() ? getRoot().getAllCurriculumGroups() : Collections.EMPTY_SET;
}

From source file:hudson.model.Computer.java

@Exported
public Set<LabelAtom> getAssignedLabels() {
    Node node = getNode();
    return (node != null) ? node.getAssignedLabels() : Collections.EMPTY_SET;
}

From source file:net.sourceforge.fenixedu.domain.StudentCurricularPlan.java

public Set<CurriculumGroup> getAllCurriculumGroupsWithoutNoCourseGroupCurriculumGroups() {
    return isBoxStructure() ? getRoot().getAllCurriculumGroupsWithoutNoCourseGroupCurriculumGroups()
            : Collections.EMPTY_SET;
}

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

public HashMap getAssociationTargets(String scheme, String version, String code, String assocName) {
    HashMap hmap = new HashMap();
    TreeItem ti = null;//  w  w  w .j  a  v a  2  s.  c  om
    long ms = System.currentTimeMillis();
    Util.StopWatch stopWatch = new Util.StopWatch(); //DYEE

    Set<String> codesToExclude = Collections.EMPTY_SET;

    CodingSchemeVersionOrTag csvt = new CodingSchemeVersionOrTag();
    if (version != null)
        csvt.setVersion(version);
    ResolvedConceptReferenceList matches = null;
    Vector v = new Vector();
    try {
        //EVSApplicationService lbSvc = new RemoteServerUtil().createLexBIGService();
        LexBIGService lbSvc = RemoteServerUtil.createLexBIGService();
        LexBIGServiceConvenienceMethods lbscm = (LexBIGServiceConvenienceMethods) lbSvc
                .getGenericExtension("LexBIGServiceConvenienceMethods");
        lbscm.setLexBIGService(lbSvc);

        String name = getCodeDescription(lbSvc, scheme, csvt, code);
        ti = new TreeItem(code, name);
        ti.expandable = false;

        CodedNodeGraph cng = lbSvc.getNodeGraph(scheme, csvt, null);
        ConceptReference focus = Constructors.createConceptReference(code, scheme);
        cng = cng.restrictToAssociations(Constructors.createNameAndValueList(assocName), null);
        boolean associationsNavigatedFwd = true;
        /*
                 ResolvedConceptReferenceList branch = cng.resolveAsList(focus, associationsNavigatedFwd,
                       !associationsNavigatedFwd, -1, 2, noopList_, null, null, null, -1, true);
        */
        ResolvedConceptReferenceList branch = cng.resolveAsList(focus, associationsNavigatedFwd,
                !associationsNavigatedFwd, -1, 2, noopList_, null, null, null, -1, false);

        for (Iterator<ResolvedConceptReference> nodes = branch.iterateResolvedConceptReference(); nodes
                .hasNext();) {
            ResolvedConceptReference node = nodes.next();
            AssociationList childAssociationList = associationsNavigatedFwd ? node.getSourceOf()
                    : node.getTargetOf();

            // Process each association defining children ...
            for (Iterator<Association> pathsToChildren = childAssociationList
                    .iterateAssociation(); pathsToChildren.hasNext();) {
                Association child = pathsToChildren.next();
                String childNavText = getDirectionalLabel(lbscm, scheme, csvt, child, associationsNavigatedFwd);

                // Each association may have multiple children ...
                AssociatedConceptList branchItemList = child.getAssociatedConcepts();
                for (Iterator<AssociatedConcept> branchNodes = branchItemList
                        .iterateAssociatedConcept(); branchNodes.hasNext();) {
                    AssociatedConcept branchItemNode = branchNodes.next();
                    String branchItemCode = branchItemNode.getConceptCode();

                    // Add here if not in the list of excluded codes.
                    // This is also where we look to see if another level
                    // was indicated to be available.  If so, mark the
                    // entry with a '+' to indicate it can be expanded.
                    if (!codesToExclude.contains(branchItemCode)) {
                        TreeItem childItem = new TreeItem(branchItemCode, getCodeDescription(branchItemNode));
                        ti.expandable = true;
                        AssociationList grandchildBranch = associationsNavigatedFwd
                                ? branchItemNode.getSourceOf()
                                : branchItemNode.getTargetOf();
                        if (grandchildBranch != null)
                            childItem.expandable = true;
                        ti.addChild(childNavText, childItem);
                    }
                }
            }
        }
        hmap.put(code, ti);

    } catch (Exception ex) {
        ex.printStackTrace();
    }
    _logger.debug(
            "Run time (milliseconds) getSubconcepts: " + (System.currentTimeMillis() - ms) + " to resolve ");
    _logger.debug("DYEE: getSubconcepts: " + stopWatch.getResult() + " to resolve ");
    return hmap;
}

From source file:io.github.jeddict.jpa.spec.extend.MultiRelationAttribute.java

@Override
public Set<Class<? extends Constraint>> getKeyConstraintsClass() {
    if (!isMap(getCollectionType())) {
        return Collections.EMPTY_SET;
    }/*from w  ww  .ja  v  a  2 s . c  o m*/
    return getConstraintsClass(getMapKeyDataTypeLabel());
}