Example usage for com.google.common.collect Multimap keySet

List of usage examples for com.google.common.collect Multimap keySet

Introduction

In this page you can find the example usage for com.google.common.collect Multimap keySet.

Prototype

Set<K> keySet();

Source Link

Document

Returns a view collection of all distinct keys contained in this multimap.

Usage

From source file:edu.umn.msi.tropix.client.directory.impl.UserIterableImpl.java

public Iterator<GridUser> iterator() {
    final Collection<GridUser> users = new LinkedList<GridUser>();
    final Multimap<String, Person> persons = personSupplier.get();
    for (String institution : persons.keySet()) {
        Iterables.addAll(users,/*  w  w  w .ja  v  a2  s .  com*/
                Iterables.filter(
                        Collections2.transform(persons.get(institution), new PersonFunction(institution)),
                        Predicates.not(Predicates.isNull())));
    }
    for (final GridUser user : users) {
        gridUserMap.put(user.getGridId(), user);
    }
    return users.iterator();
}

From source file:com.google.devtools.build.lib.query2.TransitiveTraversalValueDTCVisitor.java

@Override
protected Visit getVisitResult(Iterable<SkyKey> ttvKeys) throws InterruptedException {
    Multimap<SkyKey, SkyKey> deps = env.getDirectDepsOfSkyKeys(ttvKeys);
    return new Visit(/*keysToUseForResult=*/ deps.keySet(), /*keysToVisit=*/ deps.values().stream()
            .filter(SkyQueryEnvironment.IS_TTV).collect(ImmutableList.toImmutableList()));
}

From source file:tterrag.potionapi.common.util.ReplaceUtil.java

@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onWorldLoad(WorldEvent.Load event) {
    if (Repl.replacements.size() < 1) {
        return;// w  w w .  j ava2s.  c o  m
    }
    for (Map.Entry<RegistryNamespaced, Multimap<String, Object>> entry : Repl.replacements.entrySet()) {
        RegistryNamespaced reg = entry.getKey();
        Multimap<String, Object> map = entry.getValue();
        Iterator<String> v = map.keySet().iterator();
        while (v.hasNext()) {
            String id = v.next();
            List<Object> c = (List<Object>) map.get(id);
            int i = 0, e = c.size() - 1;
            Object end = c.get(e);
            if (reg.getIDForObject(c.get(0)) != reg.getIDForObject(end)) {
                for (; i <= e; ++i) {
                    Object t = c.get(i);
                    Object oldThing = reg.getObject(id);
                    Repl.overwrite_do(reg, id, t, oldThing);
                    Repl.alterDelegate(oldThing, end);
                }
            }
        }
    }
}

From source file:sorcer.boot.util.ClassPathVerifier.java

public void verifyClassPaths(ClassLoader cl) {

    Multimap<ClassLoader, String> classPaths = HashMultimap.create();
    for (ClassLoader classLoader : getClassLoaderTree(cl)) {
        classPaths.get(classLoader).addAll(getClassPath(classLoader));
    }//from  w w w .j  a  va 2  s . co m
    HashMultimap<String, ClassLoader> dest = HashMultimap.create();
    Multimap<String, ClassLoader> classLoaders = Multimaps.invertFrom(classPaths, dest);
    for (String key : classLoaders.keySet()) {
        // don't check bootstrap classpath
        if (SorcerEnv.getRepoDir() == null || !key.contains(SorcerEnv.getRepoDir()))
            continue;
        if (classLoaders.get(key).size() > 1) {
            StringBuilder msg = new StringBuilder(key).append(" is loaded by multiple class loaders:\n");
            for (ClassLoader kcl : classLoaders.get(key)) {
                msg.append("\t").append(kcl).append("\n");
            }
            log.info("{}", msg);
        }
    }
}

From source file:org.jclouds.cloudstack.filters.ReEncodeQueryWithDefaultURLEncoder.java

@Override
public HttpRequest filter(HttpRequest request) throws HttpException {
    UriBuilder builder = builders.get();
    builder.uri(request.getEndpoint());/*  www  .  j a v  a  2 s  .  c om*/
    Multimap<String, String> map = Queries.parseQueryToMap(request.getEndpoint().getRawQuery());
    builder.replaceQuery("");
    for (String key : map.keySet())
        builder.queryParam(key, getOnlyElement(map.get(key)));
    return request.toBuilder().endpoint(builder.build()).build();
}

From source file:org.summer.ss.ide.builder.SourceRelativeFileSystemAccess.java

/**
 * Since sourceTraces are relative the URI has to be computed with the currentSource as context
 *//*from   ww w  .j  av a2s  .  co m*/
@Override
public void flushSourceTraces(String generatorName) throws CoreException {
    Multimap<URI, IPath> sourceTraces = getSourceTraces();
    if (sourceTraces != null) {
        Set<URI> keys = sourceTraces.keySet();
        for (URI uri : keys) {
            if (uri != null && currentSource != null) {
                Collection<IPath> paths = sourceTraces.get(uri);
                IFile sourceFile = currentSource.getFile(uri.toFileString());
                if (sourceFile.exists()) {
                    IPath[] tracePathArray = paths.toArray(new IPath[paths.size()]);
                    getTraceMarkers().installMarker(sourceFile, generatorName, tracePathArray);
                }
            }
        }
    }
    resetSourceTraces();
}

From source file:fr.irit.smac.may.speadl.ui.builder.SourceRelativeFileSystemAccess.java

/**
 * Since sourceTraces are relative the URI has to be computed with the currentSource as context
 *///from  w  w w  .  ja  v  a2 s.  com
//TODO this fixes relative URIs for Xtend only, but what about all other languages?
@Override
public void flushSourceTraces(String generatorName) throws CoreException {
    Multimap<URI, IPath> sourceTraces = getSourceTraces();
    if (sourceTraces != null) {
        Set<URI> keys = sourceTraces.keySet();
        String source = getCurrentSource();
        IContainer container = Strings.isEmpty(source) ? getProject() : getProject().getFolder(source);
        for (URI uri : keys) {
            if (uri != null && source != null) {
                Collection<IPath> paths = sourceTraces.get(uri);
                IFile sourceFile = container.getFile(new Path(uri.toFileString()));
                if (sourceFile.exists()) {
                    IPath[] tracePathArray = paths.toArray(new IPath[paths.size()]);
                    getTraceMarkers().installMarker(sourceFile, generatorName, tracePathArray);
                }
            }
        }
    }
    resetSourceTraces();
}

From source file:com.textocat.textokit.morph.opencorpora.resource.YoLemmaPostProcessor.java

/**
 * {@inheritDoc}/*from   w  w  w  .  j a va  2 s.c o  m*/
 */
@Override
public boolean process(MorphDictionary dict, Lemma.Builder lemmaBuilder, Multimap<String, Wordform> wfMap) {
    Multimap<String, Wordform> additionalWfs = LinkedHashMultimap.create();
    for (String wfStr : wfMap.keySet()) {
        // alternative wordform string
        String altStr = StringUtils.replaceChars(wfStr, YO_CHARS, YO_REPLACEMENTS);
        if (Objects.equal(wfStr, altStr)) {
            continue;
        } // else wfStr contains 'yo'
        if (wfMap.containsKey(altStr)) {
            // the wordform multimap already contains string without 'yo'
            continue;
        }
        additionalWfs.putAll(altStr, wfMap.get(wfStr));
    }
    wfMap.putAll(additionalWfs);
    return true;
}

From source file:org.jclouds.json.internal.IgnoreNullMultimapTypeAdapterFactory.java

private <K, V> TypeAdapter<Multimap<K, V>> newMapAdapter(final TypeAdapter<K> keyAdapter,
        final TypeAdapter<V> valueAdapter) {
    return new TypeAdapter<Multimap<K, V>>() {
        public void write(JsonWriter out, Multimap<K, V> map) throws IOException {
            out.beginObject();/*from  w ww  . j  av  a  2 s .c om*/
            for (K key : map.keySet()) {
                out.name(String.valueOf(key));
                out.beginArray();
                for (V value : map.get(key)) {
                    valueAdapter.write(out, value);
                }
                out.endArray();
            }
            out.endObject();
        }

        public Multimap<K, V> read(JsonReader in) throws IOException {
            ImmutableMultimap.Builder<K, V> result = ImmutableListMultimap.builder();
            in.beginObject();
            while (in.hasNext()) {
                JsonReaderInternalAccess.INSTANCE.promoteNameToValue(in);
                K name = keyAdapter.read(in);
                in.beginArray();
                while (in.hasNext()) {
                    V value = valueAdapter.read(in);
                    if (value != null)
                        result.put(name, value);
                }
                in.endArray();
            }
            in.endObject();
            return result.build();
        }
    }.nullSafe();
}

From source file:com.axelor.meta.loader.AbstractLoader.java

/**
 * Return set of all the unresolved keys.
 * //w  ww .j a  v a 2s  .c om
 * @return set of unresolved keys
 */
protected Set<String> unresolvedKeys() {
    Set<String> names = Sets.newHashSet();
    Map<Class<?>, Multimap<String, Object>> map = unresolved.get();
    if (map == null) {
        return names;
    }
    for (Multimap<String, Object> mm : map.values()) {
        names.addAll(mm.keySet());
    }
    return names;
}