當前位置: 首頁>>代碼示例>>Java>>正文


Java ImmutableListMultimap類代碼示例

本文整理匯總了Java中com.google.common.collect.ImmutableListMultimap的典型用法代碼示例。如果您正苦於以下問題:Java ImmutableListMultimap類的具體用法?Java ImmutableListMultimap怎麽用?Java ImmutableListMultimap使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ImmutableListMultimap類屬於com.google.common.collect包,在下文中一共展示了ImmutableListMultimap類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: runTasks

import com.google.common.collect.ImmutableListMultimap; //導入依賴的package包/類
public void runTasks() {
    Multimaps.asMap(ImmutableListMultimap.copyOf(taskQueue)).values().forEach(tasks -> {
        int size = tasks.size();
        while (size > 0) {
            int last = size - 1;
            Task<?> current = tasks.get(last);
            if (current.done()) {
                taskQueue.get(current.getClass()).remove(last);
                size--;
                continue;
            }
            current.tick();
            return;
        }
    });
}
 
開發者ID:kenzierocks,項目名稱:HardVox,代碼行數:17,代碼來源:TaskManager.java

示例2: testProcess

import com.google.common.collect.ImmutableListMultimap; //導入依賴的package包/類
@Test
public void testProcess() {
    String taskName = "task";
    JavaUtils.setFieldWithoutCheckedException(
            ReflectionUtils.findField(TaskProcessorRegistryImpl.class, "taskProcessorMap")
            , registry
            , ImmutableListMultimap.builder()
                                   .put(taskName, Pair.of(Objects.class, taskProcessor))
                                   .build()
    );

    registry.process(taskName, "some body");

    Mockito.verify(taskMapper, Mockito.atLeastOnce()).map(Mockito.anyString(), Mockito.any());
    Mockito.verify(taskProcessor, Mockito.atLeastOnce()).process(Mockito.any());
}
 
開發者ID:EsikAntony,項目名稱:camunda-task-dispatcher,代碼行數:17,代碼來源:TaskProcessorRegistryImplTest.java

示例3: modifyTypes

import com.google.common.collect.ImmutableListMultimap; //導入依賴的package包/類
/** Applies the supplied modifications to the GraphQLTypes. */
private static BiMap<String, GraphQLType> modifyTypes(
    BiMap<String, GraphQLType> mapping,
    ImmutableListMultimap<String, TypeModification> modifications) {
  BiMap<String, GraphQLType> result = HashBiMap.create(mapping.size());
  for (String key : mapping.keySet()) {
    if (mapping.get(key) instanceof GraphQLObjectType) {
      GraphQLObjectType val = (GraphQLObjectType) mapping.get(key);
      if (modifications.containsKey(key)) {
        for (TypeModification modification : modifications.get(key)) {
          val = modification.apply(val);
        }
      }
      result.put(key, val);
    } else {
      result.put(key, mapping.get(key));
    }
  }
  return result;
}
 
開發者ID:google,項目名稱:rejoiner,代碼行數:21,代碼來源:ProtoRegistry.java

示例4: withParameter

import com.google.common.collect.ImmutableListMultimap; //導入依賴的package包/類
/**
 * <em>Replaces</em> all parameters with the given attribute with a single parameter with the
 * given value. If multiple parameters with the same attributes are necessary use
 * {@link #withParameters}. Prefer {@link #withCharset} for setting the {@code charset} parameter
 * when using a {@link Charset} object.
 *
 * @throws IllegalArgumentException if either {@code attribute} or {@code value} is invalid
 */
public MediaType withParameter(String attribute, String value) {
  checkNotNull(attribute);
  checkNotNull(value);
  String normalizedAttribute = normalizeToken(attribute);
  ImmutableListMultimap.Builder<String, String> builder = ImmutableListMultimap.builder();
  for (Entry<String, String> entry : parameters.entries()) {
    String key = entry.getKey();
    if (!normalizedAttribute.equals(key)) {
      builder.put(key, entry.getValue());
    }
  }
  builder.put(normalizedAttribute, normalizeParameterValue(normalizedAttribute, value));
  MediaType mediaType = new MediaType(type, subtype, builder.build());
  // if the attribute isn't charset, we can just inherit the current parsedCharset
  if (!normalizedAttribute.equals(CHARSET_ATTRIBUTE)) {
    mediaType.parsedCharset = this.parsedCharset;
  }
  // Return one of the constants if the media type is a known type.
  return MoreObjects.firstNonNull(KNOWN_TYPES.get(mediaType), mediaType);
}
 
開發者ID:zugzug90,項目名稱:guava-mock,代碼行數:29,代碼來源:MediaType.java

示例5: create

import com.google.common.collect.ImmutableListMultimap; //導入依賴的package包/類
private static MediaType create(
    String type, String subtype, Multimap<String, String> parameters) {
  checkNotNull(type);
  checkNotNull(subtype);
  checkNotNull(parameters);
  String normalizedType = normalizeToken(type);
  String normalizedSubtype = normalizeToken(subtype);
  checkArgument(
      !WILDCARD.equals(normalizedType) || WILDCARD.equals(normalizedSubtype),
      "A wildcard type cannot be used with a non-wildcard subtype");
  ImmutableListMultimap.Builder<String, String> builder = ImmutableListMultimap.builder();
  for (Entry<String, String> entry : parameters.entries()) {
    String attribute = normalizeToken(entry.getKey());
    builder.put(attribute, normalizeParameterValue(attribute, entry.getValue()));
  }
  MediaType mediaType = new MediaType(normalizedType, normalizedSubtype, builder.build());
  // Return one of the constants if the media type is a known type.
  return MoreObjects.firstNonNull(KNOWN_TYPES.get(mediaType), mediaType);
}
 
開發者ID:zugzug90,項目名稱:guava-mock,代碼行數:20,代碼來源:MediaType.java

示例6: getAttachmentsForItems

import com.google.common.collect.ImmutableListMultimap; //導入依賴的package包/類
@Override
@Transactional(propagation = Propagation.MANDATORY)
public ListMultimap<Item, Attachment> getAttachmentsForItems(Collection<Item> items)
{
	if( items.isEmpty() )
	{
		return ImmutableListMultimap.of();
	}
	List<Attachment> attachments = getHibernateTemplate().findByNamedParam(
		"select a from Item i join i.attachments a where i in (:items) order by index(a) ASC", "items", items);
	ListMultimap<Item, Attachment> multiMap = ArrayListMultimap.create();
	for( Attachment attachment : attachments )
	{
		multiMap.put(attachment.getItem(), attachment);
	}
	return multiMap;
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:18,代碼來源:ItemDaoImpl.java

示例7: getAttachmentsForItemIds

import com.google.common.collect.ImmutableListMultimap; //導入依賴的package包/類
@Override
@Transactional(propagation = Propagation.MANDATORY)
public ListMultimap<Long, Attachment> getAttachmentsForItemIds(Collection<Long> ids)
{
	if( ids.isEmpty() )
	{
		return ImmutableListMultimap.of();
	}
	List<Object[]> attachments = getHibernateTemplate().findByNamedParam(
		"select a, i.id from Item i join i.attachments a where i.id in (:items) order by index(a) ASC", "items",
		ids);
	ListMultimap<Long, Attachment> multiMap = ArrayListMultimap.create();
	for( Object[] attachmentRow : attachments )
	{
		multiMap.put((Long) attachmentRow[1], (Attachment) attachmentRow[0]);
	}
	return multiMap;
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:19,代碼來源:ItemDaoImpl.java

示例8: getHistoryForItemIds

import com.google.common.collect.ImmutableListMultimap; //導入依賴的package包/類
@Override
@Transactional(propagation = Propagation.MANDATORY)
public ListMultimap<Long, HistoryEvent> getHistoryForItemIds(Collection<Long> ids)
{
	if( ids.isEmpty() )
	{
		return ImmutableListMultimap.of();
	}
	List<Object[]> history = getHibernateTemplate().findByNamedParam(
		"select h, i.id from Item i join i.history h where i.id in (:items) order by index(h)", "items", ids);
	ListMultimap<Long, HistoryEvent> multiMap = ArrayListMultimap.create();
	for( Object[] historyRow : history )
	{
		multiMap.put((Long) historyRow[1], (HistoryEvent) historyRow[0]);
	}
	return multiMap;
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:18,代碼來源:ItemDaoImpl.java

示例9: getNavigationNodesForItemIds

import com.google.common.collect.ImmutableListMultimap; //導入依賴的package包/類
@Override
@Transactional(propagation = Propagation.MANDATORY)
public ListMultimap<Long, ItemNavigationNode> getNavigationNodesForItemIds(Collection<Long> ids)
{
	if( ids.isEmpty() )
	{
		return ImmutableListMultimap.of();
	}
	List<Object[]> node = getHibernateTemplate().findByNamedParam(
		"select n, i.id from ItemNavigationNode n join n.item i where i.id in (:items) order by n.index ASC",
		"items", ids);
	ListMultimap<Long, ItemNavigationNode> multiMap = ArrayListMultimap.create();
	for( Object[] nodeRow : node )
	{
		multiMap.put((Long) nodeRow[1], (ItemNavigationNode) nodeRow[0]);
	}
	return multiMap;
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:19,代碼來源:ItemDaoImpl.java

示例10: getDrmAcceptancesForItemIds

import com.google.common.collect.ImmutableListMultimap; //導入依賴的package包/類
@Override
public ListMultimap<Long, DrmAcceptance> getDrmAcceptancesForItemIds(Collection<Long> itemIds)
{
	if( itemIds.isEmpty() )
	{
		return ImmutableListMultimap.of();
	}
	final List<Object[]> drmAcceptances = getHibernateTemplate().findByNamedParam(
		"select d, item.id from DrmAcceptance d where item.id in (:items) order by d.date DESC", "items", itemIds);
	final ListMultimap<Long, DrmAcceptance> multiMap = ArrayListMultimap.create();
	for( Object[] asseptRow : drmAcceptances )
	{
		multiMap.put((Long) asseptRow[1], (DrmAcceptance) asseptRow[0]);
	}
	return multiMap;
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:17,代碼來源:ItemDaoImpl.java

示例11: getCommentsForItems

import com.google.common.collect.ImmutableListMultimap; //導入依賴的package包/類
@SuppressWarnings("unchecked")
@Override
@Transactional(propagation = Propagation.MANDATORY)
public Multimap<Long, Comment> getCommentsForItems(Collection<Long> itemIds)
{
	if( itemIds.isEmpty() )
	{
		return ImmutableListMultimap.of();
	}
	List<Object[]> attachments = getHibernateTemplate()
		.findByNamedParam("select c, i.id from Item i join i.comments c where i.id in (:items)", "items", itemIds);
	ListMultimap<Long, Comment> multiMap = ArrayListMultimap.create();
	for( Object[] attachmentRow : attachments )
	{
		multiMap.put((Long) attachmentRow[1], (Comment) attachmentRow[0]);
	}
	return multiMap;
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:19,代碼來源:ItemCommentDaoImpl.java

示例12: withParameter

import com.google.common.collect.ImmutableListMultimap; //導入依賴的package包/類
/**
 * <em>Replaces</em> all parameters with the given attribute with a single parameter with the
 * given value. If multiple parameters with the same attributes are necessary use
 * {@link #withParameters}. Prefer {@link #withCharset} for setting the {@code charset} parameter
 * when using a {@link Charset} object.
 *
 * @throws IllegalArgumentException if either {@code attribute} or {@code value} is invalid
 */
public MediaType withParameter(String attribute, String value) {
  checkNotNull(attribute);
  checkNotNull(value);
  String normalizedAttribute = normalizeToken(attribute);
  ImmutableListMultimap.Builder<String, String> builder = ImmutableListMultimap.builder();
  for (Entry<String, String> entry : parameters.entries()) {
    String key = entry.getKey();
    if (!normalizedAttribute.equals(key)) {
      builder.put(key, entry.getValue());
    }
  }
  builder.put(normalizedAttribute, normalizeParameterValue(normalizedAttribute, value));
  MediaType mediaType = new MediaType(type, subtype, builder.build());
  // Return one of the constants if the media type is a known type.
  return MoreObjects.firstNonNull(KNOWN_TYPES.get(mediaType), mediaType);
}
 
開發者ID:paul-hammant,項目名稱:googles-monorepo-demo,代碼行數:25,代碼來源:MediaType.java

示例13: get

import com.google.common.collect.ImmutableListMultimap; //導入依賴的package包/類
@Override
public MultimapResource<K> get() {
    ListMultimap<String, String> multimap = ArrayListMultimap.create();
    MultimapResource<K> resource = new MultimapResource<>(key);
    try (BufferedReader reader = new BufferedReader(new InputStreamReader(path.openStream()))) {
        String line;
        while ((line = reader.readLine()) != null) {
            line = line.trim();
            if (line.trim().isEmpty()) {
                continue;
            }
            List<String> fields = Arrays.asList(line.split("\t"));
            apply(fields, multimap);
        }
    } catch (Exception e) {
        throw new RuntimeException("Error initializing TSV resource.", e);
    }
    resource.multimap(ImmutableListMultimap.copyOf(multimap));
    resource.mappingFunction(mappingFunction);
    return resource;
}
 
開發者ID:clearwsd,項目名稱:clearwsd,代碼行數:22,代碼來源:TsvResourceInitializer.java

示例14: provideParameterMap

import com.google.common.collect.ImmutableListMultimap; //導入依賴的package包/類
/**
 * Provides an immutable representation of the servlet request parameters.
 *
 * <p>This performs a shallow copy of the {@code Map<String, String[]>} data structure from the
 * servlets API, each time this is provided. This is almost certainly less expensive than the
 * thread synchronization expense of {@link javax.inject.Singleton @Singleton}.
 *
 * <p><b>Note:</b> If a parameter is specified without a value, e.g. {@code /foo?lol} then an
 * empty string value is assumed, since Guava's multimap doesn't permit {@code null} mappings.
 *
 * @see HttpServletRequest#getParameterMap()
 */
@Provides
@ParameterMap
static ImmutableListMultimap<String, String> provideParameterMap(HttpServletRequest req) {
  ImmutableListMultimap.Builder<String, String> params = new ImmutableListMultimap.Builder<>();
  @SuppressWarnings("unchecked")  // Safe by specification.
  Map<String, String[]> original = req.getParameterMap();
  for (Map.Entry<String, String[]> param : original.entrySet()) {
    if (param.getValue().length == 0) {
      params.put(param.getKey(), "");
    } else {
      params.putAll(param.getKey(), param.getValue());
    }
  }
  return params.build();
}
 
開發者ID:google,項目名稱:nomulus,代碼行數:28,代碼來源:RequestModule.java

示例15: populatesTransaction

import com.google.common.collect.ImmutableListMultimap; //導入依賴的package包/類
@Test
public void populatesTransaction() throws Exception {
    final ByteArrayInputStream inputStream = new ByteArrayInputStream("".getBytes());
    final Payee payee = new Payee();
    final Account account = new Account();
    Security security = new Security();
    when(importFile.getAccount()).thenReturn(account);
    when(importFile.parse(inputStream)).thenReturn(singletonList(
            ImmutableListMultimap.of(dateField, "01/15/1990", payeeField, PAYEE_NAME, securityField, SECURITY_NAME)));
    ImportContext context = new GroupedDetailImportContext(importFile, payeeMapper, securityMapper, categoryMapper);
    when(payeeMapper.get(PAYEE_NAME)).thenReturn(payee);
    when(securityMapper.get(SECURITY_NAME)).thenReturn(security);

    List<Transaction> transactions = context.parseTransactions(inputStream);

    assertThat(transactions).hasSize(1);
    assertThat(transactions.get(0).getAccount()).isSameAs(account);
    assertThat(transactions.get(0).getDate()).isEqualTo(new SimpleDateFormat("yyyy/MM/dd").parse("1990/01/15"));
    assertThat(transactions.get(0).getPayee()).isSameAs(payee);
    assertThat(transactions.get(0).getSecurity()).isSameAs(security);
}
 
開發者ID:jonestimd,項目名稱:finances,代碼行數:22,代碼來源:GroupedDetailImportContextTest.java


注:本文中的com.google.common.collect.ImmutableListMultimap類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。