List of usage examples for com.google.common.collect Multimap keySet
Set<K> keySet();
From source file:com.zxy.commons.poi.excel.ExcelUtils.java
/** * multimap?table//from ww w.ja v a 2s . c om * * @param multimap multimap * @return table */ public static Table<Integer, String, String> map2table(Multimap<String, String> multimap) { Table<Integer, String, String> table = TreeBasedTable.create(); Set<String> cloumns = multimap.keySet(); for (String cloumn : cloumns) { Collection<String> values = multimap.get(cloumn); int rowIndex = 1; for (String value : values) { table.put(rowIndex, cloumn, value); rowIndex++; } } return table; }
From source file:com.ardor3d.util.scenegraph.DisplayListDelegate.java
private static void handleDisplayListDelete(final Renderer deleter, final Multimap<Object, Integer> idMap) { Object currentGLRef = null;/*from w ww .java 2s. c o m*/ // Grab the current context, if any. if (deleter != null && ContextManager.getCurrentContext() != null) { currentGLRef = ContextManager.getCurrentContext().getGlContextRep(); } // For each affected context... for (final Object glref : idMap.keySet()) { // If we have a deleter and the context is current, immediately delete if (deleter != null && glref.equals(currentGLRef)) { deleter.deleteDisplayLists(idMap.get(glref)); } // Otherwise, add a delete request to that context's render task queue. else { GameTaskQueueManager.getManager(ContextManager.getContextForRef(glref)) .render(new RendererCallable<Void>() { public Void call() throws Exception { getRenderer().deleteDisplayLists(idMap.get(glref)); return null; } }); } } }
From source file:org.apache.james.webadmin.dto.MailDto.java
private static Optional<ImmutableMap<String, HeadersDto>> fetchPerRecipientsHeaders( Set<AdditionalField> additionalFields, Mail mail) { if (!additionalFields.contains(AdditionalField.PER_RECIPIENTS_HEADERS)) { return Optional.empty(); }/*from ww w. ja va 2s.c o m*/ Multimap<MailAddress, PerRecipientHeaders.Header> headersByRecipient = mail.getPerRecipientSpecificHeaders() .getHeadersByRecipient(); return Optional .of(headersByRecipient.keySet().stream().collect(Guavate.toImmutableMap(MailAddress::asString, (address) -> fetchPerRecipientHeader(headersByRecipient, address)))); }
From source file:org.apache.beam.runners.core.construction.ExecutableStageTranslation.java
/** * Creates a human-readable name for a set of stage names that occur in a single stage. * * <p>This name reflects the nested structure of the stages, as inferred by slashes in the stage * names. Sibling stages will be listed as {A, B}, nested stages as A/B, and according to the * value of truncateSiblingComposites the nesting stops at the first level that siblings are * encountered.// ww w. j av a2 s. c o m * * <p>This is best understood via examples, of which there are several in the tests for this * class. * * @param names a list of full stage names in this fused operation * @param truncateSiblingComposites whether to recursively descent into composite operations that * have simblings, or stop the recursion at that level. * @return a single string representation of all the stages in this fused operation */ public static String generateNameFromTransformNames(Collection<String> names, boolean truncateSiblingComposites) { Multimap<String, String> groupByOuter = LinkedHashMultimap.create(); for (String name : names) { int index = name.indexOf('/'); if (index == -1) { groupByOuter.put(name, ""); } else { groupByOuter.put(name.substring(0, index), name.substring(index + 1)); } } if (groupByOuter.keySet().size() == 1) { Map.Entry<String, Collection<String>> outer = Iterables.getOnlyElement(groupByOuter.asMap().entrySet()); if (outer.getValue().size() == 1 && outer.getValue().contains("")) { // Names consisted of a single name without any slashes. return outer.getKey(); } else { // Everything is in the same outer stage, enumerate at one level down. return String.format("%s/%s", outer.getKey(), generateNameFromTransformNames(outer.getValue(), truncateSiblingComposites)); } } else { Collection<String> parts; if (truncateSiblingComposites) { // Enumerate the outer stages without their composite structure, if any. parts = groupByOuter.keySet(); } else { // Enumerate the outer stages with their composite structure, if any. parts = groupByOuter.asMap().entrySet().stream() .map(outer -> String .format("%s/%s", outer.getKey(), generateNameFromTransformNames(outer.getValue(), truncateSiblingComposites)) .replaceAll("/$", "")) .collect(Collectors.toList()); } return String.format("{%s}", Joiner.on(", ").join(parts)); } }
From source file:com.ikanow.aleph2.search_service.elasticsearch.utils.ElasticsearchHadoopUtils.java
/** Utility to time slice elasticsearch indexes * TODO (ALEPH-72): this should also be applied to the type collection * @param job_input/*from w ww . j a va 2s .c o m*/ * @param index_type_mappings * @return */ public static Optional<Stream<String>> getTimedIndexes(final AnalyticThreadJobInputBean job_input, final Multimap<String, String> index_type_mappings, final Date now) { return Optional.ofNullable(job_input.config()) .filter(cfg -> (null != cfg.time_min()) || (null != cfg.time_max())).map(cfg -> { return TimeSliceDirUtils.filterTimedDirectories( TimeSliceDirUtils.annotateTimedDirectories(index_type_mappings.keySet().stream()), TimeSliceDirUtils.getQueryTimeRange(cfg, now)); }); }
From source file:org.caleydo.view.domino.internal.NodeDataItem.java
public static void update(final Set<NodeGroup> mouseOvers, final Set<NodeGroup> selections) { final NodeDataItem i = instance; if (i == null) return;//from w w w. ja va 2 s .co m Set<NodeGroup> toShow = selections; if (!mouseOvers.isEmpty()) { toShow = mouseOvers; } String text; if (toShow.isEmpty()) { text = "No Selection"; } else { Multimap<Node, NodeGroup> nodes = HashMultimap.create(); for (NodeGroup group : toShow) { Node n = group.getNode(); nodes.put(n, group); } StringBuilder b = new StringBuilder(); for (ILabeled node : ImmutableSortedSet.orderedBy(Labels.BY_LABEL).addAll(nodes.keySet()).build()) { Node n = (Node) node; addNodeInfos(b, n, nodes.get(n)); b.append('\n'); } b.setLength(b.length() - 1); text = b.toString(); } final String t = text; Display.getDefault().asyncExec(new Runnable() { @Override public void run() { i.updateImpl(t); } }); }
From source file:jatf.common.util.ArchitectureTestUtil.java
@Nonnull public static Set<String> getAllClassesInReflections(Reflections reflections) { Set<String> result = newHashSet(); for (String key : reflections.getStore().keySet()) { Multimap<String, String> multimap = reflections.getStore().get(key); for (String name : multimap.keySet()) { Collection<String> collection = multimap.get(name); result.addAll(collection.stream().filter(item -> startsWithAnyOf(SCOPES, item)) .collect(Collectors.toList())); }//from w w w . j a v a2 s . co m } return result; }
From source file:moavns.SolucaoAleatoria.java
public static Solucao eliminarRedundancia(Solucao solucao) { Multimap<Float, Integer> colunas = TreeMultimap.create(); for (Coluna coluna : solucao.getColunas()) { Float custo = coluna.getCusto(); colunas.put((custo * (-1)), coluna.getNome()); }//from w w w .j a v a2 s . c o m Solucao testarsolucao = new Solucao(solucao); for (Float chave : colunas.keySet()) { Iterator iterador = colunas.get(chave).iterator(); while (iterador.hasNext()) { Solucao testar = new Solucao(testarsolucao); Coluna maiorcoluna = testarsolucao.getLinhasX().get(iterador.next()); testar.getLinhasCobertas().clear(); cobrirLinhas(maiorcoluna, testar); if (testar.getLinhasCobertas().size() == testar.getQtdeLinhas()) { testar.getColunas().remove(maiorcoluna); testar.setCustototal(testar.getCustototal() - maiorcoluna.getCusto()); testarsolucao = testar; } } } return testarsolucao; }
From source file:com.palantir.atlasdb.keyvalue.impl.ProfilingKeyValueService.java
private static <T> long byteSize(Multimap<Cell, T> values) { long sizeInBytes = 0; for (Cell cell : values.keySet()) { sizeInBytes += Cells.getApproxSizeOfCell(cell) + values.get(cell).size(); }/* www .j av a 2 s . c om*/ return sizeInBytes; }
From source file:com.google.errorprone.bugpatterns.ReplacementVariableFinder.java
private static ImmutableList<Fix> buildValidReplacements( Multimap<Integer, JCVariableDecl> potentialReplacements, Function<JCVariableDecl, Fix> replacementFunction) { if (potentialReplacements.isEmpty()) { return ImmutableList.of(); }/* w ww .j a va2 s. co m*/ // Take all of the potential edit-distance replacements with the same minimum distance, // then suggest them as individual fixes. return potentialReplacements.get(Collections.min(potentialReplacements.keySet())).stream() .map(replacementFunction).collect(toImmutableList()); }