List of usage examples for java.util Map isEmpty
boolean isEmpty();
From source file:com.spotify.scio.extra.transforms.ProcessUtil.java
static String[] createEnv(Map<String, String> environment) { if (environment == null || environment.isEmpty()) { return null; }/*from w ww. j a v a 2s . c o m*/ String[] envp = new String[environment.size()]; int i = 0; for (Map.Entry<String, String> e : environment.entrySet()) { envp[i] = e.getKey() + "=" + e.getValue(); i++; } return envp; }
From source file:com.capitaltg.bbcodeguard.StringUtils.java
public static String replaceAll(String original, Map<String, String> replacements) { if (original == null || replacements == null || replacements.isEmpty()) { return original; }/*from ww w . j a v a 2 s. c o m*/ StringHolder response = new StringHolder(original); replacements.forEach((n, v) -> response.replaceAll("@" + n + "@", v)); return response.toString(); }
From source file:de.micromata.mgc.jpa.hibernatesearch.bridges.TabAttrFieldBridge.java
public static void addToIndex(String prefix, Object value, Document document, LuceneOptions luceneOptions) { if ((value instanceof Map) == false) { return;//from www .jav a 2 s . c o m } Map rawmap = (Map) value; if (rawmap.isEmpty() == true) { return; } Set<Map.Entry> mes = rawmap.entrySet(); for (Map.Entry me : mes) { if ((me.getKey() instanceof String) == false || (me.getValue() instanceof JpaTabAttrBaseDO) == false) { LOG.error("Bridge to incompatible type: " + me.getKey() + "=" + me.getValue()); continue; } String key = (String) me.getKey(); JpaTabAttrBaseDO<?, ?> attr = (JpaTabAttrBaseDO<?, ?>) me.getValue(); String svalue = attr.getStringData(); svalue = StringUtils.defaultString(svalue); Field field = new StringField(key, svalue, DEFAULT_STORE); document.add(field); field = new StringField("ALL", svalue, DEFAULT_STORE); document.add(field); field = new StringField("propertyName", key, DEFAULT_STORE); document.add(field); field = new StringField("value", svalue, DEFAULT_STORE); document.add(field); } }
From source file:io.gravitee.common.util.EnvironmentUtils.java
public static Object get(String key, Map<String, Object> map) { if (map == null || map.isEmpty()) { return null; }//w w w. ja v a 2 s . c om return map.get(encodedKey(key)); }
From source file:Main.java
/** * Creates an unmodifiable shallow copy of the given original {@link Map}. <p> While the copy returns an immutable * copy of the {@link Map} the content is not cloned in any way. Unless the content is immutable by itself the * result is not fully immutable. In the shallow copy all references are the same as in the original {@link Map}! * </p>/*from w w w.ja v a 2 s .c o m*/ * * @param original The {@link Map} to copy the elements fro. * @param <K> The type of the key * @param <V> The type of the value * * @return Returns an immutable (unmodifiable) copy of the original {@link Map} with all the elements added but not * cloned! */ public static <K, V> Map<K, V> createUnmodifiableShallowCopy(final Map<K, V> original) { if (original == null || original.isEmpty()) { return Collections.emptyMap(); } else { return Collections.unmodifiableMap(new HashMap<K, V>(original)); } }
From source file:Main.java
/** * Creates an Properties object initialized with the value from the given Map. * <p>//from w ww. ja v a 2s . co m * @param map the Map supply the keys and value for the Properties object. * @return a Properties object initialized with the key and value from the Map. * @see java.util.Map * @see java.util.Properties */ public static Properties createProperties(final Map<String, String> map) { Properties properties = new Properties(); if (!(map == null || map.isEmpty())) { for (Entry<String, String> entry : map.entrySet()) { properties.setProperty(entry.getKey(), entry.getValue()); } } return properties; }
From source file:jp.co.opentone.bsol.framework.web.view.PagePropertyUtil.java
/** * page???values??.//from w w w .j a va 2 s .co m * <p> * ???????????????. * </p> * @param page * page * @param values * ? */ public static void copyProperties(Page page, Map<String, Object> values) { if (values != null && !values.isEmpty()) { try { PropertyUtils.copyProperties(page, values); } catch (IllegalAccessException e) { throw new ReflectionRuntimeException(e); } catch (InvocationTargetException e) { throw new ReflectionRuntimeException(e); } catch (NoSuchMethodException e) { throw new ReflectionRuntimeException(e); } } }
From source file:Main.java
/** * Returns a string composed from a {@link Map}. *//*from w w w. j ava2 s . c o m*/ public static <T> String toString(Map<T, byte[]> map) { if (map == null) { return "null"; } if (map.isEmpty()) { return "{}"; } StringBuilder buffer = new StringBuilder(); buffer.append('{'); Iterator<Map.Entry<T, byte[]>> it = map.entrySet().iterator(); while (it.hasNext()) { Map.Entry<T, byte[]> entry = it.next(); Object key = entry.getKey(); buffer.append(key).append("=").append(Arrays.toString(map.get(key))); if (it.hasNext()) { buffer.append(", "); } } buffer.append('}'); return buffer.toString(); }
From source file:Main.java
public static boolean isEmpty(Map<?, ?> map) { if (map == null) { return true; }/* w w w .ja v a 2 s.c o m*/ return map.isEmpty(); }
From source file:Main.java
/** * Returns a string composed from a {@link Map}. *///from w ww . ja v a 2 s. co m static <T> String toString(Map<T, byte[]> map) { if (map == null) { return "null"; } if (map.isEmpty()) { return "{}"; } StringBuilder buffer = new StringBuilder(); buffer.append('{'); Iterator<Map.Entry<T, byte[]>> it = map.entrySet().iterator(); while (it.hasNext()) { Map.Entry<T, byte[]> entry = it.next(); Object key = entry.getKey(); buffer.append(key).append("=").append(Arrays.toString(map.get(key))); if (it.hasNext()) { buffer.append(", "); } } buffer.append('}'); return buffer.toString(); }