List of usage examples for com.google.common.collect ArrayListMultimap create
public static <K, V> ArrayListMultimap<K, V> create()
From source file:com.mgmtp.perfload.core.console.meta.LtMetaInfoHandler.java
/** * Creates meta information on a test.//from w ww .j a v a 2 s . c o m * * @param startTimestamp * timestamp taken at test finish * @param finishTimestamp * timestamp taken at test start * @param config * the {@link com.mgmtp.perfload.core.common.config.TestplanConfig} instance * @return the meta information object */ public LtMetaInfo createMetaInformation(final ZonedDateTime startTimestamp, final ZonedDateTime finishTimestamp, final TestplanConfig config, final List<Daemon> daemons) { LtMetaInfo metaInfo = new LtMetaInfo(); metaInfo.setStartTimestamp(startTimestamp); metaInfo.setFinishTimestamp(finishTimestamp); metaInfo.setTestplanFileName(config.getTestplanFile().getName()); metaInfo.addDaemons(daemons); ListMultimap<String, String> operationsByTargets = ArrayListMultimap.create(); for (TestConfig testConfig : config.getTestConfigs().values()) { for (LoadProfileEvent event : testConfig.getLoadProfileEvents()) { operationsByTargets.put(event.getTarget(), event.getOperation()); } } Set<String> uniqueOperations = newHashSet(operationsByTargets.values()); metaInfo.setLoadProfileTestInfo(operationsByTargets.keySet(), uniqueOperations); for (Entry<String, Collection<String>> entry : operationsByTargets.asMap().entrySet()) { String target = entry.getKey(); Collection<String> operations = entry.getValue(); for (final String operation : uniqueOperations) { int executions = Collections2.filter(operations, new Predicate<String>() { @Override public boolean apply(final String input) { return input.equals(operation); } }).size(); metaInfo.addExecutions(operation, target, executions); } } return metaInfo; }
From source file:de.unidue.inf.is.ezdl.dlcore.message.content.UserLogNotify.java
/** * Creates a new log event./*from ww w . ja v a 2 s. com*/ * <p> * The client-local time stamp is set to the time at the creation of this * object. * * @param sessionId * the session ID to log the event for * @param eventName * the name of the event. Please consult {@link UserLogConstants} * for some possible values. To ensure consistent logging, make * sure that the name of the event doesn't change over time. */ public UserLogNotify(String sessionId, String eventName) { super(); this.clientTimestamp = System.currentTimeMillis(); this.sessionId = sessionId; this.eventName = eventName; this.parameters = ArrayListMultimap.create(); }
From source file:com.cisco.oss.foundation.tools.simulator.rest.service.SimulatorService.java
public boolean addSimulator(int port) throws Exception { String serverName = "ServerSim_" + port; ConfigurationFactory.getConfiguration().setProperty(serverName + ".http.port", port); if (simulatorExists(port)) { logger.error("simulator on port " + port + " already exists"); return false; }/*w ww .j av a 2 s . c o m*/ ResourceConfig resourceConfig = new ResourceConfig(); resourceConfig.packages("com.cisco.oss.foundation.tools"); ServletContainer servletContainer = new ServletContainer(resourceConfig); ListMultimap<String, Servlet> servlets = ArrayListMultimap.create(); servlets.put("/*", servletContainer); JettyHttpServerFactory.INSTANCE.startHttpServer(serverName, servlets); // Server server = new Server(port); // // Context root = new Context(server, "/", Context.SESSIONS); // ServletHolder holder = new ServletHolder(servletContainer); // root.addServlet(holder, "/"); // try { // server.start(); // } catch (BindException e) { // logger.error("can't create simulator", e); // return false; // } // holder.setInitParameter("port", Integer.toString(port)); logger.debug("simulator was added on port:" + port); SimulatorEntity simulatorEntity = new SimulatorEntity(port); simulators.put(port, simulatorEntity); return true; }
From source file:org.apache.archiva.redback.common.ldap.role.DefaultLdapRoleMapperConfiguration.java
public Map<String, Collection<String>> getLdapGroupMappings() { Multimap<String, String> map = ArrayListMultimap.create(); Collection<String> keys = userConf.getKeys(); for (String key : keys) { if (key.startsWith(UserConfigurationKeys.LDAP_GROUPS_ROLE_START_KEY)) { String val = userConf.getString(key); String[] roles = StringUtils.split(val, ','); for (String role : roles) { map.put(StringUtils.substringAfter(key, UserConfigurationKeys.LDAP_GROUPS_ROLE_START_KEY), role);/* w w w. ja v a2 s . c o m*/ } } } for (Map.Entry<String, List<String>> entry : this.ldapMappings.entrySet()) { map.putAll(entry.getKey(), entry.getValue()); } Map<String, Collection<String>> mappings = map.asMap(); return mappings; }
From source file:org.franca.core.ui.addons.contractviewer.util.IntermediateFrancaGraphModel.java
public IntermediateFrancaGraphModel(FModel model, boolean displayLabel) { this.displayLabel = displayLabel; this.states = new ArrayList<String>(); this.connectionMap = ArrayListMultimap.create(); this.generator = new ContractDotGenerator(); buildFromModel(model);//from w w w . java 2s .c o m }
From source file:org.kiji.common.flags.FlagParser.java
/** * Parse the flags out of the command line arguments. The non flag args are put into * nonFlagArgs./* w w w .j av a 2 s. co m*/ * * @param args The arguments to parse. * @param nonFlagArgs The remaining non-flag arguments. * @param declaredFlags Declared flag map. * @param ignoreUnknownFlags When set, unknown flags behave like non-flag arguments. * * @return A map from flag-name to the list of all values specified for the flag, in order. * * @throws UnrecognizedFlagException when encountering an unknown flag name while * ignoreUnknownFlags is not set. */ private static ListMultimap<String, String> parseArgs(String[] args, List<String> nonFlagArgs, Map<String, FlagSpec> declaredFlags, boolean ignoreUnknownFlags) throws UnrecognizedFlagException { final ListMultimap<String, String> parsedFlags = ArrayListMultimap.create(); boolean ignoreTheRest = false; for (String arg : args) { if (ignoreTheRest) { nonFlagArgs.add(arg); continue; } if (arg.equals(END_FLAG_SYMBOL)) { // Ignore all arguments after this special symbol: ignoreTheRest = true; continue; } final Matcher matcher = FLAG_RE.matcher(arg); if (!matcher.matches()) { // Non-flag argument: nonFlagArgs.add(arg); continue; } final String flagName = matcher.group(1); final String flagValue = matcher.group(3); // may be null if (declaredFlags.containsKey(flagName) || flagName.equals(HELP_FLAG_NAME)) { parsedFlags.put(flagName, flagValue); } else if (ignoreUnknownFlags) { // Flag argument but unknown flag name: nonFlagArgs.add(arg); } else { throw new UnrecognizedFlagException(flagName); } } return parsedFlags; }
From source file:org.apache.giraph.edge.HashMultimapEdges.java
@Override public void initialize() { edgeMultimap = ArrayListMultimap.create(); }
From source file:com.android.build.gradle.external.gnumake.FlowAnalyzer.java
/** * Build the flow analysis for the given set of classifications. * This tracks library files back through the {@link BuildStepInfo} call chain and * attributes source input files (.c and .cpp) to resulting library files (.so) * * @return ListMultimap where keys are the library names and values are a list of * {@link BuildStepInfo} of the source files used to create the library. *///ww w . ja v a2s. com static ListMultimap<String, List<BuildStepInfo>> analyze(String commands, boolean isWin32) { List<BuildStepInfo> commandSummaries = CommandClassifier.classify(commands, isWin32); // For each filename, record the last command that created it. Map<String, Integer> outputToCommand = new HashMap<>(); // For each command, the set of terminal inputs. ArrayList<Set<BuildStepInfo>> outputToTerminals = new ArrayList<>(); // For each command, the set of outputs that was consumed. SparseArray<Set<String>> commandOutputsConsumed = new SparseArray<>(); for (int i = 0; i < commandSummaries.size(); ++i) { BuildStepInfo current = commandSummaries.get(i); if (current.inputsAreSourceFiles()) { if (current.getInputs().size() != 1) { throw new RuntimeException(String.format( "GNUMAKE: Expected exactly one source file in compile step:" + " %s\nbut received: \n%s", current, Joiner.on("\n").join(current.getInputs()))); } } commandOutputsConsumed.put(i, new HashSet<>()); // For each input, find the line that created it or null if this is a terminal input. Set<BuildStepInfo> terminals = new HashSet<>(); for (String input : current.getInputs()) { if (outputToCommand.containsKey(input)) { int inputCommandIndex = outputToCommand.get(input); terminals.addAll(outputToTerminals.get(inputCommandIndex)); // Record this a consumed output. commandOutputsConsumed.get(inputCommandIndex).add(input); continue; } if (current.inputsAreSourceFiles()) { terminals.add(current); } } outputToTerminals.add(terminals); // Record the files output by this command for (String output : current.getOutputs()) { outputToCommand.put(output, i); } } // Emit the outputs that are never consumed. ListMultimap<String, List<BuildStepInfo>> result = ArrayListMultimap.create(); for (int i = 0; i < commandSummaries.size(); ++i) { BuildStepInfo current = commandSummaries.get(i); Set<String> outputsConsumed = commandOutputsConsumed.get(i); for (String output : current.getOutputs()) { if (!outputsConsumed.contains(output) || !current.inputsAreSourceFiles()) { // Sort the inputs List<BuildStepInfo> ordered = new ArrayList<>(); ordered.addAll(outputToTerminals.get(i)); Collections.sort(ordered, (o1, o2) -> o1.getOnlyInput().compareTo(o2.getOnlyInput())); result.put(output, ordered); } } } return result; }
From source file:org.obiba.opal.web.gwt.app.client.report.list.ReportsView.java
@Override public void setReportTemplates(JsArray<ReportTemplateDto> templates) { reportList.clear();/*w ww.j a va2 s . com*/ // group templates by project Multimap<String, ReportTemplateDto> templateMap = ArrayListMultimap.create(); for (ReportTemplateDto template : JsArrays.toIterable(JsArrays.toSafeArray(templates))) { templateMap.get(template.getProject()).add(template); } for (String project : templateMap.keySet()) { reportList.add(new NavHeader( TranslationsUtils.replaceArguments(translations.reportTemplatesHeader(), project))); addReportTemplateLinks(templateMap.get(project)); } }
From source file:org.wso2.msf4j.security.JWTSecurityInterceptor.java
public boolean preCall(HttpRequest request, HttpResponder responder, ServiceMethodInfo serviceMethodInfo) { HttpHeaders headers = request.headers(); boolean isValidSignature; if (headers != null) { String jwtHeader = headers.get(JWT_HEADER); if (jwtHeader != null) { isValidSignature = verifySignature(jwtHeader); if (isValidSignature) { return true; }/* www . j a v a2 s . com*/ } } Multimap<String, String> map = ArrayListMultimap.create(); map.put(HttpHeaders.Names.WWW_AUTHENTICATE, AUTH_TYPE_JWT); responder.sendStatus(HttpResponseStatus.UNAUTHORIZED, map); return false; }