Example usage for com.google.common.collect ImmutableMap get

List of usage examples for com.google.common.collect ImmutableMap get

Introduction

In this page you can find the example usage for com.google.common.collect ImmutableMap get.

Prototype

V get(Object key);

Source Link

Document

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

Usage

From source file:com.google.caliper.runner.config.CaliperConfig.java

public VmConfig getVmConfig(String name) {
    checkNotNull(name);//from   w  w w.  j a v a 2 s. c om
    ImmutableMap<String, String> vmGroupMap = subgroupMap(properties, "vm");
    ImmutableMap<String, String> vmMap = subgroupMap(vmGroupMap, name);
    VmConfig.Builder builder = VmConfig.builder().name(name);
    String type = vmMap.get("type");
    if (type != null) {
        builder.type(VmType.of(type));
    }
    String home = vmMap.get("home");
    if (home != null) {
        builder.home(home);
    }
    String executable = vmMap.get("executable");
    if (executable != null) {
        builder.executable(executable);
    }
    return builder.addAllArgs(getVmArgs()).addAllArgs(getArgs(vmMap)).build();
}

From source file:esun.org.apache.flume.plugins.KafkaSource.java

/**
 * Configure void./*from  w  w w. ja  v  a  2  s .  c  o  m*/
 *
 * @param context the context
 */
@Override
public void configure(Context context) {
    this.context = context;
    ImmutableMap<String, String> props = context.getParameters();

    this.parameters = new Properties();
    for (String key : props.keySet()) {
        String value = props.get(key);
        this.parameters.put(key, value);
    }

    //source monitoring count
    if (sourceCounter == null) {
        sourceCounter = new SourceCounter(getName());
    }
}

From source file:net.lldp.checksims.ChecksimsCommandLine.java

/**
 * Parse CLI arguments and run Checksims from them.
 *
 * TODO add unit tests//from   ww  w . j a v  a 2s. co  m
 *
 * @param args CLI arguments to parse
 * @throws ParseException Thrown on error parsing CLI arguments
 * @throws ChecksimsException Thrown on invalid CLI arguments or error running Checksims
 * @throws IOException Thrown on error building a submission from files or writing output to file
 */
public static void runCLI(String[] args) throws ParseException, ChecksimsException, IOException {
    checkNotNull(args);

    // Parse options, first round: nothing required, so we can check for --help and --version
    CommandLine cli = parseOpts(args, false);

    // Print CLI Help
    if (cli.hasOption("h")) {
        printHelp();
    }

    // Print version
    if (cli.hasOption("version")) {
        System.err.println("Checksims version " + ChecksimsRunner.getChecksimsVersion());
        System.exit(0);
    }

    // Parse options, second round: required arguments are required
    cli = parseOpts(args, true);

    // Parse verbose setting
    if (cli.hasOption("vv")) {
        logs = startLogger(2);
    } else if (cli.hasOption("v")) {
        logs = startLogger(1);
    } else {
        logs = startLogger(0);
    }

    // First, parse basic flags
    ChecksimsConfig config = parseBaseFlags(cli);

    // Parse file flags
    ChecksimsConfig finalConfig = parseFileFlags(cli, config);

    // Run Checksims with this config
    ImmutableMap<String, String> output = ChecksimsRunner.runChecksims(finalConfig);

    // Check if file output specified
    if (cli.hasOption("f")) {
        // Writing to a file
        // Get the filename
        String outfileBaseName = cli.getOptionValue("f");

        // Output for all specified strategies
        for (String strategy : output.keySet()) {
            // Final filename is the basename specified through CLI, with the strategy name as its extension.
            File outfile = new File(outfileBaseName + "." + strategy);

            logs.info("Writing " + strategy + " output to " + outfile.getName());

            FileUtils.writeStringToFile(outfile, output.get(strategy), StandardCharsets.UTF_8);
        }
    } else {
        // Just outputting to STDOUT
        for (String strategy : output.keySet()) {
            System.out.println("\n\n");
            System.out.println("Output from " + strategy + "\n");
            System.out.println(output.get(strategy));
        }
    }

    logs.trace("CLI parsing complete!");
}

From source file:dagger.internal.codegen.SimpleMethodBindingExpression.java

@Override
Expression getDependencyExpression(ClassName requestingClass) {
    ImmutableMap<DependencyRequest, Expression> arguments = ImmutableMap.copyOf(Maps
            .asMap(provisionBinding.dependencies(), request -> dependencyArgument(request, requestingClass)));
    Function<DependencyRequest, CodeBlock> argumentsFunction = request -> arguments.get(request).codeBlock();
    return requiresInjectionMethod(provisionBinding, arguments.values().asList(), compilerOptions,
            requestingClass.packageName(), types) ? invokeInjectionMethod(argumentsFunction, requestingClass)
                    : invokeMethod(argumentsFunction, requestingClass);
}

From source file:io.github.mywarp.mywarp.bukkit.SquirrelIdPlayerNameResolver.java

@Override
public CompletableFuture<Set<io.github.mywarp.mywarp.platform.Profile>> getByUniqueId(
        Iterable<UUID> uniqueIds) {
    return CompletableFuture.supplyAsync(() -> {
        ImmutableMap<UUID, Profile> allPresent = cache.getAllPresent(uniqueIds);
        Set<io.github.mywarp.mywarp.platform.Profile> ret = new HashSet<>();

        uniqueIds.forEach(uuid -> {//w  w w.j  a  v  a2 s  . co m
            Profile profile = allPresent.get(uuid);
            if (profile != null) {
                ret.add(BukkitProfile.of(profile));
            }
        });

        return ret;
    }, executorService);
}

From source file:controllers.api.IndicesApiController.java

public Result indexInfo(String indexName) {
    try {//from ww w .  j  a v  a2s  .c  om
        final List<Index> indexes = indexService.all();
        final ImmutableMap<String, Index> map = Maps.uniqueIndex(indexes, new Function<Index, String>() {
            @Nullable
            @Override
            public String apply(Index input) {
                return input.getName();
            }
        });

        final Index index = map.get(indexName);
        if (index == null) {
            return notFound();
        }
        final String currentTarget = indexService.getDeflectorInfo().currentTarget;
        return ok(views.html.partials.indices.index_info.render(currentTarget, index));

    } catch (APIException | IOException e) {
        return internalServerError();
    }
}

From source file:org.apache.hive.ptest.execution.YetusPhase.java

public YetusPhase(TestConfiguration configuration, List<HostExecutor> hostExecutors,
        LocalCommandFactory localCommandFactory, ImmutableMap<String, String> templateDefaults,
        String workingDir, File scratchDir, Logger logger, File logDir, File patchFile) {

    super(hostExecutors, localCommandFactory, templateDefaults, logger);
    this.mPatchFile = patchFile;
    this.buildTag = templateDefaults.get("buildTag");
    this.mWorkingDir = new File(workingDir, YETUS_OUTPUT_FOLDER + "_" + this.buildTag);
    this.mLogFile = new File(logDir, YETUS_LOG_FILE);
    this.mOutputDir = new File(logDir, YETUS_OUTPUT_FOLDER);
    this.mScratchDir = scratchDir;
    this.conf = configuration;
    this.buildUrl = conf.getLogsURL() + "/" + this.buildTag + "/";

}

From source file:org.sosy_lab.cpachecker.cpa.sign.SignState.java

public SignState enterFunction(ImmutableMap<String, SIGN> pArguments) {
    PersistentMap<String, SIGN> newMap = signMap;

    for (String var : pArguments.keySet()) {
        if (!pArguments.get(var).equals(SIGN.ALL)) {
            newMap = newMap.putAndCopy(var, pArguments.get(var));
        }/*from  www  .j a va 2s .  c  o  m*/
    }

    return signMap == newMap ? this : new SignState(newMap);
}

From source file:com.google.caliper.config.CaliperConfig.java

public VmConfig getVmConfig(String name) throws InvalidConfigurationException {
    checkNotNull(name);/*w  w  w.j a  v a 2s  .  c o m*/
    ImmutableMap<String, String> vmGroupMap = subgroupMap(properties, "vm");
    ImmutableMap<String, String> vmMap = subgroupMap(vmGroupMap, name);
    File homeDir = getJdkHomeDir(vmGroupMap.get("baseDirectory"), vmMap.get("home"), name);
    return new VmConfig.Builder(homeDir).addAllOptions(getArgs(vmGroupMap)).addAllOptions(getArgs(vmMap))
            .build();
}

From source file:net.minecrell.workbench.tools.mapping.BaseMappings.java

@SuppressWarnings("unchecked")
private <T extends Name> ImmutableBiMap<T, T> apply(ImmutableBiMap<T, T> mappings,
        ImmutableMap<String, BaseName> base, Consumer<T> consumer) {
    ImmutableBiMap.Builder<T, T> builder = ImmutableBiMap.builder();
    mappings.forEach((original, mapped) -> {
        BaseName name = base.get(original.getName());
        if (name != null) {
            T result = (T) original.apply(context, name);
            if (consumer != null) {
                consumer.accept(result);
            }/*from  w  w w.  j a va2s  . co  m*/
            builder.put(original, result);
        }
    });
    return builder.build();
}