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:com.sonicle.webtop.core.sdk.AbstractShareCache.java

public final synchronized String getShareRootIdByFolderId(T folderId) {
    if (!ready)// w  w  w. j ava2 s .  c  o m
        internalInitCache();
    for (R root : shareRoots) {
        Collection<T> folderIds = rootShareToFolderShare.get(root.getShareId());
        if (folderIds.contains(folderId))
            return root.getShareId();
    }
    return null;
}

From source file:MultiMap.java

public boolean containsValue(Object value) {
    Iterator iter = map.entrySet().iterator();
    boolean found = false;
    while (iter.hasNext()) {
        Map.Entry entry = (Map.Entry) iter.next();
        Collection values = (Collection) entry.getValue();
        if (values.contains(value)) {
            found = true;//from  w w w.j  a v  a2  s .  co  m
            break;
        }
    }
    return found;
}

From source file:com.facebook.model.JsonUtilTests.java

@SmallTest
@MediumTest//w  ww.j  a  v  a  2 s. c o m
@LargeTest
public void testJsonObjectValues() throws JSONException {
    JSONObject jsonObject = new JSONObject();
    jsonObject.put("hello", "world");
    jsonObject.put("hocus", "pocus");

    Collection<Object> values = JsonUtil.jsonObjectValues(jsonObject);

    assertEquals(2, values.size());
    assertTrue(values.contains("world"));
}

From source file:de.codecentric.boot.admin.registry.ApplicationRegistryTest.java

@Test
public void getApplications() throws Exception {
    Application app = registry/*from  ww  w  .  j  a  v a 2  s  . c o  m*/
            .register(Application.create("abc").withHealthUrl("http://localhost/health").build());

    Collection<Application> applications = registry.getApplications();
    assertEquals(1, applications.size());
    assertTrue(applications.contains(app));
}

From source file:com.basho.riak.client.http.response.TestBucketResponse.java

@Test
public void parses_keys_field() throws Exception {
    HttpResponse mockHttpResponse = mock(HttpResponse.class);
    when(mockHttpResponse.getBody()).thenReturn(BODY);
    when(mockHttpResponse.getBodyAsString()).thenReturn(TEXT_BODY);
    when(mockHttpResponse.isSuccess()).thenReturn(true);

    BucketResponse impl = new BucketResponse(mockHttpResponse);
    Collection<String> keys = impl.getBucketInfo().getKeys();

    assertEquals(3, keys.size());//from  w  w w  . j ava 2s .  co  m
    assertTrue(keys.contains("j"));
    assertTrue(keys.contains("k"));
    assertTrue(keys.contains("l"));
}

From source file:com.mtgi.analytics.aop.config.v11.JdbcPersisterConfigurationTest.java

@Test
public void testConfiguration() throws Exception {
    assertNotNull("default tracking manager configured", defaultTrackingManager);
    assertEquals("application name set", "testApp", defaultTrackingManager.getApplication());
    assertEquals("default persister type provided", JdbcBehaviorEventPersisterImpl.class,
            defaultTrackingManager.getPersister().getClass());

    //verify that the custom jdbc persister configuration has been applied.
    JdbcBehaviorEventPersisterImpl persister = (JdbcBehaviorEventPersisterImpl) defaultTrackingManager
            .getPersister();//from   w w w .  ja va 2s. c om
    assertSame("correct datasource injected into persister", unitilsDS, persister.getDataSource());
    assertEquals("custom id sql injected into persister",
            "select next value for SEQ_BEHAVIOR_TRACKING_EVENT from INFORMATION_SCHEMA.SYSTEM_SEQUENCES",
            persister.getIdSql());

    //verify proper configuration of log flush and rotation using private task executor and scheduler instances
    TaskExecutor executor = defaultTrackingManager.getExecutor();
    assertEquals("default executor type provided", ThreadPoolTaskExecutor.class, executor.getClass());

    //test the state of the global scheduler configuration.
    SchedulerFactory factory = new StdSchedulerFactory();
    Scheduler sched = factory.getScheduler("BeetScheduler");

    List<String> triggers = Arrays.asList(sched.getTriggerNames("beet"));
    assertEquals("flush job scheduled", 1, triggers.size());
    assertTrue("flush job scheduled", triggers.contains("defaultTrackingManager_flush_trigger"));

    Collection<?> schedulers = factory.getAllSchedulers();
    assertEquals("private scheduler created", 1, schedulers.size());
    assertTrue(schedulers.contains(sched));

    //verify the default session context implementation has been selected.
    SessionContext context = defaultTrackingManager.getSessionContext();
    assertNotNull(context);
    assertTrue("JAAS context used by default", context instanceof JAASSessionContext);
}

From source file:com.chadekin.jadys.syntax.from.impl.FromClauseBuilderImpl.java

private Set<String> findRelatedAlias(Collection<String> aliasToSearch) {
    return joinStatements.entrySet().stream().filter(entry -> aliasToSearch.contains(entry.getKey()))
            .map(entry -> extractAlias(entry.getValue())).flatMap(entry -> entry.stream())
            .filter(alias -> joinStatements.keySet().contains(alias) && !aliasToSearch.contains(alias))
            .collect(Collectors.toSet());
}

From source file:org.biopax.validator.rules.NextStepShareParticipantsRule.java

Collection<Entity> getParticipants(Process process, Collection<Process> visited) {
    Collection<Entity> ret = new HashSet<Entity>();

    // escape infinite loop
    if (visited.contains(process)) {
        //"Step Processes Form a Loop!"
        return ret; // empty
    }//w  w w .j a va  2 s .c o  m
    visited.add(process);

    if (process instanceof Interaction) {
        for (Entity pat : ((Interaction) process).getParticipant()) {
            if (pat instanceof PhysicalEntity || pat instanceof Gene)
                ret.add(pat);
        }
    } else { // a pathway
        for (Process p : ((Pathway) process).getPathwayComponent()) {
            ret.addAll(getParticipants(p, visited));
        }
    }

    return ret;
}

From source file:com.somerledsolutions.pa11y.client.cli.OptionsBuilderTest.java

@Test
public void testBuildPa11yOptions() throws Exception {
    Options options = OptionsBuilder.buildPa11yOptions();

    assertEquals(10, options.getOptions().size());

    assertPa11yOptions(options);//w  w  w  .  j  av a 2  s.  com

    OptionGroup optionGroup = options.getOptionGroup(options.getOption("c"));
    Collection<String> optionGroupNames = optionGroup.getNames();
    assertTrue(optionGroupNames.contains("c"));
    assertTrue(optionGroupNames.contains("l"));
    assertTrue(optionGroupNames.contains("r"));
    assertTrue(optionGroupNames.contains("g"));
    assertTrue(optionGroupNames.contains("d"));
}

From source file:de.codecentric.boot.admin.registry.ApplicationRegistryTest.java

@Test
public void getApplicationsByName() throws Exception {
    Application app = registry//from   w ww. jav a 2s .  c  o  m
            .register(Application.create("abc").withHealthUrl("http://localhost/health").build());
    Application app2 = registry
            .register(Application.create("abc").withHealthUrl("http://localhost:8081/health").build());
    Application app3 = registry
            .register(Application.create("zzz").withHealthUrl("http://localhost:8082/health").build());

    Collection<Application> applications = registry.getApplicationsByName("abc");
    assertEquals(2, applications.size());
    assertTrue(applications.contains(app));
    assertTrue(applications.contains(app2));
    assertFalse(applications.contains(app3));
}