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:org.icgc.dcc.portal.manifest.writer.GDCManifestWriter.java

@SneakyThrows
public static void write(OutputStream buffer, Multimap<String, ManifestFile> bundles) {
    val tsv = createTsv(buffer);
    tsv.writeHeader(TSV_HEADERS);/*from   ww  w. j  a va2s .c  om*/

    for (val url : bundles.keySet()) {
        val bundle = bundles.get(url);
        checkState(bundle.size() == 1, "%s expected to have only one file", bundle);

        val file = getFirst(bundle, null);
        val row = createRow(file);

        tsv.write(row);
    }

    tsv.flush();
}

From source file:org.icgc.dcc.portal.manifest.writer.ICGCManifestWriter.java

@SneakyThrows
public static void write(OutputStream buffer, Multimap<String, ManifestFile> bundles) {
    val tsv = createTsv(buffer);
    tsv.writeHeader(TSV_HEADERS);/*from ww  w .  jav  a 2  s .c o  m*/

    for (val url : bundles.keySet()) {
        val bundle = bundles.get(url);
        val row = createRow(bundle);

        tsv.write(row);
    }

    tsv.flush();
}

From source file:org.gradle.api.internal.tasks.compile.incremental.deps.ClassDependentsAccumulator.java

private static <K, V> Map<K, Set<V>> asMap(Multimap<K, V> multimap) {
    ImmutableMap.Builder<K, Set<V>> builder = ImmutableMap.builder();
    for (K key : multimap.keySet()) {
        builder.put(key, ImmutableSet.copyOf(multimap.get(key)));
    }/*from   w w  w  .ja v a  2 s. c om*/
    return builder.build();
}

From source file:it.osm.gtfs.command.GTFSGenerateRoutesGPXs.java

public static void run() throws IOException, ParserConfigurationException, SAXException {
    Map<String, Stop> osmstops = OSMParser.applyGTFSIndex(OSMParser
            .readOSMStops(GTFSImportSetting.getInstance().getOSMPath() + GTFSImportSetting.OSM_STOP_FILE_NAME));
    Map<String, Route> routes = GTFSParser.readRoutes(
            GTFSImportSetting.getInstance().getGTFSPath() + GTFSImportSetting.GTFS_ROUTES_FILE_NAME);
    Map<String, Shape> shapes = GTFSParser.readShapes(
            GTFSImportSetting.getInstance().getGTFSPath() + GTFSImportSetting.GTFS_SHAPES_FILE_NAME);
    Map<String, StopsList> stopTimes = GTFSParser.readStopTimes(
            GTFSImportSetting.getInstance().getGTFSPath() + GTFSImportSetting.GTFS_STOP_TIME_FILE_NAME,
            osmstops);/*from  w w  w  .  j a v a  2 s  . co  m*/
    List<Trip> trips = GTFSParser.readTrips(
            GTFSImportSetting.getInstance().getGTFSPath() + GTFSImportSetting.GTFS_TRIPS_FILE_NAME, routes,
            new HashMap<String, StopsList>());

    //sorting set
    Multimap<String, Trip> grouppedTrips = GTFSParser.groupTrip(trips, routes, stopTimes);
    Set<String> keys = new TreeSet<String>(grouppedTrips.keySet());

    new File(GTFSImportSetting.getInstance().getOutputPath() + "gpx").mkdirs();

    int id = 10000;
    for (String k : keys) {
        Collection<Trip> allTrips = grouppedTrips.get(k);
        Set<Trip> uniqueTrips = new HashSet<Trip>(allTrips);

        for (Trip trip : uniqueTrips) {
            Route r = routes.get(trip.getRoute().getId());
            Shape s = shapes.get(trip.getShapeID());

            FileOutputStream f = new FileOutputStream(GTFSImportSetting.getInstance().getOutputPath() + "/gpx/r"
                    + id++ + " " + r.getShortName().replace("/", "B") + " " + trip.getName().replace("/", "_")
                    + ".gpx");
            f.write(s.getGPX(r.getShortName()).getBytes());
            f.close();
        }
    }
}

From source file:com.magnet.mmx.tools.PojoToJsonSchema.java

public static void printAll(ClassLoader classLoader) {
    Reflections reflections = new Reflections("com.magnet.mmx.protocol");

    // iterate through all and print the JSON schema
    Store store = reflections.getStore();
    Map<String, Multimap<String, String>> map = store.getStoreMap();
    Set<String> entrySet = map.keySet();

    for (String key : entrySet) {
        Multimap<String, String> entries = map.get(key);
        if ("SubTypesScanner".equalsIgnoreCase(key)) {
            for (String key2 : entries.keySet()) {
                // get the class and find its sub-types
                try {
                    if (schemaHashMap.containsKey(key2)) {
                        continue;
                    }//from ww  w. j a  v  a  2s  . c o m
                    Class<?> clazz = classLoader.loadClass(key2);
                    Set<? extends Class<?>> subTypes = reflections.getSubTypesOf(clazz);
                    for (Class subType : subTypes) {
                        if (schemaHashMap.containsKey(subType.getName())) {
                            continue;
                        }
                        System.out.println();
                        PojoSchema schema = getJsonSchemaFormat(subType);
                        printSchema(schema);
                        schemaHashMap.put(subType.getName(), schema);
                    }

                } catch (ClassNotFoundException e) {
                    e.printStackTrace();
                }
            }
        }
        System.out.println();
    }
}

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;
            }//from w  w  w .  j  a  v a  2s  . c o m
        }
    }

    return address;
}

From source file:n3phele.factory.rest.impl.HPCloudExtractor.java

@SuppressWarnings("unchecked")
private static String getPublicAddresses(Object response) {
    String address = "";

    Multimap<String, Address> multimap = (Multimap<String, Address>) response;
    for (String access : multimap.keySet()) {
        //logger.info("multimap key access:" + access);
        Collection<Address> addresses = multimap.get(access);
        //logger.info("Collection size:" + addresses.size());
        for (@SuppressWarnings("rawtypes")
        Iterator iter = addresses.iterator(); iter.hasNext();) {
            Address add = (Address) iter.next();
            address = (add.getAddr());/*w w  w . ja v a 2 s .  c  o  m*/

        }
    }

    return address;
}

From source file:it.osm.gtfs.command.GTFSGenerateRoutesBaseRelations.java

public static void run() throws IOException, ParserConfigurationException, SAXException {
    Map<String, Stop> osmstops = OSMParser.applyGTFSIndex(OSMParser
            .readOSMStops(GTFSImportSetting.getInstance().getOSMPath() + GTFSImportSetting.OSM_STOP_FILE_NAME));
    Map<String, Route> routes = GTFSParser.readRoutes(
            GTFSImportSetting.getInstance().getGTFSPath() + GTFSImportSetting.GTFS_ROUTES_FILE_NAME);
    Map<String, StopsList> stopTimes = GTFSParser.readStopTimes(
            GTFSImportSetting.getInstance().getGTFSPath() + GTFSImportSetting.GTFS_STOP_TIME_FILE_NAME,
            osmstops);/*from   w  ww.ja  v a  2s  .c  o m*/
    List<Trip> trips = GTFSParser.readTrips(
            GTFSImportSetting.getInstance().getGTFSPath() + GTFSImportSetting.GTFS_TRIPS_FILE_NAME, routes,
            stopTimes);
    BoundingBox bb = new BoundingBox(osmstops.values());

    //sorting set
    Multimap<String, Trip> grouppedTrips = GTFSParser.groupTrip(trips, routes, stopTimes);
    Set<String> keys = new TreeSet<String>(grouppedTrips.keySet());

    new File(GTFSImportSetting.getInstance().getOutputPath() + "relations").mkdirs();

    int id = 10000;
    for (String k : keys) {
        Collection<Trip> allTrips = grouppedTrips.get(k);
        Set<Trip> uniqueTrips = new HashSet<Trip>(allTrips);

        for (Trip trip : uniqueTrips) {
            int count = Collections.frequency(allTrips, trip);

            Route r = routes.get(trip.getRoute().getId());
            StopsList s = stopTimes.get(trip.getTripID());

            FileOutputStream f = new FileOutputStream(GTFSImportSetting.getInstance().getOutputPath()
                    + "relations/r" + id + " " + r.getShortName().replace("/", "B") + " "
                    + trip.getName().replace("/", "_") + "_" + count + ".osm");
            f.write(OSMRelationImportGenerator.getRelation(bb, s, trip, r).getBytes());
            f.close();
            f = new FileOutputStream(GTFSImportSetting.getInstance().getOutputPath() + "relations/r" + id++
                    + " " + r.getShortName().replace("/", "B") + " " + trip.getName().replace("/", "_") + "_"
                    + count + ".txt");
            f.write(s.getRelationAsStopList(trip, r).getBytes());
            f.close();
        }
    }
}

From source file:com.google.enterprise.connector.ldap.JsonDocument.java

private static JsonDocument buildJson(Multimap<String, String> person) {
    JSONObject jo = new JSONObject();
    for (String attrname : person.keySet()) {
        try {/*from   w  w w  .  j  a  v  a 2s .c  om*/
            jo.put(attrname, person.get(attrname));
        } catch (JSONException e) {
            throw new IllegalStateException();
        }
    }
    return new JsonDocument(jo);
}

From source file:com.android.tools.idea.apk.viewer.dex.DexParser.java

@NotNull
static PackageTreeNode constructMethodRefTreeForDex(@NotNull DexBackedDexFile dexFile) {
    PackageTreeNode root = new PackageTreeNode("", "root", PackageTreeNode.NodeType.PACKAGE, null);

    Set<String> classesWithDefinition = dexFile.getClasses().stream().map(DexBackedClassDef::getType)
            .collect(Collectors.toSet());

    Multimap<String, MethodReference> methodsByClassName = getMethodsByClassName(dexFile);
    for (String className : methodsByClassName.keySet()) {
        Collection<MethodReference> methods = methodsByClassName.get(className);
        for (MethodReference ref : methods) {
            root.insert("", DebuggerUtilsEx.signatureToName(className), ref,
                    classesWithDefinition.contains(className));
        }/*  w  w w .j a  va2  s.  c om*/
    }

    root.sortByCount();
    return root;
}