List of usage examples for com.google.common.collect Multimap get
Collection<V> get(@Nullable K key);
From source file:edu.cmu.lti.oaqa.baseqa.answer.CavUtil.java
private static void getConstituentTokens(Token token, Multimap<Token, Token> head2children, Set<Token> exclusions, List<Token> branchTokens) { branchTokens.add(token);//from w ww . j a v a 2 s . com head2children.get(token).stream().filter(child -> exclusions == null || !exclusions.contains(child)) .forEach(child -> getConstituentTokens(child, head2children, exclusions, branchTokens)); }
From source file:com.android.sdklib.repository.local.Update.java
private static RemotePkgInfo findUpdate(@NonNull LocalPkgInfo local, @NonNull Multimap<PkgType, RemotePkgInfo> remotePkgs, @NonNull UpdateResult result) { RemotePkgInfo currUpdatePkg = null;/*from w ww. j a va 2 s .com*/ IPkgDesc currUpdateDesc = null; IPkgDesc localDesc = local.getDesc(); for (RemotePkgInfo remote : remotePkgs.get(localDesc.getType())) { IPkgDesc remoteDesc = remote.getDesc(); if ((currUpdateDesc == null && remoteDesc.isUpdateFor(localDesc)) || (currUpdateDesc != null && remoteDesc.isUpdateFor(currUpdateDesc))) { currUpdatePkg = remote; currUpdateDesc = remoteDesc; } } local.setUpdate(currUpdatePkg); if (currUpdatePkg != null) { result.addUpdatedPkgs(local); } return currUpdatePkg; }
From source file:de.iteratec.iteraplan.persistence.elasticeam.metamodel.IteraplanDiffClassifier.java
public static Collection<MMChange<?>> getUnapplicableDiffs(Multimap<TypeOfDiff, MMChange<?>> classifiedDiffs) { LOGGER.info("Getting unapplicable metamodel differences."); Collection<MMChange<?>> unapplicableDiffs = classifiedDiffs.get(TypeOfDiff.UNKNOWN); if (unapplicableDiffs == null) { unapplicableDiffs = Sets.newHashSet(); }//from ww w . j a v a 2 s . c o m LOGGER.info("{0} unapplicable differences.", Integer.valueOf(unapplicableDiffs.size())); if (LOGGER.isDebugEnabled()) { for (MMChange<?> diff : unapplicableDiffs) { LOGGER.debug("- {0}", diff); } } return unapplicableDiffs; }
From source file:com.eucalyptus.entities.PersistenceExceptions.java
@SuppressWarnings("unchecked") private static Multimap<ErrorCategory, Class<? extends Exception>> buildErrorMap() { final Multimap<ErrorCategory, Class<? extends Exception>> map = ArrayListMultimap.create(); map.get(ErrorCategory.BUG) .addAll(Lists.newArrayList(LazyInitializationException.class, InstantiationException.class, MappingException.class, MultipleBagFetchException.class, NonUniqueObjectException.class, QueryException.class, PersistentObjectException.class, PropertyAccessException.class, SerializationException.class, SessionException.class, TooManyRowsAffectedException.class, TransientObjectException.class, StaleStateException.class, TypeMismatchException.class, UnresolvableObjectException.class, WrongClassException.class, SQLGrammarException.class, TransactionRequiredException.class, HibernateException.class)); map.get(ErrorCategory.CONSTRAINT).addAll(Lists.newArrayList(ConstraintViolationException.class, NonUniqueResultException.class, NoResultException.class, NonUniqueResultException.class)); map.get(ErrorCategory.RUNTIME)//from w w w . j ava 2 s.c o m .addAll(Lists.newArrayList(TransactionException.class, IllegalStateException.class, RollbackException.class, PessimisticLockException.class, OptimisticLockException.class, EntityNotFoundException.class, EntityExistsException.class)); map.get(ErrorCategory.CONNECTION).addAll(Lists.newArrayList(JDBCConnectionException.class, QueryTimeoutException.class, LockTimeoutException.class)); return map; }
From source file:info.gehrels.voting.web.BallotIterableDiffCalculator.java
private static <T extends Candidate> Set<Long> differentBetweenSetAAndSetB(Iterable<Ballot<T>> ballotSetA, Iterable<Ballot<T>> ballotSetB) { Set<Long> idsOfDifferingBallots = new HashSet<>(); Multimap<Long, Ballot<T>> idsToBallotSetMultimapForB = asIdToBallotsMulitmap(ballotSetB); for (Ballot<T> ballotFromSetA : ballotSetA) { Collection<Ballot<T>> ballotsFromSetB = idsToBallotSetMultimapForB.get(ballotFromSetA.id); for (Ballot<T> ballotFromSetB : ballotsFromSetB) { if (!ballotFromSetA.equals(ballotFromSetB)) { idsOfDifferingBallots.add(ballotFromSetA.id); }//from ww w . j av a2s .c om } } return idsOfDifferingBallots; }
From source file:com.github.checkstyle.TemplateProcessor.java
/** * Returns the map which represents template variables. * @param releaseNotes release notes map. * @param releaseNumber release number.// w w w . j av a 2 s. c om * @return the map which represents template variables. */ public static Map<String, Object> getTemplateVariables(Multimap<String, ReleaseNotesMessage> releaseNotes, String releaseNumber) { final Map<String, Object> variables = new HashMap<>(); variables.put("releaseNo", releaseNumber); variables.put("breakingMessages", releaseNotes.get(Constants.BREAKING_COMPATIBILITY_LABEL)); variables.put("newMessages", releaseNotes.get(Constants.NEW_LABEL)); variables.put("bugMessages", releaseNotes.get(Constants.BUG_LABEL)); variables.put("notesMessages", releaseNotes.get(Constants.MISCELLANEOUS_LABEL)); return variables; }
From source file:com.eucalyptus.vm.NetworkGroupsMetadata.java
private static String rulesToString(Multimap<String, String> rules) { StringBuilder buf = new StringBuilder(); for (String networkName : rules.keySet()) { for (String rule : rules.get(networkName)) { buf.append("RULE ").append(networkName).append(" ").append(rule).append("\n"); }/* ww w . j ava2 s.com*/ } return buf.toString(); }
From source file:de.dentrassi.pm.storage.service.jpa.StreamServiceHelper.java
public static SortedMap<MetaKey, String> extract(final String id, final Multimap<String, MetaDataEntry> properties) { final SortedMap<MetaKey, String> result = new TreeMap<>(); for (final MetaDataEntry entry : properties.get(id)) { result.put(entry.getKey(), entry.getValue()); }//w w w . j a v a2 s .c om return result; }
From source file:n3phele.factory.rest.impl.HPCloudExtractor.java
@SuppressWarnings("unchecked") private static String getPrivateAddresses(Object response) { String address = ""; Multimap<String, Address> multimap = (Multimap<String, Address>) response; for (String access : multimap.keySet()) { if (access.compareTo("private") == 0) { Collection<Address> addresses = multimap.get(access); for (@SuppressWarnings("rawtypes") Iterator iter = addresses.iterator(); iter.hasNext();) { Address add = (Address) iter.next(); address = (add.getAddr()); return address; }// w w w . j a v a2s .c om } } return address; }
From source file:pl.com.tt.guice.InjectorFactory.java
/** * Scan classpath members for classes that have static fields annotated with * {@link Inject}.//from w ww.ja v a2s .co m * * <p/> * This scan will only find classes that are not from * <code>com.google</code> package (to exclude internal Guice * modules) * * @param classPathMembers classpath members to scan * @return all classes that are Guice modules */ @SuppressWarnings("unchecked") public static Collection<Class<?>> findAllStaticInjects(Set<URL> classPathMembers) { //Search only for classes with Module in name. //Exclude Google Guice internal injectors // and our wrapper module. Predicate<String> filter = new FilterBuilder().include(".*").exclude("com\\.google\\..*") .exclude("pl\\.com\\.tt\\.guice\\.junit\\.GUnitInjectorFactory\\$WrapperModule.*"); //Find all classes with @Inject fields StaticFieldAnnotationsScanner scanner = new StaticFieldAnnotationsScanner(); scanner.filterResultsBy(new FilterBuilder().include(Inject.class.getName())); ConfigurationBuilder config = new ConfigurationBuilder().setUrls(classPathMembers).setScanners(scanner) .filterInputsBy(filter); Reflections reflections = new Reflections(config); Multimap<String, String> keys = reflections.getStore().get(scanner); Collection<String> fieldFqns = keys.get(Inject.class.getName()); Set<Class<?>> classes = new HashSet<Class<?>>(fieldFqns.size()); for (String string : fieldFqns) { Field field = Utils.getFieldFromString(string); classes.add(field.getDeclaringClass()); } return classes; }