Example usage for java.util Set size

List of usage examples for java.util Set size

Introduction

In this page you can find the example usage for java.util Set size.

Prototype

int size();

Source Link

Document

Returns the number of elements in this set (its cardinality).

Usage

From source file:hudson.plugins.trackplus.Updater.java

/**
 * @param pattern pattern to use to match issue ids
 *//*from   w w  w .ja  v  a2  s .c  om*/
static void findIssues(AbstractBuild<?, ?> build, Set<Integer> ids, String issuePrefix,
        BuildListener listener) {
    for (Entry change : build.getChangeSet()) {
        LOGGER.fine("Looking for Track+ ID in " + change.getMsg());
        Set<Integer> tmpIds = TrackplusSite.getWorkItemIDs(change.getMsg(), issuePrefix);
        if (tmpIds != null && tmpIds.size() > 0) {
            for (Iterator iterator = tmpIds.iterator(); iterator.hasNext();) {
                Integer id = (Integer) iterator.next();
                ids.add(id);
            }
        } else {
            listener.getLogger().println("No issues found!");
        }
    }
}

From source file:com.github.qwazer.markdown.confluence.gradle.plugin.ConfluenceGradleTask.java

protected static void validateNoDuplicates(Collection<ConfluenceConfig.Page> pages) {

    Set<ConfluenceConfig.Page> set = new TreeSet<>(new Comparator<ConfluenceConfig.Page>() {
        @Override//from w w w .  j  av a  2s . c  o  m
        public int compare(ConfluenceConfig.Page o1, ConfluenceConfig.Page o2) {
            return o1.getTitle().compareTo(o2.getTitle());
        }
    });

    set.addAll(pages);

    if (set.size() < pages.size()) {
        throw new IllegalArgumentException("Found duplicate pageTitle in confluence pages");
    }
}

From source file:com.alta189.bukkit.script.event.EventScanner.java

public static void scanBukkit() {
    Reflections reflections = new Reflections(new ConfigurationBuilder()
            .filterInputsBy(new FilterBuilder().include(FilterBuilder.prefix("org.bukkit")))
            .setUrls(ClasspathHelper.forClassLoader(ClasspathHelper.contextClassLoader(),
                    ClasspathHelper.staticClassLoader())));

    Set<Class<? extends Event>> classes = reflections.getSubTypesOf(Event.class);

    BScript plugin = BScript.getInstance();
    plugin.info(//from w ww .  ja v a 2 s .  c  om
            "Found " + classes.size() + " classes extending " + Event.class.getCanonicalName() + " in Bukkit");
    for (Class<? extends Event> clazz : classes) {
        if (clazz.isInterface() || Modifier.isAbstract(clazz.getModifiers())) {
            continue;
        }
        bukkitEvent.put(clazz.getSimpleName(), clazz);

        String className = clazz.getCanonicalName();
        if (className == null) {
            className = clazz.getName();
        }
        events.put(className, clazz);
        simpleNameEvents.put(clazz.getSimpleName(), clazz);
        plugin.debug(className);
    }
}

From source file:com.meltmedia.cadmium.deployer.JBossUtil.java

public static boolean isWarDeployed(String warName, Logger log) throws Exception {
    MBeanServer server = MBeanServerLocator.locateJBoss();
    Set<ObjectInstance> foundInstances = server
            .queryMBeans(new ObjectName("jboss.deployment:type=Deployment,id=\"*" + warName + "*\""), null);
    boolean found = false;
    if (foundInstances != null && foundInstances.size() > 0) {
        log.debug("MBean query returned: {} results.", foundInstances.size());
        for (ObjectInstance instance : foundInstances) {
            String simpleName = "" + server.getAttribute(instance.getObjectName(), "SimpleName");
            log.debug("Checking {} is {}", simpleName, warName);
            if (simpleName.equals(warName)) {
                found = true;//from   w ww .ja v  a 2  s.c  o  m
                String state = server.getAttribute(instance.getObjectName(), "State") + "";
                log.debug("Deployment state {}", state);
                if (state.equals("ERROR")) {
                    Object error = server.getAttribute(instance.getObjectName(), "Problem");
                    log.debug("Found problem: {}", error);
                    if (error instanceof Throwable) {
                        throw new Exception((Throwable) error);
                    } else {
                        throw new Exception(error.toString());
                    }
                } else if (state.equals("DEPLOYED")) {
                    return true;
                } else if (state.equals("UNDEPLOYED")) {
                    found = false;
                }
            }
        }
    }
    if (!found) {
        throw new NoDeploymentFoundException();
    }
    return false;
}

From source file:csv.parser.CSVParser.java

private static String[] getEduLvl(String[] val) {
    for (int i = 0; i < val.length; i++) {
        if (val[i].equals("Under Graduate") || val[i].equals("Post Graduate")) {
            val[i] = "ug_pg";
        } else if (val[i].equals("I") || val[i].equals("II") || val[i].equals("III") || val[i].equals("IV")) {
            val[i] = "lowerPrimary";
        } else if (val[i].equals("V") || val[i].equals("VI") || val[i].equals("VII") || val[i].equals("VIII")) {
            val[i] = "upperPrimary";
        } else if (val[i].equals("IX") || val[i].equals("X")) {
            val[i] = "middleSchool";
        } else if (val[i].equals("XI") || val[i].equals("XII")) {
            val[i] = "highSchool";
        }/*from w ww  . j a  v  a  2  s  .  c  om*/
    }
    int end = val.length;
    Set<String> set = new HashSet<String>();
    for (int i = 0; i < end; i++) {
        set.add(val[i]);
    }
    val = set.toArray(new String[set.size()]);
    return val;
}

From source file:com.cassius.spring.assembly.test.common.toolbox.ContextUtil.java

/**
 * Get context configuration./*from   w ww .j  a v  a  2  s.  c  o m*/
 *
 * @param testInstance the test instance
 * @return the string [ ]
 */
public static String[] getContextConfiguration(Object testInstance) {
    Class<?> testClass = testInstance.getClass();
    SpringAssemblyConfigure springAssemblyConfigure = AnnotationUtils.findAnnotation(testClass,
            SpringAssemblyConfigure.class);
    Set<String> files = com.cassius.spring.assembly.test.common.toolbox.ContextUtil
            .getSpringContextLocations(testClass);
    if (springAssemblyConfigure.createSpy()) {
        files.add(SPY_PROCESSOR_CONFIG);
    }
    String[] configurationLocations = new String[files.size()];
    configurationLocations = files.toArray(configurationLocations);
    return configurationLocations;
}

From source file:org.ohmage.cache.UserBin.java

/**
 * Checks every bin location and removes Users whose tokens have expired.
 */// w  w w. j a v  a  2  s .  c om
private static synchronized void expire() {
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Beginning user expiration process");
    }

    Set<String> keySet = USERS.keySet();

    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Number of users before expiration: " + keySet.size());
    }

    long currentTime = System.currentTimeMillis();

    for (String key : keySet) {
        UserTime ut = USERS.get(key);
        if (currentTime - ut.time > LIFETIME) {

            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug("Removing user with Id " + key);
            }

            USERS.remove(key);
        }
    }

    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Number of users after expiration: " + USERS.size());
    }
}

From source file:com.bfd.harpc.common.configure.ResourceUtils.java

private static URL[] load1(String locationPattern) throws IOException, URISyntaxException {
    String location = locationPattern.substring(ResourceConstants.CLASSPATH_ALL_URL_PREFIX.getValue().length());
    if (location.startsWith(ResourceConstants.FOLDER_SEPARATOR.getValue())) {
        location = location.substring(1);
    }/*from   w ww.j a va  2  s  . com*/

    Enumeration<URL> resourceUrls = getDefaultClassLoader().getResources(location);
    Set<URL> result = new LinkedHashSet<URL>(16);
    while (resourceUrls.hasMoreElements()) {
        URL url = resourceUrls.nextElement();
        result.add(PathUtils.cleanPath(url));
    }
    return result.toArray(new URL[result.size()]);
}

From source file:com.vmware.identity.openidconnect.common.ResponseType.java

public static ResponseType parse(String responseTypeString) throws ParseException {
    Validate.notEmpty(responseTypeString, "responseTypeString");

    Set<ResponseTypeValue> valueSet = new HashSet<ResponseTypeValue>();
    String[] parts = responseTypeString.split(" ");
    for (String part : parts) {
        ResponseTypeValue value = ResponseTypeValue.parse(part);
        valueSet.add(value);//  w w w.  j a  v  a2s  .  co  m
    }

    ResponseType result;
    if (valueSet.size() == 1 && valueSet.contains(ResponseTypeValue.AUTHORIZATION_CODE)) {
        result = ResponseType.authorizationCode();
    } else if (valueSet.size() == 1 && valueSet.contains(ResponseTypeValue.ID_TOKEN)) {
        result = ResponseType.idToken();
    } else if (valueSet.size() == 2 && valueSet.contains(ResponseTypeValue.ID_TOKEN)
            && valueSet.contains(ResponseTypeValue.ACCESS_TOKEN)) {
        result = ResponseType.idTokenAccessToken();
    } else {
        throw new ParseException(ErrorObject.unsupportedResponseType("unsupported response_type"));
    }
    return result;
}

From source file:dk.dma.ais.track.rest.resource.TrackResource.java

/** Create a Predicate<TargetInfo> out of user supplied mmsi and area information */
static Predicate<TargetInfo> createTargetFilterPredicate(Set<Integer> mmsis, Set<Area> baseAreas,
        Set<Area> areas) {
    Predicate<TargetInfo> mmsiPredicate = null;
    if (mmsis != null && mmsis.size() > 0) {
        mmsiPredicate = targetInfo -> mmsis.contains(targetInfo.getMmsi());
    }// ww w . j a  v a  2  s .c o  m

    Predicate<TargetInfo> baseAreaPredicate = null;
    if (baseAreas != null && baseAreas.size() > 0) {
        baseAreaPredicate = targetInfo -> baseAreas.stream()
                .anyMatch(area -> targetInfo.getPosition() != null && area.contains(targetInfo.getPosition()));
    }

    Predicate<TargetInfo> areaPredicate = null;
    if (areas != null && areas.size() > 0) {
        areaPredicate = targetInfo -> areas.stream()
                .anyMatch(area -> targetInfo.getPosition() != null && area.contains(targetInfo.getPosition()));
    }

    Predicate<TargetInfo> resultingAreaPredicate = null;
    if (baseAreaPredicate != null && areaPredicate == null) {
        resultingAreaPredicate = baseAreaPredicate;
    } else if (baseAreaPredicate != null && areaPredicate != null) {
        resultingAreaPredicate = baseAreaPredicate.and(areaPredicate);
    } else {
        resultingAreaPredicate = areaPredicate;
    }

    if (mmsiPredicate == null && resultingAreaPredicate == null)
        return t -> true;
    else if (mmsiPredicate != null && resultingAreaPredicate == null)
        return mmsiPredicate;
    else if (mmsiPredicate == null && resultingAreaPredicate != null)
        return resultingAreaPredicate;
    else
        return mmsiPredicate.or(resultingAreaPredicate);
}