当前位置: 首页>>代码示例>>Java>>正文


Java ImmutableListMultimap.of方法代码示例

本文整理汇总了Java中com.google.common.collect.ImmutableListMultimap.of方法的典型用法代码示例。如果您正苦于以下问题:Java ImmutableListMultimap.of方法的具体用法?Java ImmutableListMultimap.of怎么用?Java ImmutableListMultimap.of使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.common.collect.ImmutableListMultimap的用法示例。


在下文中一共展示了ImmutableListMultimap.of方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: testWithParameters_invalidAttribute

import com.google.common.collect.ImmutableListMultimap; //导入方法依赖的package包/类
public void testWithParameters_invalidAttribute() {
  MediaType mediaType = MediaType.parse("text/plain");
  ImmutableListMultimap<String, String> parameters =
      ImmutableListMultimap.of("a", "1", "@", "2", "b", "3");
  try {
    mediaType.withParameters(parameters);
    fail();
  } catch (IllegalArgumentException expected) {}
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:10,代码来源:MediaTypeTest.java

示例8: testAvroRoundTrip

import com.google.common.collect.ImmutableListMultimap; //导入方法依赖的package包/类
@Test
public void testAvroRoundTrip() throws Exception {
  String file = RESOURCES_DIR + "/test-documents" + "/sample-statuses-20120906-141433.avro";
  testDocumentTypesInternal(file);
  QueryResponse rsp = query("*:*");
  Iterator<SolrDocument> iter = rsp.getResults().iterator();
  ListMultimap<String, String> expectedFieldValues;
  expectedFieldValues = ImmutableListMultimap.of("id", "1234567890", "text", "sample tweet one",
                                                 "user_screen_name", "fake_user1");
  assertEquals(expectedFieldValues, next(iter));
  expectedFieldValues = ImmutableListMultimap.of("id", "2345678901", "text", "sample tweet two",
                                                 "user_screen_name", "fake_user2");
  assertEquals(expectedFieldValues, next(iter));
  assertFalse(iter.hasNext());
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:16,代码来源:TestMorphlineSolrSink.java

示例9: lockOrDetectPotentialLocksCycle

import com.google.common.collect.ImmutableListMultimap; //导入方法依赖的package包/类
@Override public ListMultimap<Long, ID> lockOrDetectPotentialLocksCycle() {
  final long currentThreadId = Thread.currentThread().getId();
  synchronized (CycleDetectingLockFactory.class) {
    checkState();
    ListMultimap<Long, ID> locksInCycle = detectPotentialLocksCycle();
    if (!locksInCycle.isEmpty()) {
      // potential deadlock is found, we don't try to take this lock
      return locksInCycle;
    }

    lockThreadIsWaitingOn.put(currentThreadId, this);
  }

  // this may be blocking, but we don't expect it to cause a deadlock
  lockImplementation.lock();

  synchronized (CycleDetectingLockFactory.class) {
    // current thread is no longer waiting on this lock
    lockThreadIsWaitingOn.remove(currentThreadId);
    checkState();

    // mark it as owned by us
    lockOwnerThreadId = currentThreadId;
    lockReentranceCount++;
    // add this lock to the list of locks owned by a current thread
    locksOwnedByThread.put(currentThreadId, this);
  }
  // no deadlock is found, locking successful
  return ImmutableListMultimap.of();
}
 
开发者ID:maetrive,项目名称:businessworks,代码行数:31,代码来源:CycleDetectingLock.java

示例10: detectPotentialLocksCycle

import com.google.common.collect.ImmutableListMultimap; //导入方法依赖的package包/类
/**
 * Algorithm to detect a potential lock cycle.
 *
 * For lock's thread owner check which lock is it trying to take.
 * Repeat recursively. When current thread is found a potential cycle is detected.
 *
 * @see CycleDetectingLock#lockOrDetectPotentialLocksCycle()
 */
private ListMultimap<Long, ID> detectPotentialLocksCycle() {
  final long currentThreadId = Thread.currentThread().getId();
  if (lockOwnerThreadId == null || lockOwnerThreadId == currentThreadId) {
    // if nobody owns this lock, lock cycle is impossible
    // if a current thread owns this lock, we let Guice to handle it
    return ImmutableListMultimap.of();
  }

  ListMultimap<Long, ID> potentialLocksCycle = Multimaps.newListMultimap(
      new LinkedHashMap<Long, Collection<ID>>(),
      new Supplier<List<ID>>() {
        @Override
        public List<ID> get() {
          return Lists.newArrayList();
        }
      });
  // lock that is a part of a potential locks cycle, starts with current lock
  ReentrantCycleDetectingLock lockOwnerWaitingOn = this;
  // try to find a dependency path between lock's owner thread and a current thread
  while (lockOwnerWaitingOn != null && lockOwnerWaitingOn.lockOwnerThreadId != null) {
    Long threadOwnerThreadWaits = lockOwnerWaitingOn.lockOwnerThreadId;
    // in case locks cycle exists lock we're waiting for is part of it
    potentialLocksCycle.putAll(threadOwnerThreadWaits,
        getAllLockIdsAfter(threadOwnerThreadWaits, lockOwnerWaitingOn));

    if (threadOwnerThreadWaits == currentThreadId) {
      // owner thread depends on current thread, cycle detected
      return potentialLocksCycle;
    }
    // going for the next thread we wait on indirectly
    lockOwnerWaitingOn = lockThreadIsWaitingOn.get(threadOwnerThreadWaits);
  }
  // no dependency path from an owner thread to a current thread
  return ImmutableListMultimap.of();
}
 
开发者ID:maetrive,项目名称:businessworks,代码行数:44,代码来源:CycleDetectingLock.java

示例11: main

import com.google.common.collect.ImmutableListMultimap; //导入方法依赖的package包/类
public static void main(String[] asdf) {
    final ConvertersMap convertersMap = new ConvertersMapBuilderImpl().build();
    new HeadersImpl(
        ImmutableListMultimap.of(),
        convertersMap.getMap()
    );
}
 
开发者ID:codefacts,项目名称:Elastic-Components,代码行数:8,代码来源:ConvertersMapBuilderImpl.java

示例12: SingularityDeployStatistics

import com.google.common.collect.ImmutableListMultimap; //导入方法依赖的package包/类
@JsonCreator
public SingularityDeployStatistics(@JsonProperty("requestId") String requestId, @JsonProperty("deployId") String deployId, @JsonProperty("numSuccess") int numSuccess, @JsonProperty("numFailures") int numFailures,
    @JsonProperty("numSequentialRetries") int numSequentialRetries, @JsonProperty("lastFinishAt") Optional<Long> lastFinishAt, @JsonProperty("lastTaskState") Optional<ExtendedTaskState> lastTaskState,
    @JsonProperty("instanceSequentialFailureTimestamps") ListMultimap<Integer, Long> instanceSequentialFailureTimestamps, @JsonProperty("numTasks") int numTasks, @JsonProperty("averageRuntimeMillis")  Optional<Long> averageRuntimeMillis) {
  this.requestId = requestId;
  this.deployId = deployId;
  this.numSuccess = numSuccess;
  this.numFailures = numFailures;
  this.lastFinishAt = lastFinishAt;
  this.lastTaskState = lastTaskState;
  this.numSequentialRetries = numSequentialRetries;
  this.numTasks = numTasks;
  this.averageRuntimeMillis = averageRuntimeMillis;
  this.instanceSequentialFailureTimestamps = instanceSequentialFailureTimestamps == null ?  ImmutableListMultimap.<Integer, Long> of() : ImmutableListMultimap.copyOf(instanceSequentialFailureTimestamps);
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:16,代码来源:SingularityDeployStatistics.java

示例13: fromNullable

import com.google.common.collect.ImmutableListMultimap; //导入方法依赖的package包/类
public static final LookupValuesList fromNullable(final LookupValue lookupValue)
{
	if (lookupValue == null)
	{
		return EMPTY;
	}

	final ImmutableListMultimap<Object, LookupValue> valuesById = ImmutableListMultimap.of(lookupValue.getId(), lookupValue);
	final Map<String, String> debugProperties = ImmutableMap.of();
	return new LookupValuesList(valuesById, debugProperties);
}
 
开发者ID:metasfresh,项目名称:metasfresh-webui-api,代码行数:12,代码来源:LookupValuesList.java

示例14: testRetrievePickingSlotRows_No_HUs_show_PickingSlotsOnly

import com.google.common.collect.ImmutableListMultimap; //导入方法依赖的package包/类
/**
 * Verifies {@link PickingSlotViewRepository#retrieveRows(PickingSlotRepoQuery)}<br>
 * when there are no HUs (no picking candidates) assigned to a picking slot, but still the picking slot itself shall be shown.
 */
@Test
public void testRetrievePickingSlotRows_No_HUs_show_PickingSlotsOnly()
{
	final I_M_ShipmentSchedule shipmentSchedule = newInstance(I_M_ShipmentSchedule.class);
	save(shipmentSchedule);

	final I_M_PickingSlot pickingSlot = newInstance(I_M_PickingSlot.class);
	pickingSlot.setIsPickingRackSystem(true);
	save(pickingSlot);

	final PickingSlotRepoQuery query = PickingSlotRepoQuery.of(shipmentSchedule.getM_ShipmentSchedule_ID());

	// @formatter:off return an empty list
	new Expectations() {{ pickingHUsRepo.retrievePickedHUsIndexedByPickingSlotId(query); result = ImmutableListMultimap.of(); }};
	// @formatter:on

	final NullLookupDataSource nullDS = NullLookupDataSource.instance;

	final PickingSlotViewRepository pickingSlotViewRepository = new PickingSlotViewRepository(pickingHUsRepo, () -> nullDS, () -> nullDS, () -> nullDS);
	final List<PickingSlotRow> pickingSlotRows = pickingSlotViewRepository.retrievePickingSlotRows(query);

	assertThat(pickingSlotRows.size(), is(1)); // even if there are no HUs, there shall still be a row for our picking slot.

	final PickingSlotRow pickingSlotRow = pickingSlotRows.get(0);
	assertThat(pickingSlotRow.getType()).isEqualTo(PickingSlotRowType.forPickingSlotRow());
}
 
开发者ID:metasfresh,项目名称:metasfresh-webui-api,代码行数:31,代码来源:PickingSlotViewRepositoryTests.java

示例15: load

import com.google.common.collect.ImmutableListMultimap; //导入方法依赖的package包/类
@Override
public ImmutableListMultimap<String, P> load(U user) throws Exception {
    try {
        final Collection<P> policies = getPoliciesFor(user);
        return Multimaps.index(policies, getPolicyName);
    } catch (Exception e) {
        logger.error("Error while retrieving policies for user {}", user, e);
        return ImmutableListMultimap.of();
    }
}
 
开发者ID:TechGapItalia,项目名称:tgi-commons,代码行数:11,代码来源:GuavaBasedSecurityCache.java


注:本文中的com.google.common.collect.ImmutableListMultimap.of方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。