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:com.google.devtools.build.lib.rules.objc.RuleType.java

/**
 * Generates the String necessary to define a target of this rule type.
 *
 * @param packageDir the package in which to create the target
 * @param name the name of the target//from   w  w w .java 2 s.  c  om
 * @param checkSpecificAttrs alternating name/values of attributes to add to the rule that are
 *     required for the check being performed to be defined a certain way. Pass
 *     {@link #OMIT_REQUIRED_ATTR} for a value to prevent an attribute from being automatically
 *     defined.
 */
final String target(Scratch scratch, String packageDir, String name, String... checkSpecificAttrs)
        throws IOException {
    ImmutableMap<String, String> checkSpecific = map(checkSpecificAttrs);
    StringBuilder target = new StringBuilder(ruleTypeName).append("(name = '").append(name).append("',");
    for (Map.Entry<String, String> entry : checkSpecific.entrySet()) {
        if (entry.getValue().equals(OMIT_REQUIRED_ATTR)) {
            continue;
        }
        target.append(entry.getKey()).append("=").append(entry.getValue()).append(",");
    }
    Joiner.on(",").appendTo(target, requiredAttributes(scratch, packageDir, checkSpecific.keySet()));
    target.append(')');
    return target.toString();

}

From source file:eu.eidas.auth.commons.attribute.ImmutableValueMap.java

/**
 * Returns all the {@link AttributeDefinition}s in the map matching the given friendly name or returns {@code null}
 * if no attribute in this map matches the given {@link AttributeDefinition}.
 *
 * @param friendlyName the attribute friendly name to look up.
 * @return all the {@link AttributeDefinition}s in the map matching the given friendly name or returns {@code null}
 * when there is no match./*from w ww  . j a  v a  2s  .c o  m*/
 */
@Nullable
public ImmutableSet<AttributeDefinition<?>> getDefinitionsByFriendlyName(@Nonnull String friendlyName) {
    ImmutableMap<AttributeDefinition<?>, ImmutableSet<?>> subMap = friendlyNameMap.get(friendlyName);
    if (null == subMap) {
        return null;
    }
    return subMap.keySet();
}

From source file:vazkii.botania.client.model.SpecialFlowerModel.java

@Override
public IModel process(ImmutableMap<String, String> customData) {
    // Load the base variant from blockstate json, and also add all the model paths we received from external API
    ImmutableMap.Builder<Optional<String>, ModelResourceLocation> blockBuilder = ImmutableMap.builder();
    ImmutableMap.Builder<Optional<String>, ModelResourceLocation> itemBuilder = ImmutableMap.builder();

    for (String key : customData.keySet()) {
        if ("base".equals(key)) {
            blockBuilder.put(Optional.empty(), getLocation(customData.get(key)));
        }/*from ww  w . ja va 2s  .c  om*/
    }

    for (Map.Entry<String, ModelResourceLocation> e : BotaniaAPIClient.getRegisteredSubtileBlockModels()
            .entrySet()) {
        blockBuilder.put(Optional.of(e.getKey()), e.getValue());
    }
    for (Map.Entry<String, ModelResourceLocation> e : BotaniaAPIClient.getRegisteredSubtileItemModels()
            .entrySet()) {
        itemBuilder.put(Optional.of(e.getKey()), e.getValue());
    }

    ImmutableMap<Optional<String>, ModelResourceLocation> blockModels = blockBuilder.build();
    ImmutableMap<Optional<String>, ModelResourceLocation> itemModels = itemBuilder.build();
    if (blockModels.isEmpty() && itemModels.isEmpty())
        return INSTANCE;
    return new SpecialFlowerModel(blockModels, itemModels);
}

From source file:org.lanternpowered.server.block.state.LanternBlockState.java

LanternBlockState(LanternBlockStateMap baseState, ImmutableMap<BlockTrait<?>, Comparable<?>> traitValues) {
    this.traitValues = traitValues;
    this.baseState = baseState;

    ImmutableBiMap.Builder<Key<Value<?>>, BlockTrait<?>> builder = ImmutableBiMap.builder();
    for (BlockTrait trait : traitValues.keySet()) {
        builder.put(((LanternBlockTrait) trait).getKey(), trait);
    }/*from  ww w.ja v  a2 s .  com*/
    this.keyToBlockTrait = builder.build();

    final StringBuilder idBuilder = new StringBuilder();
    idBuilder.append(
            baseState.getBlockType().getId().substring(baseState.getBlockType().getPluginId().length() + 1));
    if (!traitValues.isEmpty()) {
        idBuilder.append('[');
        final Joiner joiner = Joiner.on(',');
        final List<String> propertyValues = new ArrayList<>();
        for (Map.Entry<BlockTrait<?>, Comparable<?>> entry : traitValues.entrySet()) {
            propertyValues.add(
                    entry.getKey().getName() + "=" + entry.getValue().toString().toLowerCase(Locale.ENGLISH));
        }
        idBuilder.append(joiner.join(propertyValues));
        idBuilder.append(']');
    }
    this.name = idBuilder.toString();
    this.id = baseState.getBlockType().getPluginId() + ':' + this.name;
}

From source file:com.facebook.buck.features.python.CxxPythonExtensionDescription.java

private BuildRule createCompilationDatabase(BuildTarget target, ProjectFilesystem projectFilesystem,
        ActionGraphBuilder graphBuilder, CellPathResolver cellRoots, PythonPlatform pythonPlatform,
        CxxPlatform cxxPlatform, CxxPythonExtensionDescriptionArg args) {
    SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(graphBuilder);
    SourcePathResolver pathResolver = DefaultSourcePathResolver.from(ruleFinder);
    ImmutableSet<BuildRule> deps = getPlatformDeps(graphBuilder, pythonPlatform, cxxPlatform, args);
    ImmutableMap<CxxPreprocessAndCompile, SourcePath> objects = requireCxxObjects(target, projectFilesystem,
            graphBuilder, pathResolver, ruleFinder, cellRoots, cxxPlatform, args, deps);
    return CxxCompilationDatabase.createCompilationDatabase(target, projectFilesystem, objects.keySet());
}

From source file:com.facebook.buck.cli.ExopackageInstaller.java

private boolean doInstall() throws Exception {
    Optional<PackageInfo> agentInfo = installAgentIfNecessary();
    if (!agentInfo.isPresent()) {
        return false;
    }/*from w ww .  j av a2  s .  c o  m*/

    nativeAgentPath = agentInfo.get().nativeLibPath;

    final File apk = apkRule.getApkPath().toFile();
    // TODO(user): Support SD installation.
    final boolean installViaSd = false;

    if (shouldAppBeInstalled()) {
        try (TraceEventLogger ignored = TraceEventLogger.start(eventBus, "install_exo_apk")) {
            boolean success = adbHelper.installApkOnDevice(device, apk, installViaSd);
            if (!success) {
                return false;
            }
        }
    }

    final ImmutableMap<String, String> hashToBasename = getRequiredDexFiles();
    final ImmutableSet<String> requiredHashes = hashToBasename.keySet();
    final ImmutableSet<String> presentHashes = prepareSecondaryDexDir(requiredHashes);
    final Set<String> hashesToInstall = Sets.difference(requiredHashes, presentHashes);

    installSecondaryDexFiles(hashesToInstall, hashToBasename);

    // TODO(user): Make this work on Gingerbread.
    AdbHelper.executeCommandWithErrorChecking(device, "am force-stop " + packageName);

    return true;
}

From source file:com.google.devtools.build.android.PlaceholderIdFieldInitializerBuilder.java

private Map<String, FieldInitializer> getStyleableInitializers(Map<String, Integer> attrAssignments,
        Collection<String> styleableFields) throws AttrLookupException {
    ImmutableMap.Builder<String, FieldInitializer> initList = ImmutableMap.builder();
    for (String field : styleableFields) {
        Set<String> attrs = styleableAttrs.get(field).keySet();
        ImmutableMap.Builder<String, Integer> arrayInitValues = ImmutableMap.builder();
        for (String attr : attrs) {
            Integer attrId = attrAssignments.get(attr);
            if (attrId == null) {
                // It should be a framework resource, otherwise we don't know about the resource.
                if (!attr.startsWith(NORMALIZED_ANDROID_PREFIX)) {
                    throw new AttrLookupException("App attribute not found: " + attr);
                }//from w  ww . j a v  a  2 s .  co m
                String attrWithoutPrefix = attr.substring(NORMALIZED_ANDROID_PREFIX.length());
                attrId = androidIdProvider.getAttrId(attrWithoutPrefix);
            }
            arrayInitValues.put(attr, attrId);
        }
        // The styleable array should be sorted by ID value.
        // Make sure that if we have android: framework attributes, their IDs are listed first.
        ImmutableMap<String, Integer> arrayInitMap = arrayInitValues
                .orderEntriesByValue(Ordering.<Integer>natural()).build();
        initList.put(field, IntArrayFieldInitializer.of(arrayInitMap.values()));
        int index = 0;
        for (String attr : arrayInitMap.keySet()) {
            initList.put(field + "_" + attr, IntFieldInitializer.of(index));
            ++index;
        }
    }
    return initList.build();
}

From source file:io.fabric8.jube.apimaster.ApiMasterService.java

@GET
@Path("local/pods")
@Consumes("application/json")
@Override/*from   w w  w.j  av  a  2s.  c  o  m*/
public PodList getLocalPods() {
    ImmutableMap<String, Installation> installMap = processManager.listInstallationMap();
    ImmutableSet<String> keys = installMap.keySet();
    List<Pod> pods = new ArrayList<>();
    for (String key : keys) {
        Pod pod = model.getPod(key);
        if (pod != null) {
            pods.add(pod);
        }
    }
    PodList answer = new PodList();
    answer.setItems(pods);
    return answer;

}

From source file:com.facebook.buck.cli.Config.java

public boolean equalsIgnoring(Config other, ImmutableMap<String, ImmutableSet<String>> ignoredFields) {
    if (this == other) {
        return true;
    }/*from www  .  j a v a 2 s  . c  o m*/
    ImmutableMap<String, ImmutableMap<String, String>> left = this.sectionToEntries;
    ImmutableMap<String, ImmutableMap<String, String>> right = other.sectionToEntries;
    Sets.SetView<String> sections = Sets.union(left.keySet(), right.keySet());
    for (String section : sections) {
        ImmutableMap<String, String> leftFields = left.get(section);
        ImmutableMap<String, String> rightFields = right.get(section);
        if (leftFields == null || rightFields == null) {
            return false;
        }
        Sets.SetView<String> fields = Sets.difference(Sets.union(leftFields.keySet(), rightFields.keySet()),
                Optional.fromNullable(ignoredFields.get(section)).or(ImmutableSet.<String>of()));
        for (String field : fields) {
            String leftValue = leftFields.get(field);
            String rightValue = rightFields.get(field);
            if (leftValue == null || rightValue == null || !leftValue.equals(rightValue)) {
                return false;
            }
        }
    }
    return true;
}

From source file:com.facebook.buck.config.Config.java

public boolean equalsIgnoring(Config other, ImmutableMap<String, ImmutableSet<String>> ignoredFields) {
    if (this == other) {
        return true;
    }/*from  w ww.j  av  a  2s. c  o  m*/
    ImmutableMap<String, ImmutableMap<String, String>> left = this.getSectionToEntries();
    ImmutableMap<String, ImmutableMap<String, String>> right = other.getSectionToEntries();
    Sets.SetView<String> sections = Sets.union(left.keySet(), right.keySet());
    for (String section : sections) {
        ImmutableMap<String, String> leftFields = left.get(section);
        ImmutableMap<String, String> rightFields = right.get(section);
        if (leftFields == null || rightFields == null) {
            return false;
        }
        Sets.SetView<String> fields = Sets.difference(Sets.union(leftFields.keySet(), rightFields.keySet()),
                Optional.ofNullable(ignoredFields.get(section)).orElse(ImmutableSet.of()));
        for (String field : fields) {
            String leftValue = leftFields.get(field);
            String rightValue = rightFields.get(field);
            if (leftValue == null || rightValue == null || !leftValue.equals(rightValue)) {
                return false;
            }
        }
    }
    return true;
}