List of usage examples for com.google.common.collect ImmutableListMultimap of
@SuppressWarnings("unchecked") public static <K, V> ImmutableListMultimap<K, V> of()
From source file:com.google.gerrit.httpd.rpc.doc.QueryDocumentationFilter.java
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest req = (HttpServletRequest) request; if ("GET".equals(req.getMethod()) && !Strings.isNullOrEmpty(req.getParameter("q"))) { HttpServletResponse rsp = (HttpServletResponse) response; try {//w ww.java 2 s .c o m List<DocResult> result = searcher.doQuery(request.getParameter("q")); RestApiServlet.replyJson(req, rsp, ImmutableListMultimap.of(), result); } catch (DocQueryException e) { log.error("Doc search failed:", e); rsp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } } else { chain.doFilter(request, response); } }
From source file:org.sosy_lab.cpachecker.core.counterexample.RichModel.java
private RichModel() { mModel = ImmutableMap.of(); assignments = new CFAPathWithAssumptions(); assignableTermsPerCFAEdge = ImmutableListMultimap.of(); }
From source file:com.google.devtools.moe.client.gson.AutoValueTypeAdapter.java
@VisibleForTesting static Object emptyAggregationFor(Field field) { Class<?> type = field.getType(); if (type.isAssignableFrom(ImmutableSet.class)) { return ImmutableSet.of(); } else if (type.isAssignableFrom(ImmutableMap.class)) { return ImmutableMap.of(); } else if (type.isAssignableFrom(ImmutableList.class)) { return ImmutableList.of(); } else if (type.isAssignableFrom(ImmutableListMultimap.class)) { return ImmutableListMultimap.of(); } else if (type.isAssignableFrom(ImmutableSetMultimap.class)) { return ImmutableSetMultimap.of(); } else if (type.isAssignableFrom(ImmutableMultiset.class)) { return ImmutableMultiset.of(); }/*from ww w. j ava2s .c o m*/ try { // Not a known aggregate type or supertype, so we'll play their game and see if it works. return type.newInstance(); } catch (InstantiationException | IllegalAccessException e) { // Don't know how to make this type, so don't. return null; } }
From source file:com.facebook.presto.sql.planner.optimizations.MergeIdenticalWindows.java
public PlanNode optimize(PlanNode plan, Session session, Map<Symbol, Type> types, SymbolAllocator symbolAllocator, PlanNodeIdAllocator idAllocator) { // ImmutableListMultimap preserves order of window nodes return SimplePlanRewriter.rewriteWith(new Rewriter(), plan, ImmutableListMultimap.of()); }
From source file:org.sosy_lab.cpachecker.core.counterexample.RichModel.java
public RichModel(Map<AssignableTerm, Object> content) { mModel = ImmutableMap.copyOf(content); assignments = new CFAPathWithAssumptions(); assignableTermsPerCFAEdge = ImmutableListMultimap.of(); }
From source file:com.google.gerrit.server.change.NotifyUtil.java
public ListMultimap<RecipientType, Account.Id> resolveAccounts( @Nullable Map<RecipientType, NotifyInfo> notifyDetails) throws OrmException, BadRequestException { if (isNullOrEmpty(notifyDetails)) { return ImmutableListMultimap.of(); }//from w w w . j ava 2 s . co m ListMultimap<RecipientType, Account.Id> m = null; for (Entry<RecipientType, NotifyInfo> e : notifyDetails.entrySet()) { List<String> accounts = e.getValue().accounts; if (accounts != null) { if (m == null) { m = MultimapBuilder.hashKeys().arrayListValues().build(); } m.putAll(e.getKey(), find(dbProvider.get(), accounts)); } } return m != null ? m : ImmutableListMultimap.of(); }
From source file:com.facebook.presto.sql.planner.optimizations.MergeWindows.java
@Override public PlanNode optimize(PlanNode plan, Session session, Map<Symbol, Type> types, SymbolAllocator symbolAllocator, PlanNodeIdAllocator idAllocator) { // ImmutableListMultimap preserves order of window nodes return SimplePlanRewriter.rewriteWith(new Rewriter(), plan, ImmutableListMultimap.of()); }
From source file:org.sosy_lab.cpachecker.core.counterexample.RichModel.java
private RichModel(Map<AssignableTerm, Object> content, CFAPathWithAssumptions pAssignments) { mModel = ImmutableMap.copyOf(content); assignments = pAssignments;//from w w w .ja v a 2s. c o m assignableTermsPerCFAEdge = ImmutableListMultimap.of(); }
From source file:org.sonar.server.rule.CachingRuleFinder.java
private static ImmutableListMultimap<Integer, RuleParamDto> retrieveRuleParameters(DbClient dbClient, DbSession dbSession, Set<RuleKey> ruleKeys) { if (ruleKeys.isEmpty()) { return ImmutableListMultimap.of(); }//from w w w . ja v a 2 s .c om return dbClient.ruleDao().selectRuleParamsByRuleKeys(dbSession, ruleKeys).stream() .collect(MoreCollectors.index(RuleParamDto::getRuleId)); }
From source file:io.prestosql.operator.MockExchangeRequestProcessor.java
@Override public Response handle(Request request) { if (request.getMethod().equalsIgnoreCase("DELETE")) { return new TestingResponse(HttpStatus.NO_CONTENT, ImmutableListMultimap.of(), new byte[0]); }//from ww w.j a va2 s .c o m // verify we got a data size and it parses correctly assertTrue(!request.getHeaders().get(PrestoHeaders.PRESTO_MAX_SIZE).isEmpty()); DataSize maxSize = DataSize.valueOf(request.getHeader(PrestoHeaders.PRESTO_MAX_SIZE)); assertEquals(maxSize, expectedMaxSize); RequestLocation requestLocation = new RequestLocation(request.getUri()); URI location = requestLocation.getLocation(); BufferResult result = buffers.getUnchecked(location).getPages(requestLocation.getSequenceId(), maxSize); byte[] bytes = new byte[0]; HttpStatus status; if (!result.getSerializedPages().isEmpty()) { DynamicSliceOutput sliceOutput = new DynamicSliceOutput(64); PagesSerdeUtil.writeSerializedPages(sliceOutput, result.getSerializedPages()); bytes = sliceOutput.slice().getBytes(); status = HttpStatus.OK; } else { status = HttpStatus.NO_CONTENT; } return new TestingResponse(status, ImmutableListMultimap.of(CONTENT_TYPE, PRESTO_PAGES, PRESTO_TASK_INSTANCE_ID, String.valueOf(result.getTaskInstanceId()), PRESTO_PAGE_TOKEN, String.valueOf(result.getToken()), PRESTO_PAGE_NEXT_TOKEN, String.valueOf(result.getNextToken()), PRESTO_BUFFER_COMPLETE, String.valueOf(result.isBufferComplete())), bytes); }