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:net.sourceforge.fenixedu.domain.DegreeCurricularPlan.java

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

From source file:org.drools.semantics.builder.model.inference.DelegateInferenceStrategy.java

private void addSubConceptsToModel(OWLOntology ontoDescr, OntoModel model) {

    Map<String, Collection<String>> supers = new HashMap<String, Collection<String>>();

    String thing = ontoDescr.getOWLOntologyManager().getOWLDataFactory().getOWLThing().getIRI()
            .toQuotedString();// w ww  .  j  a  va2 s.  co m
    supers.put(thing, Collections.EMPTY_SET);

    for (OWLSubClassOfAxiom ax : ontoDescr.getAxioms(AxiomType.SUBCLASS_OF)) {
        processSubConceptAxiom(ax.getSubClass(), ax.getSuperClass(), supers, thing);
    }
    for (OWLEquivalentClassesAxiom ax : ontoDescr.getAxioms(AxiomType.EQUIVALENT_CLASSES)) {
        processSubConceptAxiom(ax.getClassExpressionsAsList().get(0),
                filterAliases(ax.getClassExpressionsAsList().get(1)), supers, thing);
    }

    for (OWLClassExpression delegator : aliases.keySet()) {
        if (!delegator.isAnonymous()) {
            addSuper(delegator.asOWLClass().getIRI().toQuotedString(), thing, supers);
        }
    }

    for (OWLClassExpression delegator : aliases.keySet()) {
        if (!delegator.isAnonymous()) {
            OWLClassExpression delegate = aliases.get(delegator);
            String sub = delegate.asOWLClass().getIRI().toQuotedString();
            String sup = delegator.asOWLClass().getIRI().toQuotedString();
            conceptCache.get(sub).getEquivalentConcepts().add(conceptCache.get(sup));
            addSuper(sub, sup, supers);
        }
    }

    HierarchySorter<String> sorter = new HierarchySorter<String>();
    List<String> sortedCons = sorter.sort(supers);

    ArrayList missing = new ArrayList(conceptCache.keySet());
    missing.removeAll(supers.keySet());

    LinkedHashMap<String, Concept> sortedCache = new LinkedHashMap<String, Concept>();
    for (String con : sortedCons) {
        sortedCache.put(con, conceptCache.get(con));
    }
    conceptCache.clear();
    conceptCache = sortedCache;

    reduceTransitiveInheritance(sortedCache, supers);

    for (String con : supers.keySet()) {
        Collection<String> parents = supers.get(con);
        for (String sup : parents) {
            SubConceptOf subConceptOf = new SubConceptOf(con, sup);
            model.addSubConceptOf(subConceptOf);
            conceptCache.get(subConceptOf.getSubject())
                    .addSuperConcept(conceptCache.get(subConceptOf.getObject()));
        }
    }
}

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

final public Set<IDegreeModuleToEvaluate> getDegreeModulesToEvaluate(
        final ExecutionSemester executionSemester) {
    return isBolonhaDegree() ? getRoot().getDegreeModulesToEvaluate(executionSemester) : Collections.EMPTY_SET;
}

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

final public RuleResult enrol(final ExecutionSemester executionSemester,
        final CurricularRuleLevel curricularRuleLevel) {
    return enrol(executionSemester, Collections.EMPTY_SET, Collections.EMPTY_LIST, curricularRuleLevel);
}

From source file:org.matonto.ontology.rest.impl.OntologyRestImplTest.java

@Test
public void testGetDataPropertiesInOntologyWhenNoDataProperties() {
    when(ontology.getAllDataProperties()).thenReturn(Collections.EMPTY_SET);

    Response response = target().path("ontologies/" + encode(ontologyIRI.stringValue()) + "/data-properties")
            .queryParam("branchId", branchId.stringValue()).queryParam("commitId", commitId.stringValue())
            .request().get();/*from  w  w  w  . j a  v a  2 s . co m*/

    assertEquals(response.getStatus(), 200);
    verify(ontologyManager).retrieveOntology(any(Resource.class), any(Resource.class), any(Resource.class));
    assertGetOntology(true);
    assertDataProperties(getResponse(response), Collections.EMPTY_SET);
}

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

@Atomic
public RuleResult removeCurriculumModulesFromNoCourseGroupCurriculumGroup(
        final List<CurriculumModule> curriculumModules, final ExecutionSemester executionSemester,
        final NoCourseGroupCurriculumGroupType groupType) {
    final EnrolmentContext context = new EnrolmentContext(this, executionSemester, Collections.EMPTY_SET,
            curriculumModules, groupType.getCurricularRuleLevel());
    return net.sourceforge.fenixedu.domain.studentCurriculum.StudentCurricularPlanEnrolment
            .createManager(context).manage();
}

From source file:org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttemptImpl.java

@Override
public Set<String> getBlacklistedNodes() {
    if (scheduler instanceof AbstractYarnScheduler) {
        AbstractYarnScheduler ayScheduler = (AbstractYarnScheduler) scheduler;
        SchedulerApplicationAttempt attempt = ayScheduler.getApplicationAttempt(applicationAttemptId);
        if (attempt != null) {
            return attempt.getBlacklistedNodes();
        }/*from w  w w. j  a va 2  s.  c o m*/
    }
    return Collections.EMPTY_SET;
}

From source file:org.matonto.ontology.rest.impl.OntologyRestImplTest.java

@Test
public void testGetNamedIndividualsInOntologyWhenNoNamedIndividuals() {
    when(ontology.getAllIndividuals()).thenReturn(Collections.EMPTY_SET);

    Response response = target().path("ontologies/" + encode(ontologyIRI.stringValue()) + "/named-individuals")
            .queryParam("branchId", branchId.stringValue()).queryParam("commitId", commitId.stringValue())
            .request().get();//from  www  .  j a  va  2  s .c o  m

    assertEquals(response.getStatus(), 200);
    verify(ontologyManager).retrieveOntology(any(Resource.class), any(Resource.class), any(Resource.class));
    assertGetOntology(true);
    assertIndividuals(getResponse(response), Collections.EMPTY_SET);
}

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

@Deprecated
public Set<Registration> getStudentsSet() {
    return getStudent() != null ? getStudent().getRegistrationsSet() : Collections.EMPTY_SET;
}

From source file:org.cloudfoundry.identity.uaa.oauth.UaaTokenServicesTests.java

@Test
public void testLoad_Opaque_AuthenticationForAUser() {
    defaultClient.setAutoApproveScopes(singleton("true"));
    AuthorizationRequest authorizationRequest = new AuthorizationRequest(CLIENT_ID, requestedAuthScopes);
    authorizationRequest.setResponseTypes(new HashSet(Arrays.asList(CompositeAccessToken.ID_TOKEN, "token")));
    authorizationRequest.setResourceIds(new HashSet<>(resourceIds));
    Map<String, String> azParameters = new HashMap<>(authorizationRequest.getRequestParameters());
    azParameters.put(GRANT_TYPE, AUTHORIZATION_CODE);
    azParameters.put(REQUEST_TOKEN_FORMAT, TokenConstants.OPAQUE);
    authorizationRequest.setRequestParameters(azParameters);
    Authentication userAuthentication = defaultUserAuthentication;

    OAuth2Authentication authentication = new OAuth2Authentication(authorizationRequest.createOAuth2Request(),
            userAuthentication);/*ww  w.  ja v a  2s  . c o m*/
    OAuth2AccessToken accessToken = tokenServices.createAccessToken(authentication);
    assertNotNull(accessToken);
    assertTrue("Token should be composite token", accessToken instanceof CompositeAccessToken);
    CompositeAccessToken composite = (CompositeAccessToken) accessToken;
    assertThat("id_token should be JWT, thus longer than 36 characters", composite.getIdTokenValue().length(),
            greaterThan(36));
    assertThat("Opaque access token must be shorter than 37 characters", accessToken.getValue().length(),
            lessThanOrEqualTo(36));
    assertThat("Opaque refresh token must be shorter than 37 characters",
            accessToken.getRefreshToken().getValue().length(), lessThanOrEqualTo(36));

    String accessTokenValue = tokenProvisioning.retrieve(composite.getValue()).getValue();
    Map<String, Object> accessTokenClaims = tokenServices.validateToken(accessTokenValue).getClaims();
    assertEquals(true, accessTokenClaims.get(ClaimConstants.REVOCABLE));

    String refreshTokenValue = tokenProvisioning.retrieve(composite.getRefreshToken().getValue()).getValue();
    Map<String, Object> refreshTokenClaims = tokenServices.validateToken(refreshTokenValue).getClaims();
    assertEquals(true, refreshTokenClaims.get(ClaimConstants.REVOCABLE));

    OAuth2Authentication loadedAuthentication = tokenServices.loadAuthentication(accessToken.getValue());

    assertEquals(USER_AUTHORITIES, loadedAuthentication.getAuthorities());
    assertEquals(username, loadedAuthentication.getName());
    UaaPrincipal uaaPrincipal = (UaaPrincipal) defaultUserAuthentication.getPrincipal();
    assertEquals(uaaPrincipal, loadedAuthentication.getPrincipal());
    assertNull(loadedAuthentication.getDetails());

    Authentication userAuth = loadedAuthentication.getUserAuthentication();
    assertEquals(username, userAuth.getName());
    assertEquals(uaaPrincipal, userAuth.getPrincipal());
    assertTrue(userAuth.isAuthenticated());

    Map<String, String> params = new HashedMap();
    params.put("grant_type", "refresh_token");
    params.put("client_id", CLIENT_ID);
    OAuth2AccessToken newAccessToken = tokenServices.refreshAccessToken(composite.getRefreshToken().getValue(),
            new TokenRequest(params, CLIENT_ID, Collections.EMPTY_SET, "refresh_token"));
    System.out.println("newAccessToken = " + newAccessToken);
}