Example usage for java.util SortedMap isEmpty

List of usage examples for java.util SortedMap isEmpty

Introduction

In this page you can find the example usage for java.util SortedMap isEmpty.

Prototype

boolean isEmpty();

Source Link

Document

Returns true if this map contains no key-value mappings.

Usage

From source file:org.zaproxy.zap.spider.URLCanonicalizer.java

private static String getCleanedQuery(String escapedQuery) {
    // Get the parameters' names
    SortedMap<String, String> params = createParameterMap(escapedQuery);
    StringBuilder cleanedQueryBuilder = new StringBuilder();
    if (params != null && !params.isEmpty()) {
        for (String key : params.keySet()) {
            // Ignore irrelevant parameters
            if (IRRELEVANT_PARAMETERS.contains(key) || key.startsWith("utm_")) {
                continue;
            }/*from w  w  w .  j  a  v  a2s . c o m*/
            if (cleanedQueryBuilder.length() > 0) {
                cleanedQueryBuilder.append('&');
            }
            cleanedQueryBuilder.append(key);
        }
    }

    return cleanedQueryBuilder.toString();
}

From source file:ee.ria.xroad.opmonitordaemon.HealthDataMetricsUtil.java

/**
 * @param registry the metric registry where the gauge should be looked up
 * @param expectedGaugeName the gauge name to find
 * @return the found gauge or null if it does not exist
 *//* ww w. ja va  2s .com*/
static Gauge findGauge(MetricRegistry registry, String expectedGaugeName) {
    SortedMap<String, Gauge> gauges = registry.getGauges(
            (name, metric) -> name.matches(HealthDataMetricsUtil.formatMetricMatchRegexp(expectedGaugeName)));

    if (gauges.size() > 1) {
        // Should not happen because we use a strict regexp.
        log.warn("Multiple gauges matched the name " + expectedGaugeName);
    }

    return gauges.isEmpty() ? null : gauges.values().iterator().next();
}

From source file:ee.ria.xroad.opmonitordaemon.HealthDataMetricsUtil.java

/**
 * @param registry the metric registry where the counter should be looked up
 * @param expectedCounterName the counter name to find
 * @return the found counter or null if it does not exist
 *///from ww w  . j a  va 2 s .  c  o m
static Counter findCounter(MetricRegistry registry, String expectedCounterName) {
    SortedMap<String, Counter> counters = registry.getCounters(
            (name, metric) -> name.matches(HealthDataMetricsUtil.formatMetricMatchRegexp(expectedCounterName)));

    if (counters.size() > 1) {
        // Should not happen because we use a strict regexp.
        log.warn("Multiple counters matched the name " + expectedCounterName);
    }

    return counters.isEmpty() ? null : counters.values().iterator().next();
}

From source file:org.cloudifysource.restDoclet.generation.Generator.java

private static List<DocController> generateControllers(final ClassDoc classDoc) throws Exception {
    List<DocController> controllers = new LinkedList<DocController>();
    List<DocAnnotation> annotations = generateAnnotations(classDoc.annotations());

    if (Utils.filterOutControllerClass(classDoc, annotations)) {
        return null;
    }/*from   w w w  .  j a  va 2 s . c o m*/

    String controllerClassName = classDoc.typeName();
    DocRequestMappingAnnotation requestMappingAnnotation = Utils.getRequestMappingAnnotation(annotations);
    if (requestMappingAnnotation == null) {
        throw new IllegalArgumentException(
                "controller class " + controllerClassName + " is missing request mapping annotation");
    }
    String[] uriArray = requestMappingAnnotation.getValue();
    if (uriArray == null || uriArray.length == 0) {
        throw new IllegalArgumentException("controller class " + controllerClassName
                + " is missing request mapping annotation's value (uri).");
    }
    for (String uri : uriArray) {
        DocController controller = new DocController(controllerClassName);

        SortedMap<String, DocMethod> generatedMethods = generateMethods(classDoc.methods());
        if (generatedMethods.isEmpty()) {
            throw new IllegalArgumentException(
                    "controller class " + controller.getName() + " doesn't have methods.");
        }
        controller.setMethods(generatedMethods);
        controller.setUri(uri);
        controller.setDescription(classDoc.commentText());

        controllers.add(controller);
    }
    return controllers;
}

From source file:ee.ria.xroad.opmonitordaemon.HealthDataMetricsUtil.java

/**
 * @param registry the metric registry where the histogram should be
 * looked up/*from   w w  w. j  a v  a 2 s.c o m*/
 * @param expectedHistogramName the counter name to find
 * @return the found histogram or null if it does not exist
 */
static Histogram findHistogram(MetricRegistry registry, String expectedHistogramName) {
    SortedMap<String, Histogram> histograms = registry.getHistograms((name, metric) -> name
            .matches(HealthDataMetricsUtil.formatMetricMatchRegexp(expectedHistogramName)));

    if (histograms.size() > 1) {
        // Should not happen because we use a strict regexp.
        log.warn("Multiple histograms matched the name " + expectedHistogramName);
    }

    return histograms.isEmpty() ? null : histograms.values().iterator().next();
}

From source file:com.bytelightning.opensource.pokerface.ScriptHelperImpl.java

/**
 * Canonicalize the query string.//from  w  w w  .j  a  v a  2s  . c o  m
 * 
 * @param sortedParamMap Parameter name-value pairs in lexicographical order.
 * @return Canonical form of query string.
 */
private static String Canonicalize(final SortedMap<String, String> sortedParamMap) {
    if (sortedParamMap == null || sortedParamMap.isEmpty())
        return "";
    final StringBuffer sb = new StringBuffer(350);
    final Iterator<Map.Entry<String, String>> iter = sortedParamMap.entrySet().iterator();
    while (iter.hasNext()) {
        final Map.Entry<String, String> pair = iter.next();
        sb.append(PercentEncodeRfc3986(pair.getKey()));
        sb.append('=');
        sb.append(PercentEncodeRfc3986(pair.getValue()));
        if (iter.hasNext())
            sb.append('&');
    }
    return sb.toString();
}

From source file:eu.trentorise.opendata.josman.Josmans.java

public static SemVersion latestVersion(String repoName, List<RepositoryTag> tags) {
    TodUtils.checkNotEmpty(tags, "Invalid repository tags!");
    SortedMap<String, RepositoryTag> filteredTags = Josmans.versionTags(repoName, tags);
    if (filteredTags.isEmpty()) {
        throw new NotFoundException("Couldn't find any released version!");
    }//from ww w .  j ava2 s .  c  o  m
    return Josmans.version(repoName, filteredTags.lastKey());
}

From source file:FocusTraversalExample.java

public Component getFirstComponent(Container focusCycleRoot) {
    SortedMap buttons = getSortedButtons(focusCycleRoot);
    if (buttons.isEmpty()) {
        return null;
    }//from w w w .j ava  2s .co m
    return (Component) buttons.get(buttons.firstKey());
}

From source file:FocusTraversalExample.java

public Component getLastComponent(Container focusCycleRoot) {
    SortedMap buttons = getSortedButtons(focusCycleRoot);
    if (buttons.isEmpty()) {
        return null;
    }/*from w ww . j  av  a2  s .c o  m*/
    return (Component) buttons.get(buttons.lastKey());
}

From source file:FocusTraversalExample.java

public Component getComponentAfter(Container focusCycleRoot, Component aComponent) {
    if (!(aComponent instanceof JButton)) {
        return null;
    }// w w w  . j  ava  2  s .co  m
    SortedMap buttons = getSortedButtons(focusCycleRoot);
    // Find all buttons after the current one.
    String nextName = ((JButton) aComponent).getText() + "\0";
    SortedMap nextButtons = buttons.tailMap(nextName);
    if (nextButtons.isEmpty()) { // Wrapped back to beginning
        if (!buttons.isEmpty()) {
            return (Component) buttons.get(buttons.firstKey());
        }
        return null; // Degenerate case of no buttons.
    }
    return (Component) nextButtons.get(nextButtons.firstKey());
}