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

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

Introduction

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

Prototype

public ImmutableSet<K> keySet() 

Source Link

Usage

From source file:org.spongepowered.granite.mixin.block.state.MixinBlockState.java

@Override
@SuppressWarnings("unchecked")
public Optional<? extends Comparable<?>> getPropertyValue(String name) {
    ImmutableMap<IProperty, Comparable<?>> properties = ((IBlockState) this).getProperties();
    for (IProperty property : properties.keySet()) {
        if (property.getName().equals(name)) {
            return Optional.fromNullable(properties.get(property));
        }/*from www . j  a  va2s  .  com*/
    }

    return Optional.absent();
}

From source file:org.spongepowered.granite.mixin.block.state.MixinBlockState.java

@Override
@SuppressWarnings("unchecked")
public Optional<BlockProperty<?>> getPropertyByName(String name) {
    ImmutableMap<IProperty, Comparable<?>> properties = ((IBlockState) this).getProperties();
    for (IProperty property : properties.keySet()) {
        if (property.getName().equals(name)) {
            // The extra specification here is because Java auto-detects <? extends BlockProperty<?>>
            return Optional.<BlockProperty<?>>fromNullable((BlockProperty<?>) property);
        }/*from  w ww  .ja v a 2 s .c  o m*/
    }

    return Optional.absent();
}

From source file:org.elasticsearch.rest.action.cat.RestNodeAttrsAction.java

private Table buildTable(RestRequest req, ClusterStateResponse state, NodesInfoResponse nodesInfo,
        NodesStatsResponse nodesStats) {
    boolean fullId = req.paramAsBoolean("full_id", false);

    DiscoveryNodes nodes = state.getState().nodes();
    Table table = getTableWithHeader(req);

    for (DiscoveryNode node : nodes) {
        NodeInfo info = nodesInfo.getNodesMap().get(node.id());
        ImmutableMap<String, String> attrs = node.getAttributes();
        for (String att : attrs.keySet()) {
            table.startRow();//w ww  .  java2s.  c  o m
            table.addCell(node.name());
            table.addCell(fullId ? node.id() : Strings.substring(node.getId(), 0, 4));
            table.addCell(info == null ? null : info.getProcess().getId());
            table.addCell(node.getHostName());
            table.addCell(node.getHostAddress());
            if (node.address() instanceof InetSocketTransportAddress) {
                table.addCell(((InetSocketTransportAddress) node.address()).address().getPort());
            } else {
                table.addCell("-");
            }
            table.addCell(att);
            table.addCell(attrs.containsKey(att) ? attrs.get(att) : null);
            table.endRow();
        }
    }

    return table;
}

From source file:com.intel.hibench.stormbench.trident.functions.Identity.java

@Override
public Values execute(TridentTuple tridentTuple) {
    ImmutableMap<String, String> kv = (ImmutableMap<String, String>) tridentTuple.getValue(0);
    LatencyReporter reporter = new KafkaReporter(config.reporterTopic, config.brokerList);
    reporter.report(Long.parseLong(kv.keySet().iterator().next()), System.currentTimeMillis());
    return new Values(kv);
}

From source file:org.onosproject.segmentrouting.cli.LinkStateCommand.java

private void printLinkState(ImmutableMap<Link, Boolean> seenLinks,
        ImmutableMap<DeviceId, Set<PortNumber>> downedPortState) {
    List<Link> a = Lists.newArrayList();
    a.addAll(seenLinks.keySet());
    a.sort(new CompLinks());

    StringBuilder slbldr = new StringBuilder();
    slbldr.append("\n Seen Links: ");
    for (int i = 0; i < a.size(); i++) {
        slbldr.append("\n " + (seenLinks.get(a.get(i)) == Boolean.TRUE ? "  up : " : "down : "));
        slbldr.append(a.get(i).src() + " --> " + a.get(i).dst());
    }/* ww  w .ja  v a2  s.c om*/
    print(FORMAT_MAPPING, slbldr.toString());

    StringBuilder dpbldr = new StringBuilder();
    dpbldr.append("\n\n Administratively Disabled Ports: ");
    downedPortState.entrySet().forEach(entry -> dpbldr.append("\n " + entry.getKey() + entry.getValue()));
    print(FORMAT_MAPPING, dpbldr.toString());
}

From source file:com.facebook.buck.android.exopackage.NativeExoHelper.java

/** @return a mapping from destinationPathOnDevice -> localPath */
public ImmutableMap<Path, Path> getFilesToInstall() throws IOException {
    ImmutableMap.Builder<Path, Path> filesToInstallBuilder = ImmutableMap.builder();
    ImmutableMap<String, ImmutableMultimap<String, Path>> filesByHashForAbis = getFilesByHashForAbis();
    for (String abi : filesByHashForAbis.keySet()) {
        ImmutableMultimap<String, Path> filesByHash = Objects.requireNonNull(filesByHashForAbis.get(abi));
        Path abiDir = NATIVE_LIBS_DIR.resolve(abi);
        for (Entry<Path, Collection<Path>> entry : ExopackageUtil
                .applyFilenameFormat(filesByHash, abiDir, "native-%s.so").asMap().entrySet()) {
            // The files in the getValue collection should all be identical
            // (because the key in their hash), so just pick the first one.
            filesToInstallBuilder.put(entry.getKey(), entry.getValue().iterator().next());
        }//w w w . j  av  a2  s . c  o  m
    }
    return filesToInstallBuilder.build();
}

From source file:com.facebook.buck.config.resources.AbstractResourcesConfig.java

public ImmutableMap<String, ResourceAmounts> getResourceAmountsPerRuleType() {
    ImmutableMap.Builder<String, ResourceAmounts> result = ImmutableMap.builder();
    ImmutableMap<String, String> entries = getDelegate()
            .getEntriesForSection(RESOURCES_PER_RULE_SECTION_HEADER);
    for (String ruleName : entries.keySet()) {
        ImmutableList<String> configAmounts = getDelegate()
                .getListWithoutComments(RESOURCES_PER_RULE_SECTION_HEADER, ruleName);
        Preconditions.checkArgument(configAmounts.size() == ResourceAmounts.RESOURCE_TYPE_COUNT,
                "Buck config entry [%s].%s contains %s values, but expected to contain %s values "
                        + "in the following order: cpu, memory, disk_io, network_io",
                RESOURCES_PER_RULE_SECTION_HEADER, ruleName, configAmounts.size(),
                ResourceAmounts.RESOURCE_TYPE_COUNT);
        ResourceAmounts amounts = ResourceAmounts.of(Integer.parseInt(configAmounts.get(0)),
                Integer.parseInt(configAmounts.get(1)), Integer.parseInt(configAmounts.get(2)),
                Integer.parseInt(configAmounts.get(3)));
        result.put(ruleName, amounts);//from   w  w w .  ja v a2s  . co m
    }
    return result.build();
}

From source file:com.qubole.quark.plugins.qubole.QuboleDB.java

private Integer getType(String dataType) throws QuarkException {
    if (DATA_TYPES.containsKey(dataType)) {
        return DATA_TYPES.get(dataType);
    } else {/* ww w  . j av  a2  s  .  c o m*/
        ImmutableMap<String, Integer> dataTypes = this.getDataTypes();
        for (String key : dataTypes.keySet()) {
            if (dataType.matches(key)) {
                return dataTypes.get(key);
            }
        }
    }

    throw new QuarkException("Unknown DataType `" + dataType + "`");
}

From source file:org.zanata.client.BashCompletionGenerator.java

public BashCompletionGenerator() {
    ImmutableMap<String, Class<BasicOptions>> commands = ZanataClient.OPTIONS;
    baseCommands = ImmutableList.copyOf(commands.keySet());
    commandName = ZanataClient.COMMAND_NAME;
    commandDescription = ZanataClient.COMMAND_DESCRIPTION;
    genericOptions = getOptions(ZanataClient.class);
    allOptions.addAll(genericOptions);/*from  www  .ja  v a  2s .  c o  m*/

    for (String commandName : commands.keySet()) {
        List<Option> options = getOptions(commands.get(commandName));
        // do we still want generic options to appear?
        // options.removeAll(genericOptions);
        commandOptions.put(commandName, options);
        allOptions.addAll(options);
    }
}

From source file:com.big.data.plan.KafkaSink.java

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

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