List of usage examples for com.google.common.collect Maps newHashMap
public static <K, V> HashMap<K, V> newHashMap()
From source file:org.opendaylight.controller.config.facade.xml.mapping.attributes.fromxml.SimpleCompositeAttributeReadingStrategy.java
@Override protected Object postprocessParsedValue(String textContent) { HashMap<String, String> map = Maps.newHashMap(); map.put(key, textContent);//from w ww .j av a 2s. co m return map; }
From source file:com.thinkgem.jeesite.modules.pms.utils.FeesUtils.java
public static Map<String, Fees> getALLFees() { @SuppressWarnings("unchecked") Map<String, Fees> dictMap = (Map<String, Fees>) CacheUtils.get(CACHE_FEES_MAP); if (dictMap == null) { dictMap = Maps.newHashMap(); for (Fees fees : feesDao.findAll()) { dictMap.put(fees.getId(), fees); }/*w w w .ja va2s . c o m*/ CacheUtils.put(CACHE_FEES_MAP, dictMap); } return dictMap; }
From source file:apm.modules.sys.support.Dicts.java
public static List<Dict> getDictList(String type) { @SuppressWarnings("unchecked") Map<String, List<Dict>> dictMap = (Map<String, List<Dict>>) CacheUtils.get(CACHE_DICT_MAP); if (dictMap == null) { dictMap = Maps.newHashMap(); for (Dict dict : dictDao.findAllList()) { List<Dict> dictList = dictMap.get(dict.getType()); if (dictList != null) { dictList.add(dict);/*from w ww . j a v a 2s . c o m*/ } else { dictMap.put(dict.getType(), Lists.newArrayList(dict)); } } CacheUtils.put(CACHE_DICT_MAP, dictMap); } List<Dict> dictList = Lists.newArrayList(); if (dictList != null) { dictList = dictMap.get(type); } return dictList; }
From source file:com.yufei.analysis.service.TermQuery.java
@Override public void query() { int skip = (getCurrentPage() - 1) * getPageSize(); int limit = getPageSize(); String matchedText = queryInfo.getText(); Long type = queryInfo.getType(); Map<String, Object> params = Maps.newHashMap(); if (type != null && type > 0) { params.put("type:=", type); }/*ww w. j av a2s . co m*/ if (matchedText != null && matchedText.length() > 0) { params.put("text:like", matchedText); } params.put("skip", skip); params.put("limit", limit); long count = Constants.mps.count(params, Term.class); List<Term> terms = Constants.mps.query(params, Term.class); setSearchResult(terms); queryInfo.setTotalcount((int) count); }
From source file:org.axdt.asdoc.parser.html.MutableNamespaceContext.java
public MutableNamespaceContext() { map = Maps.newHashMap(); }
From source file:blockplus.model.polyomino.PolyominoProperties.java
public static ICells<Integer> computeCells(final String[] data) { final int rows = data.length; final int columns = rows == 0 ? 0 : data[0].length(); final ICells<Integer> cells = Cells.from(rows, columns, 1, 1); final Map<IPosition, Integer> mutations = Maps.newHashMap(); for (int row = 0; row < rows; ++row) { for (int column = 0; column < columns; ++column) { final IPosition position = Position(row, column); final char cell = data[row].charAt(column); if (cell != NONE) mutations.put(position, Integer.parseInt(String.valueOf(cell))); }/* w ww . j av a 2 s. co m*/ } return cells.apply(mutations); }
From source file:com.github.fhirschmann.clozegen.cli.Utils.java
/** * Extracts a map where K V corresponds to k?/v?,k/v,k/-1,k_n/v_n. * * @param str the string to parse//from ww w. j a v a 2s. c o m * @return a map created from the string */ public static Map<String, Integer> parseGapClasses(final String str) { Map<String, Integer> map = Maps.newHashMap(); for (String clazz : str.split(",")) { if (clazz.contains("/")) { String[] opts = clazz.split("/"); map.put(opts[0], Integer.parseInt(opts[1])); } else { map.put(clazz, GapAnnotator.DEFAULT_ANSWER_COUNT); } } return map; }
From source file:org.apache.giraph.hive.Helpers.java
public static Map<Integer, Double> parseIntDoubleResults(Iterable<String> results) { Map<Integer, Double> values = Maps.newHashMap(); for (String line : results) { String[] tokens = line.split("\\s+"); int id = Integer.valueOf(tokens[0]); double value = Double.valueOf(tokens[1]); values.put(id, value);//from w w w . ja v a 2s. c om } return values; }
From source file:com.cask.twitter.MapSerdesUtil.java
@SuppressWarnings("unchecked") public static Map<String, Double> deserializeMap(byte[] bytes) { if (bytes == null) { return Maps.newHashMap(); }//from w w w . ja v a 2 s .co m try { ByteArrayInputStream byteIn = new ByteArrayInputStream(bytes); ObjectInputStream in = new ObjectInputStream(byteIn); return (Map<String, Double>) in.readObject(); } catch (Throwable t) { LOG.error(t.getMessage(), t); return Maps.newHashMap(); } }
From source file:org.sakaiproject.nakamura.util.ActivityUtils.java
/** * Post an activity event. processed by activity listeners. * @param eventAdmin /*from ww w .j av a2 s .c om*/ * @param userId the userID performing the activity * @param path the path to the node the activity is associated with * @param appId the app Id (default is "Content" if null) * @param templateId the template Id (default is "default" if null) * @param type the type (default is content if null) * @param message the message ( default is NONE if null) * @param attributes attributes, ignored if null. */ public static void postActivity(EventAdmin eventAdmin, String userId, String path, String appId, String templateId, String type, String message, Map<String, Object> attributes) { Map<String, Object> finalAttributes = Maps.newHashMap(); if (attributes != null) { finalAttributes.putAll(attributes); } if (appId == null) { appId = "Content"; } if (templateId == null) { templateId = "default"; } if (type == null) { type = "content"; } if (message == null) { message = "NONE"; } finalAttributes.put("sakai:activity-appid", appId); finalAttributes.put("sakai:activity-appid", templateId); finalAttributes.put("sakai:activity-type", type); finalAttributes.put("sakai:activityMessage", message); Hashtable<String, Object> properties = new Hashtable<String, Object>(); properties.put("path", path); properties.put("userid", userId); properties.put("attributes", finalAttributes); eventAdmin.postEvent(new Event("org/sakaiproject/nakamura/activity/POSTED", (Map) properties)); }