List of usage examples for com.google.common.collect Maps newLinkedHashMap
public static <K, V> LinkedHashMap<K, V> newLinkedHashMap()
From source file:nl.knaw.huygens.alexandria.endpoint.about.AboutEndpoint.java
/** * Show information about the back-end//from w ww.j a va 2s . c om * * @return about-data map */ @GET @ApiOperation("get information about the server (version,buildDate,commitId,startedAt)") public Response getMetadata() { final Map<String, String> data = Maps.newLinkedHashMap(); data.put("baseURI", baseURI.toString()); data.put("buildDate", getProperty("buildDate")); data.put("commitId", getProperty("commitId")); data.put("scmBranch", getProperty("scmBranch")); data.put("startedAt", startedAt.toString()); data.put("tentativesTTL", tentativesTTL.toString()); data.put("version", getProperty("version")); return Response.ok(data).build(); }
From source file:org.geogit.storage.sqlite.XerialConfigDatabase.java
@Override protected Map<String, String> all(final String section, Config config) { return new DbOp<Map<String, String>>() { @Override/*from www . j a v a2 s. c o m*/ protected Map<String, String> doRun(Connection cx) throws IOException, SQLException { String sql = "SELECT section,key,value FROM config WHERE section = ?"; PreparedStatement ps = open(cx.prepareStatement(log(sql, LOG, section))); ps.setString(1, section); ResultSet rs = open(ps.executeQuery()); Map<String, String> all = Maps.newLinkedHashMap(); while (rs.next()) { String entry = String.format("%.%", rs.getString(1), rs.getString(2)); all.put(entry, rs.getString(3)); } return all; } }.run(connect(config)); }
From source file:org.eclipse.xtext.xtext.XtextConfigurableIssueCodes.java
public XtextConfigurableIssueCodes() { final Map<String, PreferenceKey> map = Maps.newLinkedHashMap(); initialize(new IAcceptor<PreferenceKey>() { @Override/*from www . j a va 2s .c o m*/ public void accept(PreferenceKey prefKey) { map.put(prefKey.getId(), prefKey); } }); this.issueCodes = ImmutableMap.copyOf(map); }
From source file:clocker.mesos.location.MesosLocation.java
public MesosLocation() { this(Maps.newLinkedHashMap()); }
From source file:org.terasology.world.generation.facets.base.SparseBooleanFieldFacet3D.java
/** * @return a <b>new</b> map with world-based position entries */// w w w .j a v a 2 s . c o m public Map<Vector3i, Boolean> getWorldEntries() { Map<Vector3i, Boolean> result = Maps.newLinkedHashMap(); for (Entry<Vector3i, Boolean> entry : relData.entrySet()) { Vector3i relPos = entry.getKey(); Vector3i worldPos = relativeToWorld(relPos.x, relPos.y, relPos.z); result.put(worldPos, entry.getValue()); } return result; }
From source file:com.nesscomputing.jersey.filter.BodySizeLimitResourceFilterFactory.java
@Override public List<ResourceFilter> create(AbstractMethod am) { BodySizeLimit annotation = ObjectUtils.firstNonNull(am.getAnnotation(BodySizeLimit.class), am.getResource().getAnnotation(BodySizeLimit.class)); final AbstractConfiguration ac = config.getConfiguration(); final Method realMethod = am.getMethod(); Class<?> resourceClass = am.getResource().getResourceClass(); Map<String, Long> foundValues = Maps.newLinkedHashMap(); do {/*from w w w . java 2s . co m*/ final String classConfigKey = "ness.filter.max-body-size." + resourceClass.getName(); try { resourceClass.getMethod(realMethod.getName(), realMethod.getParameterTypes()); } catch (NoSuchMethodException | SecurityException e) { LOG.trace(e); continue; } final String methodKey = classConfigKey + "." + realMethod.getName(); foundValues.put(methodKey, ac.getLong(methodKey, null)); foundValues.put(classConfigKey, ac.getLong(classConfigKey, null)); } while ((resourceClass = resourceClass.getSuperclass()) != null); if (annotation != null) { foundValues.put("annotation " + annotation, annotation.value()); } foundValues.put("default", defaultSizeLimit); for (Entry<String, Long> e : foundValues.entrySet()) { final Long value = e.getValue(); if (value != null) { String message = "[%s] => %s"; Object[] args = { Joiner.on("], [").withKeyValueSeparator(" = ").useForNull("null").join(foundValues), value }; if (value != defaultSizeLimit || annotation != null) { LOG.debug(message, args); } else { LOG.trace(message, args); } return Collections.<ResourceFilter>singletonList(new Filter(value)); } } throw new IllegalStateException("No value found for " + am + ": " + foundValues); }
From source file:com.cinchapi.concourse.util.Transformers.java
/** * Transform each of the values in the {@code original} with the * {@code function}./*from w w w . ja v a2 s .c o m*/ * * @param original * @param function * @return the transformed Map */ public static <K, V, V2> Map<K, V2> transformMapValues(Map<K, V> original, Function<V, V2> function) { Map<K, V2> transformed = Maps.newLinkedHashMap(); for (Map.Entry<K, V> entry : original.entrySet()) { transformed.put(entry.getKey(), function.apply(entry.getValue())); } return transformed; }
From source file:org.eclipse.xtext.resource.containers.StateBasedContainer.java
@Override protected Map<URI, IResourceDescription> doGetUriToDescription() { Map<URI, IResourceDescription> result = Maps.newLinkedHashMap(); for (URI uri : state.getContents()) { IResourceDescription description = getDescriptions().getResourceDescription(uri); if (description != null) result.put(uri, description); }/* www. j a va2 s . com*/ return result; }
From source file:org.apache.rya.indexing.mongodb.pcj.MongoPcjIndexSetProvider.java
@Override protected List<ExternalTupleSet> getIndices() throws PcjIndexSetException { try {/*www . jav a2 s . co m*/ final StatefulMongoDBRdfConfiguration mongoConf = (StatefulMongoDBRdfConfiguration) conf; final MongoClient client = mongoConf.getMongoClient(); final MongoPcjDocuments pcjDocs = new MongoPcjDocuments(client, mongoConf.getRyaInstanceName()); List<String> documents = null; documents = mongoConf.getPcjTables(); // this maps associates pcj document name with pcj sparql query final Map<String, String> indexDocuments = Maps.newLinkedHashMap(); try (final PrecomputedJoinStorage storage = new MongoPcjStorage(client, mongoConf.getRyaInstanceName())) { final boolean docsProvided = documents != null && !documents.isEmpty(); if (docsProvided) { // if tables provided, associate table name with sparql for (final String doc : documents) { indexDocuments.put(doc, storage.getPcjMetadata(doc).getSparql()); } } else if (hasRyaDetails()) { // If this is a newer install of Rya, and it has PCJ Details, then // use those. final List<String> ids = storage.listPcjs(); for (final String pcjId : ids) { indexDocuments.put(pcjId, storage.getPcjMetadata(pcjId).getSparql()); } } else { // Otherwise figure it out by getting document IDs. documents = pcjDocs.listPcjDocuments(); for (final String pcjId : documents) { if (pcjId.startsWith("INDEX")) { indexDocuments.put(pcjId, pcjDocs.getPcjMetadata(pcjId).getSparql()); } } } } final List<ExternalTupleSet> index = Lists.newArrayList(); if (indexDocuments.isEmpty()) { log.info("No Index found"); } else { for (final String pcjID : indexDocuments.keySet()) { final String indexSparqlString = indexDocuments.get(pcjID); index.add(new MongoPcjQueryNode(indexSparqlString, pcjID, pcjDocs)); } } return index; } catch (final PCJStorageException | MalformedQueryException e) { throw new PcjIndexSetException("Failed to get indicies for this PCJ index.", e); } }
From source file:org.jetbrains.jet.lang.resolve.calls.inference.ConstraintsUtil.java
@NotNull public static Collection<TypeSubstitutor> getSubstitutorsForConflictingParameters( @NotNull ConstraintSystem constraintSystem) { TypeParameterDescriptor firstConflictingParameter = getFirstConflictingParameter(constraintSystem); if (firstConflictingParameter == null) return Collections.emptyList(); Collection<JetType> conflictingTypes = getValues( constraintSystem.getTypeConstraints(firstConflictingParameter)); ArrayList<Map<TypeConstructor, TypeProjection>> substitutionContexts = Lists.newArrayList(); for (JetType type : conflictingTypes) { Map<TypeConstructor, TypeProjection> context = Maps.newLinkedHashMap(); context.put(firstConflictingParameter.getTypeConstructor(), new TypeProjection(type)); substitutionContexts.add(context); }/*from w w w. j av a2s.c o m*/ for (TypeParameterDescriptor typeParameter : constraintSystem.getTypeVariables()) { if (typeParameter == firstConflictingParameter) continue; JetType safeType = getSafeValue(constraintSystem, typeParameter); for (Map<TypeConstructor, TypeProjection> context : substitutionContexts) { TypeProjection typeProjection = new TypeProjection(safeType); context.put(typeParameter.getTypeConstructor(), typeProjection); } } Collection<TypeSubstitutor> typeSubstitutors = Lists.newArrayList(); for (Map<TypeConstructor, TypeProjection> context : substitutionContexts) { typeSubstitutors.add(TypeSubstitutor.create(context)); } return typeSubstitutors; }