本文整理匯總了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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) {}
}
示例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());
}
示例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();
}
示例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();
}
示例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()
);
}
示例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);
}
示例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);
}
示例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());
}
示例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();
}
}