Set size - 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 size method.

This code example shows how to use the following methods:size, toArray
        Set<String> groups = userGroups.get(player.toLowerCase());
        if (groups == null) {
            return new String[0];
        } 
 
        return groups.toArray(new String[groups.size()]);
    } 
 
    public boolean hasPermission(OfflinePlayer player, String permission) {
        return hasPermission(player.getName(), permission);
    } 
 
    public boolean hasPermission(String worldName, OfflinePlayer player, String permission) {
        return hasPermission(worldName, player.getName(), permission);
    } 
 
    public boolean inGroup(OfflinePlayer player, String group) {
        return inGroup(player.getName(), group);
    } 
 
7
CodeRank
This code example shows how to use the following methods:add, size
        //given 
        Date today    = mock(Date.class);
        Date tomorrow = mock(Date.class);
 
        //when 
        Set<Date> set = new TreeSet<Date>();
        set.add(today);
        set.add(tomorrow);
 
        //then 
        assertEquals(2, set.size());
    } 
 
    @Test 
    public void shouldAllowStubbingAndVerifyingCompareTo() { 
        //given 
        Date mock    = mock(Date.class);
        when(mock.compareTo(any(Date.class))).thenReturn(10);
 
        //when 
7
CodeRank
This code example shows how to use the following methods:size
 */ 
public class TOwner { 
    private Set<TInjectee> injectees = new HashSet<TInjectee>();
 
    public void addInjectee(TInjectee i) {
        System.out.println("add #i-b = " + injectees.size());
        injectees.add(i);
        System.out.println("add #i-a = " + injectees.size());
    } 
 
    public void removeInjectee(TInjectee i) {
        System.out.println("remove #i-b = " + injectees.size());
        injectees.remove(i);
        System.out.println("remove #i-a = " + injectees.size());
    } 
} 
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:size
 
        stopwatch.reset("Read excludes");
 
        List<File> jarFiles = new ArrayList<File>(500);
        SortedSet<File> excludedDirs = new TreeSet<File>();
        SortedSet<File> sourceRoots = new TreeSet<File>();
 
        traverse(new File("."), sourceRoots, jarFiles, excludedDirs, excludes);
 
        stopwatch.reset("Traversed tree");
 
        Log.debug(sourceRoots.size() + " source roots");
        Log.debug(jarFiles.size() + " jar files");
        Log.debug(excludedDirs.size() + " excluded dirs");
 
        this.sourceRoots = Collections.unmodifiableSortedSet(sourceRoots);
        this.jarFiles = Collections.unmodifiableList(jarFiles);
        this.excludedDirs = Collections.unmodifiableSortedSet(excludedDirs);
    } 
 
7
CodeRank
This code example shows how to use the following methods:size, toArray
		return IBeansModelElementTypes.IMPORT_TYPE; 
	} 
	 
	@Override 
	public IModelElement[] getElementChildren() { 
		Set<IModelElement> children = new LinkedHashSet<IModelElement>(
				getImportedBeansConfigs()); 
		return children.toArray(new IModelElement[children.size()]);
	} 
 
	@Override 
	public boolean equals(Object other) {
		if (this == other) {
			return true; 
		} 
		if (!(other instanceof BeansImport)) {
			return false; 
		} 
		BeansImport that = (BeansImport) other;
		if (!ObjectUtils.nullSafeEquals(this.resourcePath, that.resourcePath))
7
CodeRank
This code example shows how to use the following methods:size
 
    @Test 
    public void testScriptAssert() throws NamingException, SQLException { 
        Validator validator = (Validator) new InitialContext().lookup("java:comp/Validator");
        final Set<ConstraintViolation<ScriptAssertBean>> result = validator.validate(new ScriptAssertBean());
        Assert.assertEquals(1, result.size());
    } 
 
    /** 
     * Returns true if this testcase is expected to pass against the current Java runtime. Else returns false. 
     * 
     * @return 
     */ 
    private boolean isCompatibleJRE() { 
        final String javaRuntimeName = System.getProperty("java.runtime.name");
        // The OpenJDK runtime has a value of "OpenJDK Runtime Environment" for the java.runtime.name system property. Since this test isn't passing against OpenJDK, we classify it as incompatible and return false 
        // if OpenJDK runtime is identified. 
        // Note, if this test is failing against other JREs (like IBM), add another check with the appropriate value for IBM here. 
        return !javaRuntimeName.contains("OpenJDK");
    } 
7
CodeRank
This code example shows how to use the following methods:isEmpty, size
    @Override 
    protected void recognizeArguments(CommandContext ctx) throws CommandFormatException {
 
        final ParsedCommandLine args = ctx.getParsedCommandLine();
        final Set<String> propertyNames = args.getPropertyNames();
        if(!propertyNames.isEmpty()) {
            final Collection<String> names;
            if(helpArg.isPresent(args)) {
                if(propertyNames.size() == 1) {
                    return; 
                } 
                names = new ArrayList<String>(propertyNames);
                names.remove(helpArg.getFullName());
                names.remove(helpArg.getShortName());
            } else { 
                names = propertyNames;
            } 
            throw new CommandFormatException("Unrecognized argument names: " + names);
        } 
    } 
8
CodeRank
This code example shows how to use the following methods:size, toArray
	public URL[] getClasspath() {
		if (!StringUtils.hasLength(home)) {
			return new URL[0];
		} 
 
		Set<URL> urls = new LinkedHashSet<URL>();
 
		File rooHome = new File(home);
		if (rooHome.exists()) {
			addBootstrapJar(urls, rooHome, "bin");
			addBootstrapJar(urls, rooHome, "bundle");
		} 
		return urls.toArray(new URL[urls.size()]);
	} 
 
	public String getHome() {
		return home;
	} 
 
	public String getName() {
7
CodeRank
This code example shows how to use the following methods:size
        } 
        if (!name.apply(names.iterator().next())){
            throw MESSAGES.noMBeanCalled(name);
        } 
        Set<MBeanAttributeInfo> attrs = getAttributeInfos();
        MBeanAttributeInfo[] attributes = attrs.toArray(new MBeanAttributeInfo[attrs.size()]);
 
        return new MBeanInfo(this.getClass().getName(),
                "Management Object", 
                attributes,
                new MBeanConstructorInfo[0], 
                new MBeanOperationInfo[0], 
                new MBeanNotificationInfo[0]); 
    } 
 
 
    Set<MBeanAttributeInfo> getAttributeInfos() {
        Set<MBeanAttributeInfo> attributes = new HashSet<MBeanAttributeInfo>();
        attributes.add(createRoMBeanAttributeInfo(ATTR_NAME, String.class.getName(), MESSAGES.attrInfoAttrName()));
        attributes.add(createRoMBeanAttributeInfo(ATTR_STATE_MANAGEABLE, Boolean.TYPE.getName(), MESSAGES.attrInfoStateManageable()));
7
CodeRank

Related Set size Questions & Answers:

size Method Overview
Returns the number of elements in this set (its cardinality).
See Code Examples for other Java 8 Set Methods: