Example usage for com.google.common.collect Maps immutableEntry

List of usage examples for com.google.common.collect Maps immutableEntry

Introduction

In this page you can find the example usage for com.google.common.collect Maps immutableEntry.

Prototype

@GwtCompatible(serializable = true)
public static <K, V> Entry<K, V> immutableEntry(@Nullable K key, @Nullable V value) 

Source Link

Document

Returns an immutable map entry with the specified key and value.

Usage

From source file:org.onosproject.store.primitives.impl.TranscodingAsyncConsistentTreeMap.java

@Override
public CompletableFuture<Map.Entry<String, Versioned<V1>>> floorEntry(String key) {
    return backingMap.floorEntry(key).thenApply(
            entry -> Maps.immutableEntry(entry.getKey(), versionedValueTransform.apply(entry.getValue())));
}

From source file:org.jooby.internal.spec.RouteCollector.java

@Override
public void visit(final MethodDeclaration m, final Context ctx) {
    if (!script) {
        boolean mvc = m.getAnnotations().stream().map(it -> it.getName().getName())
                .filter(Route.METHODS::contains).findFirst().isPresent();
        if (mvc) {
            nodes.add(Maps.immutableEntry(m, m.getBody()));
        }//from ww  w. j  a  va  2 s .  c o  m
    }
}

From source file:org.apache.accumulo.minicluster.impl.MiniAccumuloClusterControl.java

@Override
public Entry<Integer, String> execWithStdout(Class<?> clz, String[] args) throws IOException {
    Process p = cluster.exec(clz, args);
    int exitCode;
    try {//from   w  ww . jav a  2s. c  o  m
        exitCode = p.waitFor();
    } catch (InterruptedException e) {
        log.warn("Interrupted waiting for process to exit", e);
        Thread.currentThread().interrupt();
        throw new IOException(e);
    }
    for (LogWriter writer : cluster.getLogWriters()) {
        writer.flush();
    }
    return Maps.immutableEntry(exitCode, readAll(new FileInputStream(
            cluster.getConfig().getLogDir() + "/" + clz.getSimpleName() + "_" + p.hashCode() + ".out")));
}

From source file:org.onosproject.store.primitives.impl.TranscodingAsyncConsistentTreeMap.java

@Override
public CompletableFuture<Map.Entry<String, Versioned<V1>>> higherEntry(String key) {
    return backingMap.higherEntry(key).thenApply(
            entry -> Maps.immutableEntry(entry.getKey(), versionedValueTransform.apply(entry.getValue())));
}

From source file:com.facebook.presto.Session.java

public Session(QueryId queryId, Identity identity, Optional<String> source, Optional<String> catalog,
        Optional<String> schema, TimeZoneKey timeZoneKey, Locale locale, Optional<String> remoteUserAddress,
        Optional<String> userAgent, long startTime, Map<String, String> systemProperties,
        Map<String, Map<String, String>> catalogProperties, SessionPropertyManager sessionPropertyManager) {
    this.queryId = requireNonNull(queryId, "queryId is null");
    this.identity = identity;
    this.source = requireNonNull(source, "source is null");
    this.catalog = requireNonNull(catalog, "catalog is null");
    this.schema = requireNonNull(schema, "schema is null");
    this.timeZoneKey = requireNonNull(timeZoneKey, "timeZoneKey is null");
    this.locale = requireNonNull(locale, "locale is null");
    this.remoteUserAddress = requireNonNull(remoteUserAddress, "remoteUserAddress is null");
    this.userAgent = requireNonNull(userAgent, "userAgent is null");
    this.startTime = startTime;
    this.systemProperties = ImmutableMap.copyOf(requireNonNull(systemProperties, "systemProperties is null"));
    this.sessionPropertyManager = requireNonNull(sessionPropertyManager, "sessionPropertyManager is null");

    ImmutableMap.Builder<String, Map<String, String>> catalogPropertiesBuilder = ImmutableMap
            .<String, Map<String, String>>builder();
    catalogProperties.entrySet().stream()
            .map(entry -> Maps.immutableEntry(entry.getKey(), ImmutableMap.copyOf(entry.getValue())))
            .forEach(catalogPropertiesBuilder::put);
    this.catalogProperties = catalogPropertiesBuilder.build();

    checkArgument(catalog.isPresent() || !schema.isPresent(), "schema is set but catalog is not");
}

From source file:ninja.leaping.permissionsex.backend.memory.MemoryDataStore.java

@Override
public boolean isRegistered(String type, String identifier) {
    return data.containsKey(Maps.immutableEntry(type, identifier));
}

From source file:ninja.leaping.permissionsex.command.PermissionsExCommands.java

public static CommandSpec createRootCommand(final PermissionsEx pex) {
    final Set<CommandSpec> childrenList = ImmutableSet.<CommandSpec>builder()
            .addAll(pex.getImplementationCommands()).add(getDebugToggleCommand(pex))
            .add(RankingCommands.getRankingCommand(pex)).add(getImportCommand(pex)).add(getReloadCommand(pex))
            .build();/*from  www. j a  v a 2 s .c om*/

    final CommandElement children = ChildCommands
            .args(childrenList.toArray(new CommandSpec[childrenList.size()]));
    final CommandElement subjectChildren = ChildCommands.args(OptionCommands.getOptionCommand(pex),
            PermissionsCommands.getPermissionCommand(pex), PermissionsCommands.getPermissionDefaultCommand(pex),
            InfoCommand.getInfoCommand(pex), ParentCommands.getParentCommand(pex),
            DeleteCommand.getDeleteCommand(pex));

    return CommandSpec.builder().setAliases("pex", "permissionsex", "permissions")
            .setDescription(t("Commands for PermissionsEx"))
            .setArguments(optional(firstParsing(children,
                    Util.contextTransientFlags().buildWith(seq(subject(t("subject"), pex), subjectChildren)),
                    flags().flag("-transient").buildWith(seq(subjectType(t("subject-type"), pex),
                            literal(t("list"), "list"), optional(string(t("filter"))))))))
            .setExecutor(new CommandExecutor() {
                @Override
                public <TextType> void execute(final Commander<TextType> src, CommandContext args)
                        throws CommandException {
                    if (args.hasAny("list")) {
                        final String subjectType = args.getOne("subject-type");
                        args.checkPermission(src, "permissionsex.command.list." + subjectType);
                        SubjectCache cache = args.hasAny("transient") ? pex.getTransientSubjects(subjectType)
                                : pex.getSubjects(subjectType);
                        Iterable<String> iter = cache.getAllIdentifiers();
                        if (args.hasAny("filter")) {
                            iter = Iterables.filter(iter,
                                    new StartsWithPredicate(args.<String>getOne("filter")));
                        }

                        src.msgPaginated(t("%s subjects", subjectType),
                                t("All subjects of type %s", subjectType),
                                Iterables.transform(iter, new Function<String, TextType>() {
                                    @Nullable
                                    @Override
                                    public TextType apply(String input) {
                                        return src.fmt().subject(Maps.immutableEntry(subjectType, input));
                                    }
                                }));
                    } else if (args.hasAny(subjectChildren.getKey().getUntranslated())) {
                        ChildCommands.executor(subjectChildren).execute(src, args);
                    } else if (args.hasAny(children.getKey().getUntranslated())) {
                        ChildCommands.executor(children).execute(src, args);
                    } else {
                        src.msg(src.fmt().combined("PermissionsEx ",
                                src.fmt().hl(src.fmt().combined("v", pex.getVersion()))));
                        src.msg(args.getSpec().getUsage(src));
                    }
                }
            }).build();
}

From source file:org.apache.accumulo.miniclusterImpl.MiniAccumuloClusterControl.java

@SuppressFBWarnings(value = "PATH_TRAVERSAL_IN", justification = "code runs in same security context as user who provided input file name")
@Override/*  w  ww .  ja v  a2 s  .  c om*/
public Entry<Integer, String> execWithStdout(Class<?> clz, String[] args) throws IOException {
    ProcessInfo pi = cluster.exec(clz, args);
    int exitCode;
    try {
        exitCode = pi.getProcess().waitFor();
    } catch (InterruptedException e) {
        log.warn("Interrupted waiting for process to exit", e);
        Thread.currentThread().interrupt();
        throw new IOException(e);
    }

    return Maps.immutableEntry(exitCode, pi.readStdOut());
}

From source file:org.icgc.dcc.download.job.core.DefaultDownloadJob.java

private static Entry<? extends Task, ? extends TaskContext> createClinical(JobContext jobContext) {
    val dataTypes = filterClinical(jobContext.getDataTypes());
    val taskContext = createTaskContext(jobContext, dataTypes);

    return Maps.immutableEntry(new ClinicalTask(), taskContext);
}

From source file:io.atomix.core.multimap.impl.TranscodingAsyncAtomicMultimap.java

public TranscodingAsyncAtomicMultimap(AsyncAtomicMultimap<K2, V2> backingMap, Function<K1, K2> keyEncoder,
        Function<K2, K1> keyDecoder, Function<V1, V2> valueEncoder, Function<V2, V1> valueDecoder) {
    super(backingMap);
    this.backingMap = backingMap;
    this.keyEncoder = k -> k == null ? null : keyEncoder.apply(k);
    this.keyDecoder = k -> k == null ? null : keyDecoder.apply(k);
    this.valueEncoder = v -> v == null ? null : valueEncoder.apply(v);
    this.valueDecoder = v -> v == null ? null : valueDecoder.apply(v);
    this.entryEncoder = e -> Maps.immutableEntry(this.keyEncoder.apply(e.getKey()),
            this.valueEncoder.apply(e.getValue()));
    this.entryDecoder = e -> Maps.immutableEntry(this.keyDecoder.apply(e.getKey()),
            this.valueDecoder.apply(e.getValue()));
    this.versionedValueEncoder = v -> v == null ? null
            : new Versioned<>(v.value().stream().map(valueEncoder).collect(Collectors.toSet()), v.version(),
                    v.creationTime());//from   www.  j  a  v a 2 s .c  om
    this.versionedValueDecoder = v -> v == null ? null
            : new Versioned<>(v.value().stream().map(valueDecoder).collect(Collectors.toSet()), v.version(),
                    v.creationTime());
    this.valueCollectionEncode = v -> v == null ? null
            : v.stream().map(valueEncoder).collect(Collectors.toSet());
}