Example usage for java.util Collection contains

List of usage examples for java.util Collection contains

Introduction

In this page you can find the example usage for java.util Collection contains.

Prototype

boolean contains(Object o);

Source Link

Document

Returns true if this collection contains the specified element.

Usage

From source file:org.jasig.schedassist.web.security.DelegateAuthenticationSuccessHandler.java

/**
 * Redirects to the correct url based on the {@link GrantedAuthority}s contained by the {@link Authentication} argument.
 * //from w  w  w  .  j  av a2  s .  c om
 * @see org.springframework.security.web.authentication.AuthenticationSuccessHandler#onAuthenticationSuccess(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.springframework.security.core.Authentication)
 */
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response,
        Authentication authentication) throws IOException, ServletException {

    Collection<GrantedAuthority> authorities = authentication.getAuthorities();
    if (authorities.contains(SecurityConstants.DELEGATE_OWNER)) {
        // redirect to delegateOwnerTarget
        this.redirectStrategy.sendRedirect(request, response, this.delegateOwnerTarget);
    } else if (authorities.contains(SecurityConstants.DELEGATE_REGISTER)) {
        // redirect to delegateRegisterTarget
        this.redirectStrategy.sendRedirect(request, response, this.delegateRegisterTarget);
    } else {
        // this must be a logout success
        // redirect to logoutTarget
        this.redirectStrategy.sendRedirect(request, response, this.logoutTarget);
    }
}

From source file:org.apache.camel.component.hazelcast.TestHazelcastMultimapProducerForSpring.java

@Test
public void testGet() {
    map.put("4711", "my-foo");

    template.sendBodyAndHeader("direct:get", null, HazelcastConstants.OBJECT_ID, "4711");
    Collection<Object> body = consumer.receiveBody("seda:out", 5000, Collection.class);

    assertTrue(body.contains("my-foo"));
}

From source file:com.payu.ratel.client.RemoteAutowireCandidateResolver.java

@Override
protected Object buildLazyResolutionProxy(DependencyDescriptor descriptor, String beanName) {

    Collection<String> annotationsType = getAnnotationsTypes(descriptor);
    if (annotationsType.contains(Discover.class.getName())) {
        if (descriptor.getDependencyType().equals(EventCannon.class)) {
            return produceEventCannonProxy();
        } else {/*from  w w  w  . j a va  2 s  .c  o m*/
            RetryPolicyConfig retryPolicy = null;
            Optional<Annotation> retryPolicyAnn = getAnnotationWithType(descriptor, RetryPolicy.class);
            if (retryPolicyAnn.isPresent()) {
                retryPolicy = RetryPolicyConfig.fromRetryPolicy((RetryPolicy) retryPolicyAnn.get());
            }
            TimeoutConfig timeout = null;
            Optional<Annotation> timeoutAnn = getAnnotationWithType(descriptor, Timeout.class);
            if (timeoutAnn.isPresent()) {
                timeout = TimeoutConfig.fromTimeout((Timeout) timeoutAnn.get());
            }

            boolean useCache = annotationsType.contains(Cachable.class.getName());

            return ratelClientProducer.produceServiceProxy(descriptor.getDependencyType(), useCache,
                    retryPolicy, timeout);
        }
    }

    return super.buildLazyResolutionProxy(descriptor, beanName);
}

From source file:org.jasig.cas.services.web.ManageRegisteredServicesMultiActionControllerTests.java

public void testManage() {
    final RegisteredServiceImpl r = new RegisteredServiceImpl();
    r.setId(1200);//from ww  w  .  j a va2s.  c  om
    r.setName("name");
    r.setServiceId("test");
    r.setEvaluationOrder(2);

    this.servicesManager.save(r);

    final ModelAndView modelAndView = this.controller.manage(new MockHttpServletRequest(),
            new MockHttpServletResponse());

    assertNotNull(modelAndView);
    assertEquals("manageServiceView", modelAndView.getViewName());

    final Collection c = (Collection) modelAndView.getModel().get("services");
    assertTrue(c.contains(r));
}

From source file:org.jutge.joc.porra.entitystash.service.EntityStashEntityService.java

public Account getAccount() {
    final Authentication auth = SecurityContextHolder.getContext().getAuthentication();
    if (auth != null) {
        final Collection<? extends GrantedAuthority> authorities = auth.getAuthorities();
        if (authorities != null && authorities.contains(USER_AUTHORITY)) {
            final String name = auth.getName();
            return this.accountService.getByName(name);
        }// w w  w .  j ava  2s  . com
    }
    return null;
}

From source file:com.phoenixst.collections.AbstractSingletonCollection.java

public boolean removeAll(Collection collection) {
    return collection.contains(element) && removeElement();
}

From source file:com.phoenixst.collections.AbstractSingletonCollection.java

public boolean retainAll(Collection collection) {
    return !collection.contains(element) && removeElement();
}

From source file:com.nextep.datadesigner.vcs.impl.VersionableSorter.java

private boolean containsAny(Collection<?> lookup, Collection<?> contained) {
    for (Object o : contained) {
        if (lookup.contains(o)) {
            return true;
        }/*from  w ww . j  a  va 2 s.c o m*/
    }
    return false;
}

From source file:com.netflix.spinnaker.fiat.roles.file.FileBasedUserRolesProvider.java

@Override
public Map<String, Collection<Role>> multiLoadRoles(Collection<String> userIds) {
    try {//from   w  ww. j a v a 2  s. co m
        return parse().entrySet().stream().filter(e -> userIds.contains(e.getKey()))
                .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
    } catch (IOException io) {
        log.error("Couldn't mulitLoad roles from file", io);
    }
    return Collections.emptyMap();
}

From source file:com.macasaet.lambda.fluent.Examples.java

/**
 * This is a more concise and declarative way of defining a {@link Predicate}. It uses an example method invocation
 * to create the functor./*from  w w w.  j a v a 2  s .  c  o m*/
 */
@Test
public final void definePredicateWithFluentInterface() {
    final Predicate<? super AnyMatrix> matrixIsSquare = forMethod(ofClass(AnyMatrix.class).isSquare());

    final Collection<? extends AnyMatrix> result = filter(matrices, matrixIsSquare);
    assertTrue(result.contains(squareMatrix));
    assertFalse(result.contains(nonSquareMatrix));
}