List of usage examples for com.google.common.collect SetMultimap put
boolean put(@Nullable K key, @Nullable V value);
From source file:com.openlattice.middlesex.MiddlesexCharges2.java
public static void main(String[] args) throws InterruptedException { /*/*from w w w . j av a2 s . c o m*/ * It's worth noting that we are omitting validation such as making sure enough args were passed in, checking * existence of the file, and making sure authentication was successful. A failure in one of these cases * will cause the program to exit with an exception. */ final String arrestsPath = args[0]; final String incidents2016Path = args[1]; final String incidents2017Path = args[2]; final String jwtToken = args[3]; //final SparkSession sparkSession = MissionControl.getSparkSession(); SimplePayload payload = new SimplePayload(arrestsPath); SimplePayload incident16Data = new SimplePayload(incidents2016Path); SimplePayload incident17Data = new SimplePayload(incidents2017Path); //final String jwtToken = MissionControl.getIdToken( username, password ); logger.info("Using the following idToken: Bearer {}", jwtToken); Retrofit retrofit = RetrofitFactory.newClient(environment, () -> jwtToken); EdmApi edm = retrofit.create(EdmApi.class); // Dataset<Row> payload = sparkSession // .read() // .format( "com.databricks.spark.csv" ) // .option( "header", "true" ) // .load( arrestsPath ); // // Dataset<Row> incident16Data = sparkSession // .read() // .format( "com.databricks.spark.csv" ) // .option( "header", "true" ) // .load( incidents2016Path ); // // Dataset<Row> incident17Data = sparkSession // .read() // .format( "com.databricks.spark.csv" ) // .option( "header", "true" ) // .load( incidents2017Path ); Flight flight = Flight.newFlight().createEntities() .addEntity("arrestee").to("LPDArrestSuspects") //for name/DOB unique IDs //.to("LPDArrestees") //for UUID unique IDs .addProperty(new FullQualifiedName("nc.SubjectIdentification")) // .value( row -> UUID.randomUUID().toString() ) // .ok() .value(row -> { return Parsers.getAsString(row.getAs("Name")) + " " + Parsers.getAsString(row.getAs("DOB")); }).ok() //.value( MiddlesexCharges2::getSubjectIdentification ).ok() .addProperty(new FullQualifiedName("nc.PersonGivenName")).value(MiddlesexCharges2::getFirstName) .ok().addProperty(new FullQualifiedName("nc.PersonMiddleName")) .value(MiddlesexCharges2::getMiddleName).ok().addProperty(new FullQualifiedName("nc.PersonSurName")) .value(MiddlesexCharges2::getLastName).ok() .addProperty(new FullQualifiedName("nc.PersonNameSuffixText")).value(MiddlesexCharges2::getSuffixes) .ok().addProperty(new FullQualifiedName("nc.PersonRace")).value(MiddlesexCharges2::getRace).ok() .addProperty("nc.PersonEthnicity").value(MiddlesexCharges2::getEthnicity).ok() .addProperty(new FullQualifiedName("nc.PersonBirthDate")).value(MiddlesexCharges2::safeDOBParse) .ok().addProperty(new FullQualifiedName("nc.PersonSex")).value(MiddlesexCharges2::getSex).ok() .addProperty("nc.PersonHeightMeasure").value(MiddlesexCharges2::getHeight).ok() .addProperty("nc.PersonWeightMeasure").value(MiddlesexCharges2::getWeight).ok().endEntity() // .addEntity( "arrestAddress" ) // .to( "LPDAddresses" ) // .addProperty( new FullQualifiedName( "location.address" ) ) // .value( MiddlesexCharges2::getArrestAddress ).ok() // .endEntity() .addEntity("incidentAddress").to("LPDAddresses") .addProperty(new FullQualifiedName("location.Address")).value(MiddlesexCharges2::getIncidentAddress) .ok().endEntity() .addEntity("incident").to("LPDIncidents").addProperty("location.address") .value(MiddlesexCharges2::getIncidentAddress).ok().addProperty("criminaljustice.incidentid") .value(MiddlesexCharges2::getIncidentID).ok().endEntity() .addEntity("offense").to("LPDOffenses").addProperty("criminaljustice.offenseid") .value(MiddlesexCharges2::getArrestSequenceID).ok() .addProperty("criminaljustice.localstatute", "Charge").endEntity() // .addEntity( "charge" ) // .to( "LPDCharge" ) // .addProperty( "j.ChargeSequenceID", "Case Number" ) // .addProperty( "j.OffenseViolatedStatute" ) // .value( MiddlesexCharges2::getOffenseViolatedStatute ).ok() // .addProperty( "j.OffenseQualifierText" ) // .value( MiddlesexCharges2::getOffenseQualifierText ).ok() // .endEntity() .endEntities().createAssociations() .addAssociation("arrestedin").to("LPDArrestedIn").fromEntity("arrestee").toEntity("incident") .addProperty("nc.SubjectIdentification") // .value( row -> UUID.randomUUID().toString() ) // .ok() .value(row -> { return Parsers.getAsString(row.getAs("Name")) + " " + Parsers.getAsString(row.getAs("DOB")); }).ok().addProperty("arrestedin.id").value(MiddlesexCharges2::getIncidentID).ok() .addProperty(new FullQualifiedName("arrest.date")) .value(row -> dtHelper.parse((row.getAs("arr_date") + " " + row.getAs("Time")).trim())).ok() .addProperty("criminaljustice.bookingnumber", "bookingnum") .addProperty("arrest.category", "type_charge").addProperty("criminaljustice.localstatute", "Charge") .addProperty("location.address").value(MiddlesexCharges2::getArrestAddress).ok().endAssociation() //incident occurred at address .addAssociation("arrestedat").to("LPDOccurredAt").fromEntity("incident").toEntity("incidentAddress") .addProperty("general.stringid").value(MiddlesexCharges2::getIncidentID).ok() .addProperty("location.address").value(MiddlesexCharges2::getIncidentAddress).ok().endAssociation() // .addAssociation( "occurredat" ) // .to( "LPDOccurredAt" ) // .fromEntity( "charge" ) // .toEntity( "incidentAddress" ) // .addProperty( "general.stringid", "Case Number" ) // .addProperty( "location.address" ).value( MiddlesexCharges2::getIncidentAddress ).ok() // .endAssociation() // .addAssociation( "chargedwith" ) // .to( "LPDChargedWith" ) // .fromEntity( "suspect" ) // .toEntity( "charge" ) // .addProperty( "general.stringid" ) // .value( row -> MoreObjects.firstNonNull( row.getAs( "bookingnum" ), "" ) + MoreObjects // .firstNonNull( row.getAs( "Case Number" ), "" ) ).ok() // .endAssociation() // // .addAssociation( "chargeappears" ) //change to offense appears in arrest // .to( "LPDChargeAppearsIn" ) // .fromEntity( "offense" ) // .toEntity( "arrest" ) // .addProperty( "general.stringid" ) // .value( row -> MoreObjects.firstNonNull( row.getAs( "Case Number" ), "" ) + MoreObjects // .firstNonNull( row.getAs( "Charge" ), "" ) ).ok() // .endAssociation() .endAssociations().done(); Flight incidents = Flight.newFlight().createEntities().addEntity("incident").to("LPDIncidents") .useCurrentSync().addProperty("location.address").value(MiddlesexCharges2::getIncidentAddress).ok() .addProperty("criminaljustice.incidentid").value(MiddlesexCharges2::getIncidentflightID).ok() .addProperty("incident.reporteddatetime").value(MiddlesexCharges2::getChargeReportedDate).ok() .addProperty("incident.startdatetime").value(MiddlesexCharges2::getOffenseStartDate).ok() .addProperty("incident.enddatetime").value(MiddlesexCharges2::getOffenseEndDate).ok() .addProperty("criminaljustice.localstatute", "Class") .addProperty("criminaljustice.nibrs", "IBR Code Counts") .addProperty("criminaljustice.incidentflag", "Flags").addProperty("incident.narrative", "comments") .addProperty("criminaljustice.casestatus", "Case Status") .addProperty("location.address", "Location") .addProperty("criminaljustice.beatsector", "Beat Sector Neighborhood").endEntity() .addEntity("address").to("LPDAddresses").useCurrentSync().ofType("general.Address") .key("location.address").addProperty("location.address", "Location") .addProperty("location.name", "Beat Sector Neighborhood").endEntity().endEntities().done(); Shuttle shuttle = new Shuttle(environment, jwtToken); SetMultimap<Flight, Payload> flights = HashMultimap.create(); flights.put(flight, payload); flights.put(incidents, incident16Data); flights.put(incidents, incident17Data); shuttle.launchPayloadFlight(flights); }
From source file:org.jakstab.Main.java
public static void main(String[] args) { mainThread = Thread.currentThread(); StatsTracker stats = StatsTracker.getInstance(); // Parse command line Options.parseOptions(args);/*from ww w . j av a2 s . c o m*/ logger.error(Characters.DOUBLE_LINE_FULL_WIDTH); logger.error(" Jakstab " + version); logger.error(" Copyright 2007-2012 Johannes Kinder <johannes.kinder@epfl.ch>"); logger.error(""); logger.error(" Jakstab comes with ABSOLUTELY NO WARRANTY. This is free software,"); logger.error(" and you are welcome to redistribute it under certain conditions."); logger.error(" Refer to LICENSE for details."); logger.error(Characters.DOUBLE_LINE_FULL_WIDTH); ///////////////////////// // Parse SSL file Architecture arch; try { arch = new Architecture(Options.sslFilename.getValue()); } catch (IOException e) { logger.fatal("Unable to open SSL file!", e); return; } catch (ANTLRException e) { logger.fatal("Error parsing SSL file!", e); return; } long overallStartTime = System.currentTimeMillis(); ///////////////////////// // Parse executable Program program = Program.createProgram(arch); File mainFile = new File(Options.mainFilename).getAbsoluteFile(); String baseFileName = null; try { // Load additional modules for (String moduleName : Options.moduleFilenames) { logger.warn("Parsing " + moduleName + "..."); File moduleFile = new File(moduleName).getAbsoluteFile(); program.loadModule(moduleFile); // If we are processing drivers, use the driver's name as base name if (Options.wdm.getValue() && moduleFile.getName().toLowerCase().endsWith(".sys")) { baseFileName = getBaseFileName(moduleFile); } } // Load main module last logger.warn("Parsing " + Options.mainFilename + "..."); program.loadMainModule(mainFile); // Use main module as base name if we have none yet if (baseFileName == null) baseFileName = getBaseFileName(mainFile); } catch (FileNotFoundException e) { logger.fatal("File not found: " + e.getMessage()); return; } catch (IOException e) { logger.fatal("IOException while parsing executable!", e); //e.printStackTrace(); return; } catch (BinaryParseException e) { logger.fatal("Error during parsing!", e); //e.printStackTrace(); return; } logger.info("Finished parsing executable."); // Change entry point if requested if (Options.startAddress.getValue() > 0) { logger.verbose("Setting start address to 0x" + Long.toHexString(Options.startAddress.getValue())); program.setEntryAddress(new AbsoluteAddress(Options.startAddress.getValue())); } // Add surrounding "%DF := 1; call entrypoint; halt;" program.installHarness( Options.heuristicEntryPoints.getValue() ? new HeuristicHarness() : new DefaultHarness()); int slashIdx = baseFileName.lastIndexOf('\\'); if (slashIdx < 0) slashIdx = baseFileName.lastIndexOf('/'); if (slashIdx < 0) slashIdx = -1; slashIdx++; stats.record(baseFileName.substring(slashIdx)); stats.record(version); //StatsPlotter.create(baseFileName + "_states.dat"); //StatsPlotter.plot("#Time(ms)\tStates\tInstructions\tGC Time\tSpeed(st/s)"); // Catches control-c and System.exit Thread shutdownThread = new Thread() { @Override public void run() { if (mainThread.isAlive() && activeAlgorithm != null) { //stop = true; // Used for CFI checks activeAlgorithm.stop(); try { mainThread.join(); } catch (InterruptedException e) { e.printStackTrace(); } } } }; Runtime.getRuntime().addShutdownHook(shutdownThread); // Add shutdown on return pressed for eclipse if (!Options.background.getValue() && System.console() == null) { logger.info("No console detected (eclipse?). Press return to terminate analysis and print statistics."); Thread eclipseShutdownThread = new Thread() { public void run() { try { System.in.read(); } catch (IOException e) { e.printStackTrace(); } System.exit(1); } }; // yices.dll blocks for input on load for some reason, so load it before we start reading from System.in // If you are having problems with that, uncomment the next line // org.jakstab.solver.yices.YicesWrapper.getVersion(); eclipseShutdownThread.start(); } // Necessary to stop shutdown thread on exceptions being thrown try { ///////////////////////// // Reconstruct Control Flow ControlFlowReconstruction cfr = new ControlFlowReconstruction(program); // Execute the algorithm try { runAlgorithm(cfr); } catch (RuntimeException r) { logger.error( "!! Runtime exception during Control Flow Reconstruction! Trying to shut down gracefully."); r.printStackTrace(); } long overallEndTime = System.currentTimeMillis(); ReachedSet reached = cfr.getReachedStates(); if (Options.dumpStates.getValue()) { // output logger.fatal("================="); logger.fatal(" Reached states:"); logger.fatal("================="); AbstractState[] stateArray = reached.toArray(new AbstractState[reached.size()]); Arrays.sort(stateArray, new Comparator<AbstractState>() { @Override public int compare(AbstractState o1, AbstractState o2) { return ((CompositeState) o1).getLocation().compareTo(((CompositeState) o2).getLocation()); } }); Location lastLoc = null; for (AbstractState s : stateArray) { if (!s.getLocation().equals(lastLoc)) { lastLoc = s.getLocation(); logger.fatal(""); } logger.fatal(s); } } int stateCount = reached.size(); if (Options.outputLocationsWithMostStates.getValue()) reached.logHighestStateCounts(10); if (!cfr.isCompleted()) { logger.error(Characters.starredBox("WARNING: Analysis interrupted, CFG might be incomplete!")); } if (!cfr.isSound()) { logger.error(Characters.starredBox("WARNING: Analysis was unsound!")); } /*logger.verbose("Unresolved locations: " + program.getUnresolvedBranches()); for (Location l : program.getUnresolvedBranches()) { AbsoluteAddress a = ((Location)l).getAddress(); if (program.getInstruction(a) == null) { logger.verbose(l + ": " + program.getStatement((Location)l)); } else { logger.verbose(a + "\t" + program.getInstructionString(a)); } }*/ int indirectBranches = program.countIndirectBranches(); logger.error(Characters.DOUBLE_LINE_FULL_WIDTH); logger.error(" Statistics for Control Flow Reconstruction"); logger.error(Characters.DOUBLE_LINE_FULL_WIDTH); logger.error(" Runtime: " + String.format("%8dms", (overallEndTime - overallStartTime))); logger.error(" Instructions: " + String.format("%8d", program.getInstructionCount())); logger.error( " RTL Statements: " + String.format("%8d", program.getStatementCount())); logger.error( " CFA Edges: " + String.format("%8d", program.getCFA().size())); logger.error(" States visited: " + String.format("%8d", cfr.getNumberOfStatesVisited())); logger.error(" Final state space: " + String.format("%8d", stateCount)); logger.error(" Finished normally: " + String.format("%8b", cfr.isCompleted())); logger.error(" Analysis result: " + cfr.getStatus()); // logger.error( " Sound: " + String.format("%8b", cfr.isSound())); logger.error(" Indirect Branches (no import calls): " + String.format("%8d", indirectBranches)); logger.error(" Unresolved Branches: " + String.format("%8d", program.getUnresolvedBranches().size())); logger.debug(" FastSet conversions: " + String.format("%8d", FastSet.getConversionCount())); logger.debug(" Variable count: " + String.format("%8d", ExpressionFactory.getVariableCount())); logger.error(Characters.DOUBLE_LINE_FULL_WIDTH); stats.record(program.getInstructionCount()); stats.record(program.getStatementCount()); stats.record(program.getCFA().size()); stats.record(indirectBranches); stats.record(program.getUnresolvedBranches().size()); stats.record(cfr.getNumberOfStatesVisited()); stats.record(stateCount); stats.record(Math.round((overallEndTime - overallStartTime) / 1000.0)); stats.record(cfr.getStatus()); stats.record(Options.cpas.getValue()); stats.record(BoundedAddressTracking.varThreshold.getValue()); stats.record(BoundedAddressTracking.heapThreshold.getValue()); stats.record(Options.basicBlocks.getValue() ? "y" : "n"); stats.record(Options.summarizeRep.getValue() ? "y" : "n"); stats.record(BasedNumberValuation.ExplicitPrintfArgs); stats.record(BasedNumberValuation.OverAppPrintfArgs); stats.print(); ProgramGraphWriter graphWriter = new ProgramGraphWriter(program); graphWriter.writeDisassembly(program, baseFileName + "_jak.asm"); if (!(cfr.isCompleted() && Options.secondaryCPAs.getValue().length() > 0)) { if (!Options.noGraphs.getValue()) { graphWriter.writeControlFlowAutomaton(baseFileName + "_cfa"); graphWriter.writeAssemblyCFG(baseFileName + "_asmcfg"); } //if (Options.errorTrace) graphWriter.writeART(baseFileName + "_art", cfr.getART()); } else { // If control flow reconstruction finished normally and other analyses are configured, start them now // Simplify CFA logger.info("=== Simplifying CFA ==="); DeadCodeElimination dce; long totalRemoved = 0; runAlgorithm(new ExpressionSubstitution(program)); do { dce = new DeadCodeElimination(program); runAlgorithm(dce); totalRemoved += dce.getRemovalCount(); } while (dce.getRemovalCount() > 0); logger.info("=== Finished CFA simplification, removed " + totalRemoved + " edges. ==="); AnalysisManager mgr = AnalysisManager.getInstance(); List<ConfigurableProgramAnalysis> secondaryCPAs = new LinkedList<ConfigurableProgramAnalysis>(); for (int i = 0; i < Options.secondaryCPAs.getValue().length(); i++) { ConfigurableProgramAnalysis cpa = mgr .createAnalysis(Options.secondaryCPAs.getValue().charAt(i)); if (cpa != null) { AnalysisProperties p = mgr.getProperties(cpa); logger.info("--- Using " + p.getName()); secondaryCPAs.add(cpa); } else { logger.fatal("No analysis corresponds to letter \"" + Options.secondaryCPAs.getValue().charAt(i) + "\"!"); System.exit(1); } } // Do custom analysis long customAnalysisStartTime = System.currentTimeMillis(); CPAAlgorithm cpaAlg; ConfigurableProgramAnalysis[] cpaArray = secondaryCPAs .toArray(new ConfigurableProgramAnalysis[secondaryCPAs.size()]); if (Options.backward.getValue()) { cpaAlg = CPAAlgorithm.createBackwardAlgorithm(program, cpaArray); } else { cpaAlg = CPAAlgorithm.createForwardAlgorithm(program, cpaArray); } activeAlgorithm = cpaAlg; cpaAlg.run(); long customAnalysisEndTime = System.currentTimeMillis(); if (!Options.noGraphs.getValue()) graphWriter.writeControlFlowAutomaton(baseFileName + "_cfa", cpaAlg.getReachedStates().select(1)); logger.error(Characters.DOUBLE_LINE_FULL_WIDTH); logger.error(" Statistics for " + Options.secondaryCPAs.getValue()); logger.error(Characters.DOUBLE_LINE_FULL_WIDTH); logger.error(" Runtime: " + String.format("%8dms", (customAnalysisEndTime - customAnalysisStartTime))); logger.error( " States: " + String.format("%8d", cpaAlg.getReachedStates().size())); logger.error(Characters.DOUBLE_LINE_FULL_WIDTH); } // If procedure abstraction is active, detect procedures now if (cfr.isCompleted() && Options.procedureAbstraction.getValue() == 2) { cfr = null; reached = null; ProcedureAnalysis procedureAnalysis = new ProcedureAnalysis(); CPAAlgorithm cpaAlg = CPAAlgorithm.createForwardAlgorithm(program, procedureAnalysis); runAlgorithm(cpaAlg); reached = cpaAlg.getReachedStates().select(1); Set<Location> procedures = procedureAnalysis.getCallees(); SetMultimap<Location, Location> callGraph = HashMultimap.create(); // Procedure analysis and thus this callgraph only works with --procedures 2 // A broken callgraph does not affect the safety checks, though, as all // procedures are checked without any interprocedural abstraction anyway for (Pair<Location, Location> callSite : procedureAnalysis.getCallSites()) { ProcedureState procedureState = (ProcedureState) Lattices .joinAll(reached.where(callSite.getLeft())); for (Location procedure : procedureState.getProcedureEntries()) { callGraph.put(procedure, callSite.getRight()); } } logger.info("Found " + procedures.size() + " function entry points from procedure analysis."); if (!Options.noGraphs.getValue()) graphWriter.writeCallGraph(baseFileName + "_callgraph", callGraph); } // Kills the keypress-monitor-thread. try { Runtime.getRuntime().removeShutdownHook(shutdownThread); System.exit(0); } catch (IllegalStateException e) { // Happens when shutdown has already been initiated by Ctrl-C or Return } } catch (Throwable e) { System.out.flush(); e.printStackTrace(); Runtime.getRuntime().removeShutdownHook(shutdownThread); // Kills eclipse shutdown thread System.exit(1); } }
From source file:com.wrmsr.kleist.util.collect.MoreCollectors.java
public static <I, K, V> Collector<I, SetMultimap<K, V>, SetMultimap<K, V>> toHashMultimap( Function<I, K> keyMapper, Function<I, V> valueMapper) { return Collector.of(HashMultimap::create, (SetMultimap<K, V> map, I in) -> map.put(keyMapper.apply(in), valueMapper.apply(in)), (SetMultimap<K, V> left, SetMultimap<K, V> right) -> { left.putAll(right);/* w ww . j a v a 2 s.c o m*/ return left; }, identity(), Collector.Characteristics.UNORDERED); }
From source file:de.bund.bfr.knime.gis.views.regiontoregionvisualizer.RegionToRegionUtils.java
public static Set<String> getSelectedGraphNodeIds(Set<GraphNode> graphNodes, Set<RegionNode> selectedGisNodes) { SetMultimap<String, String> graphNodesByRegion = LinkedHashMultimap.create(); for (GraphNode graphNode : graphNodes) { graphNodesByRegion.put(graphNode.getRegion(), graphNode.getId()); }//from w w w . j ava 2 s.c o m return selectedGisNodes.stream().map(n -> graphNodesByRegion.get(n.getId())).flatMap(Set::stream) .collect(Collectors.toCollection(LinkedHashSet::new)); }
From source file:org.sonar.server.notification.DefaultNotificationManager.java
private static void addUsersToRecipientListForChannel(List<String> users, SetMultimap<String, NotificationChannel> recipients, NotificationChannel channel) { for (String username : users) { recipients.put(username, channel); }//from w w w. j a v a2s . co m }
From source file:org.apache.kylin.source.hive.HiveSourceTableLoader.java
public static Set<String> loadHiveTables(String[] hiveTables, KylinConfig config) throws IOException { SetMultimap<String, String> db2tables = LinkedHashMultimap.create(); for (String fullTableName : hiveTables) { String[] parts = HadoopUtil.parseHiveTableName(fullTableName); db2tables.put(parts[0], parts[1]); }/*from w ww .j a va2 s. c o m*/ IHiveClient hiveClient = HiveClientFactory.getHiveClient(); SchemaChecker checker = new SchemaChecker(hiveClient, MetadataManager.getInstance(config), CubeManager.getInstance(config)); for (Map.Entry<String, String> entry : db2tables.entries()) { SchemaChecker.CheckResult result = checker.allowReload(entry.getKey(), entry.getValue()); result.raiseExceptionWhenInvalid(); } // extract from hive Set<String> loadedTables = Sets.newHashSet(); for (String database : db2tables.keySet()) { List<String> loaded = extractHiveTables(database, db2tables.get(database), hiveClient); loadedTables.addAll(loaded); } return loadedTables; }
From source file:edu.cmu.lti.oaqa.baseqa.answer.CavUtil.java
public static SetMultimap<Token, Token> getHeadTokenMap(Collection<Token> tokens) { SetMultimap<Token, Token> head2children = HashMultimap.create(); tokens.stream().filter(token -> token.getHead() != null) .forEach(token -> head2children.put(token.getHead(), token)); return head2children; }
From source file:org.sonar.server.computation.source.SymbolsLineReader.java
private static void putForTextRange(SetMultimap<Integer, BatchReport.Symbol> res, BatchReport.Symbol symbol, BatchReport.TextRange declaration) { for (int i = declaration.getStartLine(); i <= declaration.getEndLine(); i++) { res.put(i, symbol); }//from ww w . ja va 2s . c o m }
From source file:org.sonar.server.computation.task.projectanalysis.source.SymbolsLineReader.java
private static void putForTextRange(SetMultimap<Integer, ScannerReport.Symbol> res, ScannerReport.Symbol symbol, ScannerReport.TextRange declaration) { for (int i = declaration.getStartLine(); i <= declaration.getEndLine(); i++) { res.put(i, symbol); }//from ww w . j a v a 2 s. co m }
From source file:com.google.template.soy.internal.proto.Field.java
/** Returns the set of fields indexed by soy accessor name for the given type. */ public static <T extends Field> ImmutableMap<String, T> getFieldsForType(Descriptor descriptor, Set<FieldDescriptor> extensions, Factory<T> factory) { ImmutableMap.Builder<String, T> fields = ImmutableMap.builder(); for (FieldDescriptor fieldDescriptor : descriptor.getFields()) { if (ProtoUtils.shouldJsIgnoreField(fieldDescriptor)) { continue; }//from w w w . jav a 2s .c o m T field = factory.create(fieldDescriptor); fields.put(field.getName(), field); } SetMultimap<String, T> extensionsBySoyName = MultimapBuilder.hashKeys().hashSetValues().build(); for (FieldDescriptor extension : extensions) { T field = factory.create(extension); extensionsBySoyName.put(field.getName(), field); } for (Map.Entry<String, Set<T>> group : Multimaps.asMap(extensionsBySoyName).entrySet()) { Set<T> ambiguousFields = group.getValue(); String fieldName = group.getKey(); if (ambiguousFields.size() == 1) { fields.put(fieldName, Iterables.getOnlyElement(ambiguousFields)); } else { T value = factory.createAmbiguousFieldSet(ambiguousFields); logger.severe("Proto " + descriptor.getFullName() + " has multiple extensions with the name \"" + fieldName + "\": " + fullFieldNames(ambiguousFields) + "\nThis field will not be accessible from soy"); fields.put(fieldName, value); } } return fields.build(); }