List of usage examples for com.google.common.collect Maps newLinkedHashMap
public static <K, V> LinkedHashMap<K, V> newLinkedHashMap()
From source file:org.jpmml.evaluator.EvaluatorUtil.java
/** * Decouples a {@link Map} instance from the current runtime environment by decoding both its keys and values. *///from w w w. j a v a 2 s . co m static public Map<String, ?> decode(Map<FieldName, ?> map) { Map<String, Object> result = Maps.newLinkedHashMap(); Collection<? extends Map.Entry<FieldName, ?>> entries = map.entrySet(); for (Map.Entry<FieldName, ?> entry : entries) { FieldName key = entry.getKey(); Object value = entry.getValue(); if (key == null) { continue; } result.put(key.getValue(), decode(value)); } return result; }
From source file:org.jclouds.ec2.util.IpPermissions.java
/** * don't rely on this being here.. it will move *///from ww w . j a v a 2 s . co m @Beta public static Multimap<String, String> buildFormParametersForIndex(final int index, IpPermission permission) { Map<String, String> headers = Maps.newLinkedHashMap(); headers.put("IpPermissions.%d.IpProtocol", permission.getIpProtocol().toString()); headers.put("IpPermissions.%d.FromPort", permission.getFromPort() + ""); headers.put("IpPermissions.%d.ToPort", permission.getToPort() + ""); String prefix = "IpPermissions.%d.IpRanges."; int i = 0; for (String cidrIp : checkNotNull(permission.getCidrBlocks(), "cidrIps")) { headers.put(prefix + i++ + ".CidrIp", cidrIp); } prefix = "IpPermissions.%d.Groups."; i = 0; for (String groupId : checkNotNull(permission.getGroupIds(), "groupIds")) { headers.put(prefix + i++ + ".GroupId", groupId); } prefix = "IpPermissions.%d.Groups."; i = 0; for (Entry<String, String> tenantIdGroupNamePair : checkNotNull(permission.getTenantIdGroupNamePairs(), "tenantIdGroupNamePairs").entries()) { headers.put(prefix + i + ".UserId", tenantIdGroupNamePair.getKey()); headers.put(prefix + i + ".GroupId", tenantIdGroupNamePair.getValue()); i++; } prefix = "IpPermissions.%d.IpRanges."; i = 0; for (String cidrIp : checkNotNull(permission.getCidrBlocks(), "cidrIps")) { headers.put(prefix + i++ + ".CidrIp", cidrIp); } return Multimaps.forMap(Maps2.transformKeys(headers, new Function<String, String>() { @Override public String apply(String arg0) { return String.format(arg0, index); } })); }
From source file:de.cosmocode.palava.ipc.cache.SimpleExecutingFilterChain.java
@Override public Map<String, Object> filter(IpcCall call, IpcCommand command) throws IpcCommandExecutionException { final Map<String, Object> result = Maps.newLinkedHashMap(); command.execute(call, result);/*from ww w . j av a2s . co m*/ return result; }
From source file:org.jetbrains.jet.lang.cfg.pseudocode.NondeterministicJumpInstruction.java
public NondeterministicJumpInstruction(List<Label> targetLabels) { this.targetLabels = Lists.newArrayList(targetLabels); resolvedTargets = Maps.newLinkedHashMap(); }
From source file:cc.recommenders.io.WritingArchive.java
public WritingArchive(File file) { Asserts.assertFalse(file.exists());//from w w w .j av a2 s . c o m File parent = file.getParentFile(); Asserts.assertTrue(parent.exists()); Asserts.assertTrue(parent.isDirectory()); content = Maps.newLinkedHashMap(); this.file = file; }
From source file:brooklyn.event.feed.jmx.JmxValueFunctions.java
public static Map tabularDataToMap(TabularData table) { Map<String, Object> result = Maps.newLinkedHashMap(); for (Object entry : table.values()) { CompositeData data = (CompositeData) entry; //.getValue() for (String key : data.getCompositeType().keySet()) { Object old = result.put(key, data.get(key)); if (old != null) { log.warn("tablularDataToMap has overwritten key {}", key); }/*w ww.j a v a 2s . c o m*/ } } return result; }
From source file:org.movsim.simulator.roadnetwork.routing.NetworkGraph.java
public static WeightedGraph<Long, RoadSegment> create(RoadNetwork roadNetwork) { DefaultDirectedWeightedGraph<Long, RoadSegment> graph = new DefaultDirectedWeightedGraph<>( RoadSegment.class); HashMap<RoadSegment, Node> connections = Maps.newLinkedHashMap(); for (final RoadSegment roadSegment : roadNetwork) { connections.clear();/*from w w w . j ava 2s .c om*/ connections.put(roadSegment, roadSegment.getDestinationNode()); for (LaneSegment laneSegment : roadSegment.laneSegments()) { if (laneSegment.sinkLaneSegment() != null) { RoadSegment successor = laneSegment.sinkLaneSegment().roadSegment(); connections.put(successor, successor.getOriginNode()); for (LaneSegment laneSegmentSuccessor : successor.laneSegments()) { if (laneSegmentSuccessor.sourceLaneSegment() != null) { RoadSegment predecessor = laneSegmentSuccessor.sourceLaneSegment().roadSegment(); connections.put(predecessor, predecessor.getDestinationNode()); } } } } createOrUpdateNode(connections); connections.clear(); connections.put(roadSegment, roadSegment.getOriginNode()); for (LaneSegment laneSegment : roadSegment.laneSegments()) { if (laneSegment.sourceLaneSegment() != null) { RoadSegment predecessor = laneSegment.sourceLaneSegment().roadSegment(); connections.put(predecessor, predecessor.getDestinationNode()); for (LaneSegment laneSegmentPredecessor : predecessor.laneSegments()) { if (laneSegmentPredecessor.sinkLaneSegment() != null) { RoadSegment successor = laneSegmentPredecessor.sinkLaneSegment().roadSegment(); connections.put(successor, successor.getOriginNode()); } } } } createOrUpdateNode(connections); } LOG.info("created graph with " + graph.edgeSet().size() + " edges and " + graph.vertexSet().size() + " nodes."); for (RoadSegment roadSegment : roadNetwork) { long fromVertex = roadSegment.getOriginNode().getId(); long toVertex = roadSegment.getDestinationNode().getId(); graph.addVertex(fromVertex); graph.addVertex(toVertex); graph.addEdge(fromVertex, toVertex, roadSegment); graph.setEdgeWeight(roadSegment, roadSegment.roadLength()); LOG.info("weight={}, roadSegment={}", graph.getEdgeWeight(roadSegment), roadSegment.toString()); } if (ProjectMetaData.getInstance().isWriteDotFile()) { exportToFile(graph); } return graph; }
From source file:org.jfrog.hudson.util.PropertyUtils.java
/** * Read the {@code gradle.properties} and parse it into {@link GradleModule}s. Only those keys which are given will * be included in the parsing.//from w w w . j av a 2 s . c o m * * @param gradlePropPath The path of the gradle.properties file * @param propKeys The property keys that should be taken into account when reading the properties file. * @return A map of {@link GradleModule}s that were assembled from the properties file, with the version as its * value. * @throws IOException In case an error occurs while reading the properties file, this exception is thrown. */ public static Map<String, String> getModulesPropertiesFromPropFile(FilePath gradlePropPath, String[] propKeys) throws IOException, InterruptedException { Properties gradleProps = loadGradleProperties(gradlePropPath); Map<String, String> versionsByPropKey = Maps.newLinkedHashMap(); for (String propKey : propKeys) { if (gradleProps.containsKey(propKey)) { versionsByPropKey.put(propKey, gradleProps.getProperty(propKey)); } } return versionsByPropKey; }
From source file:co.jirm.core.util.JirmUrlEncodedUtils.java
public static Map<String, List<String>> parseParameters(final URI uri, final String encoding) { List<NameValuePair> result = parse(uri, encoding); Map<String, List<String>> m = Maps.newLinkedHashMap(); for (NameValuePair nvp : result) { List<String> list = m.get(nvp.getName()); if (list == null) { list = Lists.newArrayList(); m.put(nvp.getName(), list);//from www . j a va2 s .com } list.add(nvp.getValue()); } return m; }
From source file:org.zaizi.alfresco.redlink.util.EntityTypeExtractor.java
public void init() { mapEntityTypes = Maps.newLinkedHashMap(); for (String entityType : entityTypes) { String value = properties.getProperty("sensefy.redlink.extract.entity.types." + entityType + ".uris"); String[] values = value.split(COMMA); for (String v : values) { mapEntityTypes.put(v, entityType); }/*from w w w . ja v a 2 s . com*/ } }