List of usage examples for com.google.common.collect Maps newHashMap
public static <K, V> HashMap<K, V> newHashMap()
From source file:com.android.build.gradle.AndroidGradleOptions.java
@NonNull public static Map<String, String> getExtraInstrumentationTestRunnerArgs(@NonNull Project project) { Map<String, String> argsMap = Maps.newHashMap(); for (Map.Entry<String, ?> entry : project.getProperties().entrySet()) { if (entry.getKey().startsWith(PROPERTY_TEST_RUNNER_ARGS)) { String argName = entry.getKey().substring(PROPERTY_TEST_RUNNER_ARGS.length()); String argValue = entry.getValue().toString(); argsMap.put(argName, argValue); }/*from ww w.ja v a 2 s.com*/ } return argsMap; }
From source file:org.eel.kitchen.jsonschema.util.JacksonUtils.java
/** * Return a map out of an object instance * * @param node the node//from w w w .ja v a2 s .com * @return a mutable map made of the instance's entries */ public static Map<String, JsonNode> nodeToMap(final JsonNode node) { final Map<String, JsonNode> ret = Maps.newHashMap(); final Iterator<Map.Entry<String, JsonNode>> iterator = node.fields(); Map.Entry<String, JsonNode> entry; while (iterator.hasNext()) { entry = iterator.next(); ret.put(entry.getKey(), entry.getValue()); } return ret; }
From source file:com.vityuk.ginger.provider.format.DefaultMessageFormatFactory.java
private static Map<String, FormatFactory> createFactoryRegistry() { Map<String, FormatFactory> formatFactoryRegistry = Maps.newHashMap(); if (isJodaTimeAvailable()) { FormatFactory dateTimeFormatFactory = new JdkAndJodaDateTimeFormatFactory(); formatFactoryRegistry.put(FormatType.TIME.getFormat(), dateTimeFormatFactory); formatFactoryRegistry.put(FormatType.DATE.getFormat(), dateTimeFormatFactory); formatFactoryRegistry.put(FormatType.DATETIME.getFormat(), dateTimeFormatFactory); } else {//from w ww. j ava2s . co m // Only add 'datetime' format support for JDK Date formatFactoryRegistry.put(FormatType.DATETIME.getFormat(), new JdkDateTimeFormatFactory()); } return formatFactoryRegistry; }
From source file:com.mxep.web.common.persistence.SearchFilter.java
/** * searchParamskey?OPERATOR_FIELDNAME/*www. ja v a2 s.com*/ */ public static Map<String, SearchFilter> parse(Map<String, Object> searchParams) { Map<String, SearchFilter> filters = Maps.newHashMap(); for (Entry<String, Object> entry : searchParams.entrySet()) { // String key = entry.getKey(); Object value = entry.getValue(); if (value != null && StringUtils.isBlank(value.toString())) { continue; } // operatorfiledAttribute String[] names = StringUtils.split(key, "_"); if (names.length < 2) { throw new IllegalArgumentException(key + " is not a valid search filter name"); } String filedName = ""; for (int i = 1; i < names.length; i++) { filedName += names[i]; if ((i + 1) < names.length) { filedName += "."; } } Operator operator = getOperator(names[0]); if (null == operator) { continue; } // searchFilter if (isValidDate(value.toString())) { try { Date date = DateUtils.parseDate((String) value, "yyyy-MM-dd"); // ? if (operator.equals(Operator.LT) || operator.equals(Operator.LTE)) { Calendar cal = Calendar.getInstance(); cal.setTime(date); cal.add(Calendar.DAY_OF_YEAR, 1); date = cal.getTime(); } // ???? if (operator.equals(Operator.GT) || operator.equals(Operator.GTE)) { Calendar cal = Calendar.getInstance(); cal.setTime(date); date = cal.getTime(); } value = date; } catch (Exception e) { e.printStackTrace(); } } else if (isValidDateTime(value.toString())) { try { Date date = DateUtils.parseDate((String) value, "yyyy-MM-dd HH:mm:ss"); value = date; } catch (Exception e) { e.printStackTrace(); } } // searchFilter SearchFilter filter = new SearchFilter(filedName, operator, value); filters.put(key, filter); } return filters; }
From source file:com.ibm.og.json.StoppingConditionsConfig.java
public StoppingConditionsConfig() { this.operations = 0; this.runtime = 0.0; this.runtimeUnit = TimeUnit.SECONDS; this.statusCodes = Maps.newHashMap(); }
From source file:com.opengamma.integration.tool.portfolio.xml.v1_0.jaxb.AttributeMapAdapter.java
@Override public Map<String, String> unmarshal(AdditionalAttributes attrs) throws Exception { Map<String, String> map = Maps.newHashMap(); for (Attribute attribute : attrs.getAttributes()) { map.put(attribute.getName(), attribute.getValue()); }//from w w w.java 2s .c om return map; }
From source file:com.enonic.cms.core.plugin.host.HostServicesImpl.java
public HostServicesImpl() { this.serviceMap = Maps.newHashMap(); register("pluginEnvironment", new PluginEnvironmentImpl()); }
From source file:com.dvdprime.server.mobile.util.PropertiesUtil.java
/** * db.properties.xml ?? ? ? Map? ./* w w w .j av a2 s . com*/ * * @return Map<String, Object> */ public static Map<String, Object> loadProperties(String path) { if (resourcePropertiestMap.get(path) == null) { Map<String, Object> resultMap = Maps.newHashMap(); ClassLoader cl = Thread.currentThread().getContextClassLoader(); if (cl == null) { cl = ClassLoader.getSystemClassLoader(); } URL url = cl.getResource(path); // ? ?? . if (url == null) { return null; } // 1. ? ?? ?. Properties properties = new Properties(); FileInputStream fileInputStream = null; try { if (new File(url.getPath()).exists()) { fileInputStream = new FileInputStream(url.getPath()); properties.loadFromXML(fileInputStream); } else { // ? ? ? ? ?. Enumeration<URL> urls = cl.getResources(path); while (urls.hasMoreElements()) { url = (URL) urls.nextElement(); InputStream is = null; try { URLConnection con = url.openConnection(); con.setUseCaches(false); is = con.getInputStream(); properties.loadFromXML(is); } finally { if (is != null) { is.close(); } } } } } catch (IOException e) { e.printStackTrace(); } finally { if (fileInputStream != null) { try { fileInputStream.close(); } catch (IOException e) { e.printStackTrace(); } } } // 2. ? ?? ? ? eventMap ? . Enumeration<?> enumeration = properties.keys(); while (enumeration.hasMoreElements()) { String key = (String) enumeration.nextElement(); resultMap.put(key, properties.get(key)); } resourcePropertiestMap.put(path, resultMap); } return resourcePropertiestMap.get(path); }
From source file:org.waveprotocol.box.server.util.UrlParameters.java
public static Map<String, String> getParameters(String query) { Map<String, String> map = Maps.newHashMap(); if (query != null) { String[] params = query.split("&"); for (String param : params) { String[] parts = param.split("="); if (parts.length == 2) { map.put(parts[0], parts[1]); }/* w w w . jav a2 s .co m*/ } } return map; }
From source file:com.xebialabs.overcast.support.libvirt.jdom.InterfaceXml.java
/** * Get a map of mac addresses of interfaces defined on the domain. This is somewhat limited at the moment. It is * assumed that only one network interface with mac is connected to a bridge or network. For instance if you have a * bridged network device connected to 'br0' then you will find it's MAC address with the key 'br0'. *//*from w w w . j a va 2 s . co m*/ public static Map<String, String> getMacs(Document domainXml) { Map<String, String> macs = Maps.newHashMap(); XPathFactory xpf = XPathFactory.instance(); XPathExpression<Element> interfaces = xpf.compile("/domain/devices/interface", Filters.element()); for (Element iface : interfaces.evaluate(domainXml)) { String interfaceType = iface.getAttribute("type").getValue(); logger.debug("Detecting IP on network of type '{}'", interfaceType); if ("bridge".equals(interfaceType)) { Element macElement = iface.getChild("mac"); String mac = macElement.getAttribute("address").getValue(); Element sourceElement = iface.getChild("source"); String bridge = sourceElement.getAttribute("bridge").getValue(); logger.info("Detected MAC '{}' on bridge '{}'", mac, bridge); macs.put(bridge, mac); } else if ("network".equals(interfaceType)) { Element macElement = iface.getChild("mac"); String mac = macElement.getAttribute("address").getValue(); Element sourceElement = iface.getChild("source"); String network = sourceElement.getAttribute("network").getValue(); logger.info("Detected MAC '{}' on network '{}'", mac, network); macs.put(network, mac); } else { logger.warn("Ignoring network of type {}", interfaceType); } } return macs; }