Example usage for java.util Map isEmpty

List of usage examples for java.util Map isEmpty

Introduction

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

Prototype

boolean isEmpty();

Source Link

Document

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

Usage

From source file:RenderingUtils.java

private static Map installDesktopHints(Graphics2D g2) {
    Map oldRenderingHints = null;

    Map desktopHints = desktopHints(g2);
    if (desktopHints != null && !desktopHints.isEmpty()) {
        oldRenderingHints = new HashMap(desktopHints.size());
        RenderingHints.Key key;
        for (Iterator i = desktopHints.keySet().iterator(); i.hasNext();) {
            key = (RenderingHints.Key) i.next();
            oldRenderingHints.put(key, g2.getRenderingHint(key));
        }//w  w  w. ja  v a 2 s .c  o m
        g2.addRenderingHints(desktopHints);
    }

    return oldRenderingHints;
}

From source file:net.bitnine.agensgraph.graph.property.JsonObject.java

public static JsonObject create(Map<String, ?> map) {
    if (map == null || map.isEmpty())
        return new JsonObject();

    JsonObject jobj = new JsonObject();
    for (Map.Entry<String, ?> entry : map.entrySet()) {
        String key = entry.getKey();
        if (key == null)
            throw new IllegalArgumentException("'null' key is not allowed in JsonObject");
        Object value = entry.getValue();
        if (isJsonValue(value))
            jobj.put(key, value);/* w  ww .  jav a2  s.c om*/
        else
            throw new IllegalArgumentException("invalid json value type");
    }

    return jobj;
}

From source file:ee.ria.xroad.common.util.MimeUtils.java

/**
 * Converts a map of header key-values to header array with colon-separated values.
 * @param headers the map of header key-values
 * @return array of color-separated Strings
 *///from w w w.j  a va  2 s .  co  m
public static String[] toHeaders(Map<String, String> headers) {
    if (headers != null && !headers.isEmpty()) {
        return headers.entrySet().stream().map(e -> e.getKey() + ": " + e.getValue())
                .collect(Collectors.toList()).toArray(new String[] {});
    } else {
        return null;
    }
}

From source file:com.jlfex.hermes.common.utils.CollectionUtil.java

/**
 * ?./*from  w w  w .j a v  a 2  s.  c  o m*/
 */
@SuppressWarnings("rawtypes")
public static boolean isEmpty(Map map) {
    return (map == null) || map.isEmpty();
}

From source file:com.kwoksys.framework.util.StringUtils.java

/**
 * Joins a list of maps./*  w w  w .  j a  va 2  s. c o m*/
 *
 * @param list
 * @param token
 * @return ..
 */
public static String join(List<Map> maps, String key, String token) {
    StringBuilder buffer = new StringBuilder();
    boolean appendToken = false;

    for (Map map : maps) {
        if (!map.isEmpty()) {
            if (appendToken) {
                buffer.append(token);
            }
            buffer.append(map.get(key));
            appendToken = true;
        }
    }
    return buffer.toString();
}

From source file:Main.java

public static <K, V> Map<K, V> unmodifiableMap(final Map<? extends K, ? extends V> m, final boolean newMap,
        final boolean emptyAsNull) {
    if (m == null) {
        return null;
    }//  ww w .  j a v a2 s.co m

    if (emptyAsNull && m.isEmpty()) {
        return null;
    }

    return Collections.unmodifiableMap(newMap ? new HashMap<>(m) : m);
}

From source file:com.astamuse.asta4d.web.dispatch.RedirectUtil.java

public static void addFlashScopeData(Map<String, Object> flashScopeData) {
    if (flashScopeData == null || flashScopeData.isEmpty()) {
        return;/* w ww.  j ava 2 s .c o  m*/
    }
    WebApplicationContext context = Context.getCurrentThreadContext();
    List<Map<String, Object>> dataList = context.getData(FlashScopeDataListKey);
    if (dataList == null) {
        dataList = new LinkedList<>();
        context.setData(FlashScopeDataListKey, dataList);
    }
    dataList.add(flashScopeData);
}

From source file:Main.java

public static <K, V> Collection<Map<K, V>> filterListMap(Collection<Map<K, V>> unfiltered,
        final Map<K, V> map) {
    return filter(unfiltered, new Predicate<Map<K, V>>() {
        @Override/*  w  w w . ja va 2s .  c o  m*/
        public boolean apply(Map<K, V> input) {
            if (null == map || map.isEmpty())
                return true;
            Iterator<Map.Entry<K, V>> iter = map.entrySet().iterator();
            boolean flag = true;
            while (iter.hasNext()) {
                Map.Entry<K, V> entry = iter.next();
                V iV = input.get(entry.getKey());
                V cV = entry.getValue();
                flag &= Objects.equal(iV, cV);
                if (!flag)
                    break;
            }
            return flag;
        }
    });
}

From source file:org.vader.common.spring.TransactionScope.java

private static ScopeEntry getOrCreateScopeEntry(String name) {
    final Map<String, ScopeEntry> scope = getCurrentScope();
    if (scope.isEmpty()) {
        registerSynchronization();//from   w  ww .  j  a v  a 2s . co m
    }
    final ScopeEntry entry = scope.get(name);
    if (entry != null) {
        return entry;
    }
    final ScopeEntry newEntry = new ScopeEntry();
    scope.put(name, newEntry);
    return newEntry;
}

From source file:com.mmj.app.common.cookie.parser.CookieParser.java

/**
 * CookieName???Cookievalue. ?CookieNameCookieKey
 * /*from   w  ww .  ja va  2 s  . c  om*/
 * @return ?null
 */
public static CookieNameHelper paserCookieValue(CookieNameConfig cookieNameConfig, String cookieValue) {
    String value = StringUtils.trimToNull(cookieValue);
    if (value == null || StringUtils.equalsIgnoreCase("null", value))
        return null;

    // ?
    if (cookieNameConfig.isEncrypt()) {
        value = EncryptBuilder.getInstance().decrypt(value);
    }
    CookieNameHelper cookieNameHelper = new CookieNameHelper(cookieNameConfig.getCookieName(),
            cookieNameConfig);
    // ??Key??,?
    if (cookieNameConfig.isSimpleValue()) {
        cookieNameHelper.parserValue(value);
    } else {
        // ??Value??
        Map<CookieKeyEnum, String> kv = CookieUtils.strToKVMap(value, cookieNameConfig);
        // CookieNameHelper cookieNameHelper = null;
        if (kv != null && !kv.isEmpty())
            cookieNameHelper.parserAllValues(kv);
    }
    return cookieNameHelper;
}