Java Code Examples for org.apache.commons.collections.MapUtils#EMPTY_MAP
The following examples show how to use
org.apache.commons.collections.MapUtils#EMPTY_MAP .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MyMessageSource.java From scaffold-cloud with MIT License | 6 votes |
/** * 从数据库中获取所有国际化配置 这边可以根据自己数据库表结构进行相应的业务实现 * 对应的语言能够取出来对应的值就行了 无需一定要按照这个方法来 */ public Map<String, Map<String, String>> loadAllMessageResourcesFromDB() { ResponseModel<List<SysI18nBO>> resp = sysI18nFeign.findList(new SysI18nAO()); List<SysI18nBO> list = resp.getData(); if (CollectionUtils.isNotEmpty(list)) { final Map<String, String> zhCnMessageResources = new HashMap<>(list.size()); final Map<String, String> enUsMessageResources = new HashMap<>(list.size()); for (SysI18nBO bo : list) { String name = bo.getModel() + "." + bo.getName(); String zhText = bo.getZhCn(); String enText = bo.getEnUs(); zhCnMessageResources.put(name, zhText); enUsMessageResources.put(name, enText); } LOCAL_CACHE.put("zh", zhCnMessageResources); LOCAL_CACHE.put("en", enUsMessageResources); } return MapUtils.EMPTY_MAP; }
Example 2
Source File: ReturnEmptyMap.java From levelup-java-examples with Apache License 2.0 | 6 votes |
/** * Used for post example */ @SuppressWarnings({ "unused", "unchecked" }) private void return_empty_map_apache_commons_exception () { DomainObject domain = null; // dao populate domain Map<String, String> mapOfStrings; if (domain != null && !MapUtils.isEmpty(domain.getMap())) { mapOfStrings = domain.getMap(); } else { mapOfStrings = MapUtils.EMPTY_MAP; } //... }
Example 3
Source File: RangerDefaultService.java From ranger with Apache License 2.0 | 5 votes |
@Override public Map<String, Object> validateConfig() throws Exception { if(LOG.isDebugEnabled()) { LOG.debug("RangerDefaultService.validateConfig Service: (" + serviceName + " ), returning empty map"); } return MapUtils.EMPTY_MAP; }
Example 4
Source File: ReturnEmptyMap.java From levelup-java-examples with Apache License 2.0 | 5 votes |
@Test public void return_empty_map_apache_commons () { @SuppressWarnings("unchecked") Map<String, String> emptyMap = MapUtils.EMPTY_MAP; assertTrue(emptyMap.isEmpty()); }
Example 5
Source File: InitializeMap.java From levelup-java-examples with Apache License 2.0 | 5 votes |
@Test public void create_new_map_apache () { @SuppressWarnings("unchecked") Map<String, String> newMap = MapUtils.EMPTY_MAP; assertNotNull(newMap); }
Example 6
Source File: Fixtures.java From restcommander with Apache License 2.0 | 4 votes |
/** * * TODO: reuse beanutils or MapUtils? * * @param entityProperties * @param prefix * @return an hash with the resolved entity name and the corresponding value */ static Map<String, String[]> serialize(Map<?, ?> entityProperties, String prefix) { if (entityProperties == null) { return MapUtils.EMPTY_MAP; } final Map<String, String[]> serialized = new HashMap<String, String[]>(); for (Object key : entityProperties.keySet()) { Object value = entityProperties.get(key); if (value == null) { continue; } if (value instanceof Map<?, ?>) { serialized.putAll(serialize((Map<?, ?>) value, prefix + "." + key)); } else if (value instanceof Date) { serialized.put(prefix + "." + key.toString(), new String[]{new SimpleDateFormat(DateBinder.ISO8601).format(((Date) value))}); } else if (Collection.class.isAssignableFrom(value.getClass())) { Collection<?> l = (Collection<?>) value; String[] r = new String[l.size()]; int i = 0; for (Object el : l) { r[i++] = el.toString(); } serialized.put(prefix + "." + key.toString(), r); } else if (value instanceof String && value.toString().matches("<<<\\s*\\{[^}]+}\\s*")) { Matcher m = Pattern.compile("<<<\\s*\\{([^}]+)}\\s*").matcher(value.toString()); m.find(); String file = m.group(1); VirtualFile f = Play.getVirtualFile(file); if (f != null && f.exists()) { serialized.put(prefix + "." + key.toString(), new String[]{f.contentAsString()}); } } else { serialized.put(prefix + "." + key.toString(), new String[]{value.toString()}); } } return serialized; }