List of usage examples for com.google.common.collect Maps newHashMap
public static <K, V> HashMap<K, V> newHashMap()
From source file:org.xiaoqiaotq.util.persistence.SearchFilter.java
/** * searchParamskey?OPERATOR_FIELDNAME/*from w ww . ja v a2 s . c om*/ */ 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 (StringUtils.isBlank((String) value)) { continue; } // operatorfiledAttribute String[] names = StringUtils.split(key, "_"); // if (names.length != 2) { // throw new IllegalArgumentException(key + " is not a valid search filter name"); // } String filedName = names[1]; Operator operator = Operator.valueOf(names[0]); //add param type resolve if (names.length == 3) { switch (ValueType.valueOf(names[2])) { case DATE: try { value = new SimpleDateFormat("yyyy-MM-dd").parse(value.toString()); } catch (ParseException e) { // TODO Auto-generated catch block throw new RuntimeException(e.getMessage(), e); } break; default: break; } } // searchFilter SearchFilter filter = new SearchFilter(filedName, operator, value); filters.put(key, filter); } return filters; }
From source file:zotmc.collect.FallbackingMap.java
public static <K, V> FallbackingMap<K, V> create(final Function<K, V> function) { final Map<K, V> delegatee = Maps.newHashMap(); return new FallbackingMap<K, V>() { @Override//from ww w . ja v a2s . c om protected Map<K, V> delegatee() { return delegatee; } @Override public Function<K, V> function() { return function; } }; }
From source file:org.jfrog.teamcity.agent.util.PathHelper.java
public static Map<String, String> getPublishedArtifactsPatternPairs(String publishedArtifactsPropertyValue) { Map<String, String> patternPairMap = Maps.newHashMap(); if (StringUtils.isNotBlank(publishedArtifactsPropertyValue)) { List<String> patternPairs = mappingPatternsFormPath(publishedArtifactsPropertyValue); for (String patternPair : patternPairs) { String[] splitPattern = patternPair.split("=>"); String sourcePattern = ""; String targetPattern = ""; if (splitPattern.length > 0) { sourcePattern = removeDoubleDotsFromPattern(splitPattern[0].trim().replace('\\', '/')); }/*from ww w .ja v a 2 s. c o m*/ if (splitPattern.length > 1) { targetPattern = removeDoubleDotsFromPattern(splitPattern[1].trim().replace('\\', '/')); } if (StringUtils.isNotBlank(sourcePattern)) { patternPairMap.put(sourcePattern, targetPattern); } } } return patternPairMap; }
From source file:com.oakhole.core.uitls.XMLMapper.java
/** * SAX??xml,/*w ww. jav a2 s.c om*/ * * @param inputStream * @return * @throws Exception */ public static Map<String, String> parseXml(InputStream inputStream) throws Exception { Map<String, String> map = Maps.newHashMap(); SAXReader reader = new SAXReader(); Document document = reader.read(inputStream); Element root = document.getRootElement(); List<Element> elementList = root.elements(); for (Element e : elementList) { map.put(e.getName(), e.getText()); } inputStream.close(); inputStream = null; return map; }
From source file:com.google.devtools.depan.java.bytecode.eclipse.ui.widgets.AsmLevelControl.java
private static Map<String, AsmFactory> buildAsmOptions() { Map<String, AsmFactory> result = Maps.newHashMap(); result.put("ASM-4", AsmFactory.ASM4_FACTORY); result.put("ASM-5", AsmFactory.ASM5_FACTORY); return result; }
From source file:org.carrot2.util.MapUtils.java
/** * Iterates through entries of the input <code>map</code> and for values being String * arrays puts the first element of the map in the result map. Scalar values get * copied to the output map unchanged.//w w w . j ava2 s. com * <p> * This method might be useful for "unpacking" values from servlet HTTP requests. */ @SuppressWarnings({ "rawtypes" }) public static Map<String, Object> unpack(final Map map) { final Map<String, Object> result = Maps.newHashMap(); for (Object entry : map.entrySet()) { final Map.Entry mapEntry = (Entry) entry; final String parameterName = (String) mapEntry.getKey(); final String[] parameterValues = (String[]) mapEntry.getValue(); if (parameterValues.length == 1) { result.put(parameterName, parameterValues[0]); } else { result.put(parameterName, Lists.newArrayList(parameterValues)); } } return result; }
From source file:com.flaptor.indextank.index.scorer.FacetingManager.java
public static Map<String, Multiset<String>> mergeFacets(Map<String, Multiset<String>> facets1, Map<String, Multiset<String>> facets2) { Map<String, Multiset<String>> result = Maps.newHashMap(); Set<String> facets1Cats = facets1.keySet(); for (String category : facets1Cats) { Multiset<String> facet1 = HashMultiset.create(facets1.get(category)); Multiset<String> facet2 = facets2.get(category); if (facet2 != null) { facet1.addAll(facet2);//from ww w. jav a 2 s .c o m } result.put(category, facet1); } Set<String> facets2Cats = facets2.keySet(); for (String category : facets2Cats) { if (!result.containsKey(category)) { result.put(category, HashMultiset.create(facets2.get(category))); } } return result; }
From source file:com.cloudera.exhibit.server.jdbi.JdbiExhibitStore.java
public static JdbiExhibitStore create(DBI jdbi, String table, String id) { Handle handle = jdbi.open();//ww w . j a va 2 s .co m Iterator<Exhibit> iter = handle.createQuery("select * from " + table).map(new ExhibitMapper(id)).iterator(); Map<String, Exhibit> exhibits = Maps.newHashMap(); while (iter.hasNext()) { Exhibit e = iter.next(); exhibits.put(e.attributes().get(id, String.class), e); } return new JdbiExhibitStore(exhibits); }
From source file:de.flapdoodle.logparser.collections.Collections.java
public static <K, V> Map<K, V> join(Map<K, V>... maps) { Map<K, V> ret = Maps.newHashMap(); for (Map<K, V> map : maps) { ret = join(ret, map);// w w w. java2 s.co m } return ret; }
From source file:com.querydsl.spatial.hibernate.HibernateSpatialSupport.java
public static Map<Operator, String> getSpatialOps() { Map<Operator, String> ops = Maps.newHashMap(); ops.put(SpatialOps.DIMENSION, "dimension({0})"); ops.put(SpatialOps.GEOMETRY_TYPE, "geometrytype({0}, {1})"); ops.put(SpatialOps.SRID, "srid({0})"); ops.put(SpatialOps.SRID2, "srid2({0}, {1})"); ops.put(SpatialOps.ENVELOPE, "envelope({0})"); ops.put(SpatialOps.AS_TEXT, "astext({0})"); ops.put(SpatialOps.AS_BINARY, "asbinary({0})"); ops.put(SpatialOps.IS_EMPTY, "isempty({0})"); ops.put(SpatialOps.IS_SIMPLE, "issimple({0})"); ops.put(SpatialOps.BOUNDARY, "boundary({0})"); ops.put(SpatialOps.EXTENT, "extent({0})"); ops.put(SpatialOps.EQUALS, "equals({0}, {1}) = true"); ops.put(SpatialOps.DISJOINT, "disjoint({0}, {1}) = true"); ops.put(SpatialOps.INTERSECTS, "intersects({0}, {1}) = true"); ops.put(SpatialOps.TOUCHES, "touches({0}, {1}) = true"); ops.put(SpatialOps.CROSSES, "crosses({0}, {1}) = true"); ops.put(SpatialOps.WITHIN, "within({0}, {1}) = true"); ops.put(SpatialOps.CONTAINS, "contains({0}, {1}) = true"); ops.put(SpatialOps.OVERLAPS, "overlaps({0}, {1}) = true"); ops.put(SpatialOps.RELATE, "relate({0}, {1}, {2}) = true"); ops.put(SpatialOps.DISTANCE, "distance({0}, {1})"); ops.put(SpatialOps.DISTANCE2, "distance({0}, {1}, {2})"); ops.put(SpatialOps.DISTANCE_SPHERE, "distancesphere({0}, {1})"); ops.put(SpatialOps.DISTANCE_SPHEROID, "distancespheroid({0}, {1})"); ops.put(SpatialOps.BUFFER, "buffer({0}, {1})"); ops.put(SpatialOps.BUFFER2, "buffer({0}, {1}, {2})"); ops.put(SpatialOps.CONVEXHULL, "convexhull({0})"); ops.put(SpatialOps.INTERSECTION, "intersection({0}, {1})"); ops.put(SpatialOps.UNION, "geomunion({0}, {1})"); ops.put(SpatialOps.DIFFERENCE, "difference({0}, {1})"); ops.put(SpatialOps.SYMDIFFERENCE, "symdifference({0}, {1})"); ops.put(SpatialOps.DWITHIN, "dwithin({0}, {1}, {2}) = true"); ops.put(SpatialOps.TRANSFORM, "transform({0}, {1})"); // custom// ww w .j ava 2s . c o m ops.put(SpatialOps.WKTTOSQL, "wkttosql({0}, {1})"); ops.put(SpatialOps.WKBTOSQL, "wkbtosql({0}, {1})"); ops.put(SpatialOps.X, "x({0})"); ops.put(SpatialOps.X2, "x({0}, {1})"); ops.put(SpatialOps.Y, "y({0})"); ops.put(SpatialOps.Y2, "y({0}, {1})"); ops.put(SpatialOps.Z, "y({0})"); ops.put(SpatialOps.Z2, "y({0}, {1})"); ops.put(SpatialOps.M, "y({0})"); ops.put(SpatialOps.M2, "y({0}, {1})"); ops.put(SpatialOps.START_POINT, "startpoint({0})"); ops.put(SpatialOps.END_POINT, "endpoint({0})"); ops.put(SpatialOps.IS_RING, "isring({0})"); ops.put(SpatialOps.LENGTH, "length({0})"); ops.put(SpatialOps.LENGTH2, "length({0}, {1})"); ops.put(SpatialOps.NUM_POINTS, "numpoints({0})"); ops.put(SpatialOps.POINTN, "pointn({0})"); ops.put(SpatialOps.AREA, "area({0})"); ops.put(SpatialOps.AREA2, "area({0}, {1})"); ops.put(SpatialOps.CENTROID, "centroid({0})"); ops.put(SpatialOps.POINT_ON_SURFACE, "pointonsurface({0})"); ops.put(SpatialOps.EXTERIOR_RING, "exteriorring({0})"); ops.put(SpatialOps.EXTERIOR_RING2, "exteriorring({0}, {1})"); ops.put(SpatialOps.INTERIOR_RINGS, "interiorrings({0})"); ops.put(SpatialOps.INTERIOR_RINGS2, "interiorrings({0}, {1})"); ops.put(SpatialOps.NUM_INTERIOR_RING, "numinteriorring({0})"); ops.put(SpatialOps.INTERIOR_RINGN, "interiorringn({0}, {1})"); ops.put(SpatialOps.GEOMETRIES, "geometries({0})"); ops.put(SpatialOps.NUM_SURFACES, "numsurfaces({0})"); ops.put(SpatialOps.SURFACE, "surface({0})"); ops.put(SpatialOps.NUM_GEOMETRIES, "numgeometries({0})"); ops.put(SpatialOps.GEOMETRYN, "geometryn({0})"); ops.put(SpatialOps.IS_CLOSED, "isclosed({0})"); ops.put(SpatialOps.AS_EWKT, "asewkt({0})"); ops.put(SpatialOps.GEOM_FROM_TEXT, "geomfromtext({0})"); ops.put(SpatialOps.SET_SRID, "setsrid({0}, {1})"); ops.put(SpatialOps.XMIN, "xmin({0})"); ops.put(SpatialOps.XMAX, "xmax({0})"); ops.put(SpatialOps.YMIN, "ymin({0})"); ops.put(SpatialOps.YMAX, "ymax({0})"); ops.put(SpatialOps.COLLECT, "collect({0})"); ops.put(SpatialOps.COLLECT2, "collect({0}, {1})"); ops.put(SpatialOps.TRANSLATE, "translate({0})"); ops.put(SpatialOps.TRANSLATE2, "translate({0}, {1})"); return ops; }