List of usage examples for com.google.common.collect ArrayListMultimap create
public static <K, V> ArrayListMultimap<K, V> create()
From source file:eu.esdihumboldt.hale.common.align.merge.impl.TargetIndex.java
/** * Create a new index based on an alignment. * //from ww w . j a va2 s .c om * @param alignment the alignment */ public TargetIndex(Alignment alignment) { cells = ArrayListMultimap.create(); for (Cell cell : alignment.getCells()) { Entity target = CellUtil.getFirstEntity(cell.getTarget()); if (target != null) { EntityDefinition targetDef = AlignmentUtil.getAllDefaultEntity(target.getDefinition(), true); cells.put(targetDef, cell); } } }
From source file:com.zimbra.cs.mailbox.acl.AclPushTask.java
public static synchronized void doWork() { if (!supported) return;/*from w w w .j a v a2s . c o m*/ ZimbraLog.misc.debug("Starting pending ACL push"); Multimap<Integer, List<Integer>> currentItemIdsProcessed = ArrayListMultimap.create(); try { Date now = new Date(); Multimap<Integer, Integer> mboxIdToItemIds = DbPendingAclPush.getEntries(now); for (int mboxId : mboxIdToItemIds.keySet()) { Mailbox mbox; List<Integer> itemsProcessed = new ArrayList<Integer>(); try { mbox = MailboxManager.getInstance().getMailboxById(mboxId); } catch (ServiceException e) { ZimbraLog.misc.info("Exception occurred while getting mailbox for id %s during ACL push", mboxId, e); continue; } Collection<Integer> itemIds = mboxIdToItemIds.get(mboxId); MailItem[] items = null; try { items = mbox.getItemById(null, itemIds, MailItem.Type.UNKNOWN); } catch (MailServiceException.NoSuchItemException e) { // one or more folders no longer exist if (itemIds.size() > 1) { List<MailItem> itemList = new ArrayList<MailItem>(); for (int itemId : itemIds) { try { itemList.add(mbox.getItemById(null, itemId, MailItem.Type.UNKNOWN)); } catch (MailServiceException.NoSuchItemException ignored) { } } items = itemList.toArray(new MailItem[itemList.size()]); } } Account account = mbox.getAccount(); String[] existingSharedItems = account.getSharedItem(); Set<String> updatedSharedItems = new HashSet<String>(); for (String sharedItem : existingSharedItems) { ShareInfoData shareData = AclPushSerializer.deserialize(sharedItem); if (!itemIds.contains(shareData.getItemId())) { updatedSharedItems.add(sharedItem); } } if (items != null) { for (MailItem item : items) { if (item == null) { continue; } // for now push the Folder grants to LDAP if (!(item instanceof Folder)) { continue; } ACL acl = item.getACL(); if (acl == null) { continue; } for (ACL.Grant grant : acl.getGrants()) { updatedSharedItems.add(AclPushSerializer.serialize(item, grant)); } itemsProcessed.add(item.getId()); currentItemIdsProcessed.put(mboxId, itemsProcessed); } } account.setSharedItem(updatedSharedItems.toArray(new String[updatedSharedItems.size()])); } // for DbPendingAclPush.deleteEntries(now); } catch (ServiceException e) { ZimbraLog.misc.warn("Error during ACL push task", e); } catch (Throwable t) { //don't let exceptions kill the timer try { // We ran into runtime exception, so we want to delete records from ACL // table for processed records. deleteDbAclEntryForProcessedItems(currentItemIdsProcessed); } catch (ServiceException e) { ZimbraLog.misc.warn("Error during ACL push task and deleting ACL push entry."); } ZimbraLog.misc.warn("Error during ACL push task", t); } ZimbraLog.misc.debug("Finished pending ACL push"); }
From source file:com.twitter.common.metrics.JvmStats.java
/** * Use reflection to get optional gauges that only work in Java 1.7. *///from w w w . j a va 2s. c o m private static Multimap<String, AbstractGauge<Long>> buildJava17Gauges() { Multimap<String, AbstractGauge<Long>> gauges = ArrayListMultimap.create(); try { Class<?> bufferPoolMXBean = ClassLoader.getSystemClassLoader() .loadClass("java.lang.management.BufferPoolMXBean"); Method getPlatformMxBeans = ManagementFactory.class.getMethod("getPlatformMXBeans", Class.class); @SuppressWarnings("unchecked") List<Object> beans = (List<Object>) getPlatformMxBeans.invoke(null, bufferPoolMXBean); for (Object pool : beans) { @SuppressWarnings("unchecked") String name = (String) bufferPoolMXBean.getMethod("getName").invoke(pool); gauges.put(name, reflectMethodToGauge("count", bufferPoolMXBean, "getCount", pool)); gauges.put(name, reflectMethodToGauge("used", bufferPoolMXBean, "getMemoryUsed", pool)); gauges.put(name, reflectMethodToGauge("max", bufferPoolMXBean, "getTotalCapacity", pool)); } } catch (ClassNotFoundException ex) { // If any of the above reflection fails, it's ok. These gauges just won't be present. } catch (NoSuchMethodException ex) { // ditto } catch (IllegalAccessException ex) { // same } catch (InvocationTargetException ex) { // etc. } return gauges; }
From source file:org.apache.brooklyn.cloudfoundry.location.domain.VcapServiceRegistry.java
public static VcapServiceRegistry createRegistryFromMap(Map<?, ?> params) { ListMultimap<String, VcapService> vcapServices = ArrayListMultimap.create(); if (params != null) { for (Map.Entry<?, ?> entry : params.entrySet()) { String service = (String) entry.getKey(); List<Map<?, ?>> serviceDescriptionMaps = TypeCoercions.coerce(entry.getValue(), new TypeToken<List<Map<?, ?>>>() { });//from www . j a v a2 s . c om vcapServices.putAll(service, createVcapServices(serviceDescriptionMaps)); } } return new VcapServiceRegistry(vcapServices); }
From source file:org.apache.hadoop.hive.ql.optimizer.calcite.rules.HiveRulesRegistry.java
public HiveRulesRegistry() { this.registryVisited = HashMultimap.create(); this.registryPushedPredicates = ArrayListMultimap.create(); }
From source file:org.eclipse.incquery.viewers.runtime.specifications.ContainmentQuerySpecificationDescriptor.java
private static Multimap<PParameter, PParameter> getTraceSource(IQuerySpecification<?> specification, PAnnotation annotation) {/*from w ww. j a va2s .co m*/ Multimap<PParameter, PParameter> traces = ArrayListMultimap.create(); ParameterReference parameterSource = (ParameterReference) annotation.getFirstValue(SOURCE); ParameterReference parameterTarget = (ParameterReference) annotation.getFirstValue(TARGET); insertToTraces(specification, traces, parameterSource.getName()); insertToTraces(specification, traces, parameterTarget.getName()); return traces; }
From source file:com.eincs.decanter.container.simple.route.SimpleRouter.java
public SimpleRouter() { resultCache = CacheBuilder.newBuilder().build(new SimpleRouterCacheLoader()); services = ArrayListMultimap.create(); }
From source file:gobblin.util.PublisherUtils.java
/** * Given a {@link Multimap} of {@link Extract}s to {@link WorkUnitState}s, filter out any {@link Extract}s where all * of the corresponding {@link WorkUnitState}s do not meet the given {@link Predicate}. *//*from w ww . j ava 2s. com*/ public static Multimap<Extract, WorkUnitState> getExtractsForPredicate( Multimap<Extract, WorkUnitState> extractToWorkUnitStateMap, Predicate<WorkUnitState> predicate) { Multimap<Extract, WorkUnitState> successfulExtracts = ArrayListMultimap.create(); for (Map.Entry<Extract, Collection<WorkUnitState>> entry : extractToWorkUnitStateMap.asMap().entrySet()) { if (Iterables.all(entry.getValue(), predicate)) { successfulExtracts.putAll(entry.getKey(), entry.getValue()); } } return successfulExtracts; }
From source file:ratpack.http.internal.DefaultHttpUriBuilder.java
public DefaultHttpUriBuilder() { this.protocol = "http://"; this.path = ""; this.pathComponent = ""; this.port = -1; this.params = ArrayListMultimap.create(); this.queryParams = ""; }
From source file:com.google.visualization.datasource.query.engine.ColumnIndices.java
/** * Creates an empty instance of this class. */ public ColumnIndices() { columnToIndices = ArrayListMultimap.create(); }