Set contains - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Set contains method.

This code example shows how to use the following methods:contains
        testMethodAnnotations.add("Lorg/testng/annotations/AfterGroups;");
        testMethodAnnotations.add("Lorg/testng/annotations/Factory;");
    } 
 
    public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
        if (testMethodAnnotations.contains(desc)) {
            testClassDetecter.setTest(true);
        } 
        return null; 
    } 
} 
7
CodeRank
This code example shows how to use the following methods:add, contains
		return new HashSet<OIdentifiable>();
	} 
 
	public boolean push(final OIdentifiable iRecord) {
		final Set<OIdentifiable> set = get();
		if (set.contains(iRecord))
			return false; 
 
		set.add(iRecord);
		return true; 
	} 
 
	public boolean pop(final OIdentifiable iRecord) {
		return get().remove(iRecord);
	} 
} 
7
CodeRank
This code example shows how to use the following methods:contains, size
        assertEquals("subsystem", node.getType());
        assertEquals("logging", node.getName());
        assertFalse(i.hasNext());
 
        Set<String> args = handler.getPropertyNames();
        assertEquals(1, args.size());
        assertTrue(args.contains("recursive"));
        assertEquals("true", handler.getPropertyValue("recursive"));
    } 
 
    @Test 
    public void testComposite() throws Exception { 
 
        final String op = "composite";
        final String propName = "steps";
        final String propValue = "[{\"operation\"=>\"add-system-property\",\"name\"=>\"test\",\"value\"=\"newValue\"},{\"operation\"=>\"add-system-property\",\"name\"=>\"test2\",\"value\"=>\"test2\"}]";
 
        DefaultCallbackHandler handler = new DefaultCallbackHandler();
 
        parse(':' + op + '(' + propName + '=' + propValue + ')', handler);
7
CodeRank
This code example shows how to use the following methods:add, addAll, contains, containsAll
import java.util.Arrays; 
import java.util.Collections; 
import java.util.Set; 
import java.util.TreeSet; 
 
public class Sets { 
    public static void main(String[] args){
        Set<Integer> a = new TreeSet<>();
        //TreeSet sorts on natural ordering (or an optional comparator) 
        //other options: HashSet (hashcode) 
        //               LinkedHashSet (insertion order) 
        //               EnumSet (optimized for enum values) 
        //others at: http://download.oracle.com/javase/7/docs/api/java/util/Set.html 
        Set<Integer> b = new TreeSet<>();
        Set<Integer> c = new TreeSet<>();
        Set<Integer> d = new TreeSet<>();
 
        a.addAll(Arrays.asList(1, 2, 3, 4, 5));
        b.addAll(Arrays.asList(2, 3, 4, 5, 6, 8));
        c.addAll(Arrays.asList(2, 3, 4));

7
CodeRank
This code example shows how to use the following methods:contains
    } 
     
    public void processBean(@Observes ProcessBean<?> pb) {
       System.out.println("FunExtension processBean " + pb.getBean().getBeanClass());
        
       if (funnyClasses.contains(pb.getBean().getBeanClass())) {
          funnyBeans.add(pb.getBean());
       } 
    } 
} 
7
CodeRank
This code example shows how to use the following methods:contains, size
        assertFalse(handler.isRequestComplete());
 
        assertEquals("read-resource", handler.getOperationName());
 
        Set<String> argNames = handler.getPropertyNames();
        assertEquals(2, argNames.size());
        assertTrue(argNames.contains("recursive"));
        assertEquals("true", handler.getPropertyValue("recursive"));
        assertTrue(argNames.contains("other"));
    } 
 
    @Test 
    public void testNameValueSeparatorNameAndValueSeparator() throws Exception { 
        DefaultCallbackHandler handler = new DefaultCallbackHandler();
 
        parseOperation(":read-resource(recursive=true,other=", handler);
 
        assertFalse(handler.hasAddress());
        assertTrue(handler.hasOperationName());
        assertTrue(handler.hasProperties());
8
CodeRank
This code example shows how to use the following methods:contains
    public boolean add(Key<?> key) {
        return backingSet.add(key.toString());
    } 
 
    public boolean contains(Object o) { 
        return o instanceof Key && backingSet.contains(o.toString());
    } 
} 
7
CodeRank
This code example shows how to use the following methods:contains, size
 
		InputStream stream = getClass().getResourceAsStream("resources/example_permutation.perm.xml");
 
		Set<String> files = xmlPermutationProvider.getPermutationFiles(stream);
 
		Assert.assertEquals(7, files.size());
 
		Assert.assertTrue(files.contains("showcase/01366743E08C511EF8DB208174B33C6F.cache.html"));
		Assert.assertTrue(files.contains("index.html"));
		Assert.assertTrue(files.contains("logo.png"));
		Assert.assertTrue(files.contains("showcase/hosted.html"));
		Assert.assertTrue(files.contains("showcase/showcase.nocache.js"));
		Assert.assertTrue(files.contains("showcase/clear.cache.gif"));
		Assert.assertTrue(files.contains("/"));
 
	} 
 
	@Test 
	public void testReadWritePermInformation() throws XMLPermutationProviderException, UnsupportedEncodingException { 
		XMLPermutationProvider xmlPermutationProvider = new XMLPermutationProvider();
7
CodeRank
This code example shows how to use the following methods:add, contains
 
  public Object execute(final OIdentifiable iCurrentRecord, Object iCurrentResult, final Object[] iParameters,
      OCommandContext iContext) {
    final Object value = iParameters[0];
 
    if (value != null && !context.contains(value)) {
      context.add(value);
      return value;
    } 
 
    return null; 
  } 
 
  @Override 
  public boolean filterResult() { 
    return true; 
  } 
 
  public String getSyntax() {
    return "Syntax error: distinct(<field>)"; 
8
CodeRank
This code example shows how to use the following methods:contains, remove
        } 
    } 
 
    public synchronized void undeploy(@Observes BeforeStop event, Container container, ServiceArchiveHolder archiveHolder) {
        // clean up if we deployed to this container? 
        if (serviceArchiveDeployed.contains(container.getName())) {
            try { 
                Archive<?> serviceArchive = archiveHolder.getArchive();
                log.infof("Undeploy arquillian service: %s", serviceArchive);
                DeployableContainer<?> deployableContainer = container.getDeployableContainer();
                deployableContainer.undeploy(serviceArchive);
                serviceArchiveDeployed.remove(container.getName());
            } catch (Throwable th) {
                log.error("Cannot undeploy arquillian service", th);
            } 
        } 
    } 
} 
8
CodeRank

Related Set contains Questions & Answers:

contains Method Overview
Returns true if this set contains the specified element.
See Code Examples for other Java 8 Set Methods: