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

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

Introduction

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

Prototype

public ImmutableCollection<V> values() 

Source Link

Usage

From source file:com.spectralogic.ds3autogen.net.generators.parsers.typeset.BaseTypeParserSetGenerator.java

/**
 * Converts all non-enum types within a Ds3Types list into a list of TypeParsers
 *//* www.java2 s .co m*/
protected static ImmutableList<TypeParser> toTypeParserList(final ImmutableMap<String, Ds3Type> typeMap) {
    if (isEmpty(typeMap)) {
        return ImmutableList.of();
    }

    final ImmutableList.Builder<TypeParser> builder = ImmutableList.builder();
    for (final Ds3Type ds3Type : typeMap.values().asList()) {
        if (!isEnum(ds3Type)) {
            builder.add(toTypeParser(ds3Type));
        }
    }
    return builder.build();
}

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

static void printPythonFunction(Console console, BaseDescription<?> description,
        TypeCoercerFactory typeCoercerFactory) {
    PrintStream printStream = console.getStdOut();
    ImmutableMap<String, ParamInfo> allParamInfo = CoercedTypeCache.INSTANCE.getAllParamInfo(typeCoercerFactory,
            description.getConstructorArgType());
    String name = DescriptionCache.getRuleType(description).getName();
    printStream.println("def " + name + " (");
    allParamInfo.values().stream().filter(param -> !param.isOptional()).sorted()
            .forEach(formatPythonFunction(printStream));
    allParamInfo.values().stream().filter(ParamInfo::isOptional).sorted()
            .forEach(formatPythonFunction(printStream));
    printStream.println("):");
    printStream.println(INDENT + "...");
}

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

static void printPythonFunction(Console console, DescriptionWithTargetGraph<?> description,
        TypeCoercerFactory typeCoercerFactory) {
    PrintStream printStream = console.getStdOut();
    ImmutableMap<String, ParamInfo> allParamInfo = CoercedTypeCache.INSTANCE.getAllParamInfo(typeCoercerFactory,
            description.getConstructorArgType());
    String name = DescriptionCache.getRuleType(description).getName();
    printStream.println("def " + name + " (");
    allParamInfo.values().stream().filter(param -> !param.isOptional()).sorted()
            .forEach(formatPythonFunction(printStream));
    allParamInfo.values().stream().filter(ParamInfo::isOptional).sorted()
            .forEach(formatPythonFunction(printStream));
    printStream.println("):");
    printStream.println(INDENT + "...");
}

From source file:com.spectralogic.ds3autogen.python.PythonCodeGenerator.java

/**
 * Generates the python models for type descriptors, which are used to describe expected responses
 */// ww w  .ja va 2s  .  c om
protected static ImmutableList<TypeDescriptor> toTypeDescriptorList(
        final ImmutableMap<String, Ds3Type> typeMap) {
    if (isEmpty(typeMap)) {
        return ImmutableList.of();
    }
    return typeMap.values().stream().filter(type -> isEmpty(type.getEnumConstants())) //Do not generate descriptors for enums
            .map(ds3Type -> toTypeDescriptor(ds3Type, typeMap)).collect(GuavaCollectors.immutableList());
}

From source file:com.facebook.buck.apple.AppleLibraryDescriptionSwiftEnhancer.java

/**
 * Returns transitive preprocessor inputs excluding those from the swift delegate of the given
 * CxxLibrary./*from   w ww .  j  a  v a 2s.c o  m*/
 */
public static ImmutableSet<CxxPreprocessorInput> getPreprocessorInputsForAppleLibrary(BuildTarget target,
        ActionGraphBuilder graphBuilder, CxxPlatform platform, AppleNativeTargetDescriptionArg arg) {
    CxxLibrary lib = (CxxLibrary) graphBuilder.requireRule(target.withFlavors());
    ImmutableMap<BuildTarget, CxxPreprocessorInput> transitiveMap = TransitiveCxxPreprocessorInputCache
            .computeTransitiveCxxToPreprocessorInputMap(platform, lib, false, graphBuilder);

    ImmutableSet.Builder<CxxPreprocessorInput> builder = ImmutableSet.builder();
    builder.addAll(transitiveMap.values());
    if (arg.isModular()) {
        Optional<CxxPreprocessorInput> underlyingModule = AppleLibraryDescription
                .underlyingModuleCxxPreprocessorInput(target, graphBuilder, platform);
        underlyingModule.ifPresent(builder::add);
    } else {
        builder.add(lib.getPublicCxxPreprocessorInputExcludingDelegate(platform, graphBuilder));
    }

    return builder.build();
}

From source file:no.ssb.vtl.model.DataStructure.java

private static ImmutableList<Component> computeIndexCache(ImmutableMap<String, Component> delegate) {
    return ImmutableList.copyOf(delegate.values());

}

From source file:com.facebook.buck.haskell.HaskellGhciDescription.java

public static ImmutableList<NativeLinkable> getSortedNativeLinkables(final CxxPlatform cxxPlatform,
        Iterable<? extends NativeLinkable> inputs) {

    ImmutableMap<BuildTarget, NativeLinkable> nativeLinkableMap = NativeLinkables
            .getNativeLinkables(cxxPlatform, inputs, Linker.LinkableDepType.STATIC_PIC);

    return ImmutableList.copyOf(nativeLinkableMap.values());
}

From source file:google.registry.model.ofy.CommitLogCheckpoint.java

/**
 * Creates a CommitLogCheckpoint for the given wall time and bucket checkpoint times, specified
 * as a map from bucket ID to bucket commit timestamp.
 *//*from   w  ww .  j a  va  2s  .  c  o m*/
public static CommitLogCheckpoint create(DateTime checkpointTime,
        ImmutableMap<Integer, DateTime> bucketTimestamps) {
    checkArgument(Objects.equals(CommitLogBucket.getBucketIds().asList(), bucketTimestamps.keySet().asList()),
            "Bucket ids are incorrect: %s", bucketTimestamps.keySet());
    CommitLogCheckpoint instance = new CommitLogCheckpoint();
    instance.checkpointTime = checkpointTime.getMillis();
    instance.bucketTimestamps = ImmutableList.copyOf(bucketTimestamps.values());
    return instance;
}

From source file:com.facebook.buck.cxx.NativeLinkables.java

/**
 * Collect up and merge all {@link com.facebook.buck.cxx.NativeLinkableInput} objects from
 * transitively traversing all unbroken dependency chains of
 * {@link com.facebook.buck.cxx.NativeLinkable} objects found via the passed in
 * {@link com.facebook.buck.rules.BuildRule} roots.
 *///from  www.j a  va 2 s . c  o  m
public static NativeLinkableInput getTransitiveNativeLinkableInput(CxxPlatform cxxPlatform,
        Iterable<? extends BuildRule> inputs, Linker.LinkableDepType depType, Predicate<Object> traverse,
        Predicate<Object> skip) throws NoSuchBuildTargetException {

    // Get the topologically sorted native linkables.
    ImmutableMap<BuildTarget, NativeLinkable> roots = getNativeLinkableRoots(inputs, traverse, skip);
    ImmutableMap<BuildTarget, NativeLinkable> nativeLinkables = getNativeLinkables(cxxPlatform, roots.values(),
            depType);
    ImmutableList.Builder<NativeLinkableInput> nativeLinkableInputs = ImmutableList.builder();
    for (NativeLinkable nativeLinkable : nativeLinkables.values()) {
        nativeLinkableInputs.add(getNativeLinkableInput(cxxPlatform, depType, nativeLinkable));
    }
    return NativeLinkableInput.concat(nativeLinkableInputs.build());
}

From source file:com.google.devtools.build.lib.packages.AspectDefinition.java

/**
 * Collects all attribute labels from the specified aspectDefinition.
 *///from  w  ww  . ja va2  s .  c om
public static void addAllAttributesOfAspect(Rule from, Multimap<Attribute, Label> labelBuilder, Aspect aspect,
        DependencyFilter dependencyFilter) {
    ImmutableMap<String, Attribute> attributes = aspect.getDefinition().getAttributes();
    for (Attribute aspectAttribute : attributes.values()) {
        if (!dependencyFilter.apply(aspect, aspectAttribute)) {
            continue;
        }
        if (aspectAttribute.getType() == BuildType.LABEL) {
            Label label = maybeGetRepositoryRelativeLabel(from,
                    BuildType.LABEL.cast(aspectAttribute.getDefaultValue(from)));
            if (label != null) {
                labelBuilder.put(aspectAttribute, label);
            }
        } else if (aspectAttribute.getType() == BuildType.LABEL_LIST) {
            List<Label> defaultLabels = BuildType.LABEL_LIST.cast(aspectAttribute.getDefaultValue(from));
            if (defaultLabels != null) {
                for (Label defaultLabel : defaultLabels) {
                    Label label = maybeGetRepositoryRelativeLabel(from, defaultLabel);
                    if (label != null) {
                        labelBuilder.put(aspectAttribute, label);
                    }
                }
            }
        }
    }
}