Example usage for com.google.common.collect ImmutableSet toString

List of usage examples for com.google.common.collect ImmutableSet toString

Introduction

In this page you can find the example usage for com.google.common.collect ImmutableSet toString.

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

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

/**
 * Propagate flavors represented by the given {@link FlavorDomain} objects from a parent target to
 * its dependencies.//from  w  ww  . j  a  v  a 2  s .c o m
 */
public static ImmutableSortedSet<BuildTarget> propagateFlavorDomains(BuildTarget target,
        Iterable<FlavorDomain<?>> domains, Iterable<BuildTarget> deps) {

    Set<Flavor> flavors = new HashSet<>();

    // For each flavor domain, extract the corresponding flavor from the parent target and
    // verify that each dependency hasn't already set this flavor.
    for (FlavorDomain<?> domain : domains) {

        // Now extract all relevant domain flavors from our parent target.
        ImmutableSet<Flavor> flavorSet = Sets.intersection(domain.getFlavors(), target.getFlavors())
                .immutableCopy();

        if (flavorSet.isEmpty()) {
            throw new HumanReadableException("%s: no flavor for \"%s\"", target, domain.getName());
        }
        flavors.addAll(flavorSet);

        // First verify that our deps are not already flavored for our given domains.
        for (BuildTarget dep : deps) {
            if (domain.getFlavor(dep).isPresent()) {
                throw new HumanReadableException("%s: dep %s already has flavor for \"%s\" : %s", target, dep,
                        domain.getName(), flavorSet.toString());
            }
        }
    }

    ImmutableSortedSet.Builder<BuildTarget> flavoredDeps = ImmutableSortedSet.naturalOrder();

    // Now flavor each dependency with the relevant flavors.
    for (BuildTarget dep : deps) {
        flavoredDeps.add(dep.withAppendedFlavors(flavors));
    }

    return flavoredDeps.build();
}

From source file:com.facebook.buck.model.BuildTargets.java

/**
 * Propagate flavors represented by the given {@link FlavorDomain} objects from a parent
 * target to its dependencies./*from  w ww. j av a 2 s. c  o m*/
 */
public static ImmutableSortedSet<BuildTarget> propagateFlavorDomains(BuildTarget target,
        Iterable<FlavorDomain<?>> domains, Iterable<BuildTarget> deps) {

    Set<Flavor> flavors = Sets.newHashSet();

    // For each flavor domain, extract the corresponding flavor from the parent target and
    // verify that each dependency hasn't already set this flavor.
    for (FlavorDomain<?> domain : domains) {

        // Now extract all relevant domain flavors from our parent target.
        ImmutableSet<Flavor> flavorSet = Sets.intersection(domain.getFlavors(), target.getFlavors())
                .immutableCopy();

        if (flavorSet.isEmpty()) {
            throw new HumanReadableException("%s: no flavor for \"%s\"", target, domain.getName());
        }
        flavors.addAll(flavorSet);

        // First verify that our deps are not already flavored for our given domains.
        for (BuildTarget dep : deps) {
            if (domain.getFlavor(dep).isPresent()) {
                throw new HumanReadableException("%s: dep %s already has flavor for \"%s\" : %s", target, dep,
                        domain.getName(), flavorSet.toString());
            }
        }
    }

    ImmutableSortedSet.Builder<BuildTarget> flavoredDeps = ImmutableSortedSet.naturalOrder();

    // Now flavor each dependency with the relevant flavors.
    for (BuildTarget dep : deps) {
        flavoredDeps.add(BuildTarget.builder(dep).addAllFlavors(flavors).build());
    }

    return flavoredDeps.build();
}

From source file:org.linagora.linshare.core.notifications.service.impl.MailBuildingServiceImpl.java

private String getFileNames(UploadRequestUrl requestUrl) {
    ImmutableSet<FileRepresentation> files = FluentIterable.from(requestUrl.getUploadRequestEntries())
            .transform(new Function<UploadRequestEntry, FileRepresentation>() {
                @Override//from ww  w . j a  v  a2 s. com
                public FileRepresentation apply(UploadRequestEntry ure) {
                    return new FileRepresentation(ure);
                }
            }).toSet();
    if (files.size() > 0) {
        return files.toString();
    }
    return " - ";
}

From source file:com.facebook.buck.features.apple.project.XCodeProjectCommandHelper.java

private FocusedModuleTargetMatcher getFocusModules() throws IOException, InterruptedException {
    if (modulesToFocusOn == null) {
        return FocusedModuleTargetMatcher.noFocus();
    }//from  www .  ja va2  s . co m

    Iterable<String> patterns = Splitter.onPattern("\\s+").split(modulesToFocusOn);
    // Parse patterns with the following syntax:
    // https://buckbuild.com/concept/build_target_pattern.html
    ImmutableList<TargetNodeSpec> specs = argsParser.apply(patterns);

    // Resolve the list of targets matching the patterns.
    ImmutableSet<BuildTarget> passedInTargetsSet;
    try {
        passedInTargetsSet = parser
                .resolveTargetSpecs(parsingContext.withSpeculativeParsing(SpeculativeParsing.DISABLED), specs,
                        targetConfiguration)
                .stream().flatMap(Collection::stream).collect(ImmutableSet.toImmutableSet());
    } catch (HumanReadableException e) {
        buckEventBus.post(ConsoleEvent.severe(MoreExceptions.getHumanReadableOrLocalizedMessage(e)));
        return FocusedModuleTargetMatcher.noFocus();
    }
    LOG.debug("Selected targets: %s", passedInTargetsSet.toString());

    ImmutableSet<UnflavoredBuildTarget> passedInUnflavoredTargetsSet = RichStream.from(passedInTargetsSet)
            .map(BuildTarget::getUnflavoredBuildTarget).toImmutableSet();
    LOG.debug("Selected unflavored targets: %s", passedInUnflavoredTargetsSet.toString());
    return FocusedModuleTargetMatcher.focusedOn(passedInUnflavoredTargetsSet);
}

From source file:com.facebook.buck.apple.project_generator.XCodeProjectCommandHelper.java

private FocusedModuleTargetMatcher getFocusModules(ListeningExecutorService executor)
        throws IOException, InterruptedException {
    if (modulesToFocusOn == null) {
        return FocusedModuleTargetMatcher.noFocus();
    }/*from   w  ww  .  j  ava2s  .  c o  m*/

    Iterable<String> patterns = Splitter.onPattern("\\s+").split(modulesToFocusOn);
    // Parse patterns with the following syntax:
    // https://buckbuild.com/concept/build_target_pattern.html
    ImmutableList<TargetNodeSpec> specs = argsParser.apply(patterns);

    // Resolve the list of targets matching the patterns.
    ImmutableSet<BuildTarget> passedInTargetsSet;
    ParserConfig parserConfig = buckConfig.getView(ParserConfig.class);
    try {
        passedInTargetsSet = parser
                .resolveTargetSpecs(buckEventBus, cell, enableParserProfiling, executor, specs,
                        SpeculativeParsing.of(false), parserConfig.getDefaultFlavorsMode())
                .stream().flatMap(Collection::stream).map(target -> target.withoutCell())
                .collect(MoreCollectors.toImmutableSet());
    } catch (BuildTargetException | BuildFileParseException | HumanReadableException e) {
        buckEventBus.post(ConsoleEvent.severe(MoreExceptions.getHumanReadableOrLocalizedMessage(e)));
        return FocusedModuleTargetMatcher.noFocus();
    }
    LOG.debug("Selected targets: %s", passedInTargetsSet.toString());

    ImmutableSet<UnflavoredBuildTarget> passedInUnflavoredTargetsSet = RichStream.from(passedInTargetsSet)
            .map(BuildTarget::getUnflavoredBuildTarget).toImmutableSet();
    LOG.debug("Selected unflavored targets: %s", passedInUnflavoredTargetsSet.toString());
    return FocusedModuleTargetMatcher.focusedOn(passedInUnflavoredTargetsSet);
}

From source file:org.linagora.linshare.core.service.impl.MailBuildingServiceImpl.java

private String getFileNames(UploadRequest request) {
    ImmutableSet<FileRepresentation> files = FluentIterable.from(request.getUploadRequestEntries())
            .transform(new Function<UploadRequestEntry, FileRepresentation>() {
                @Override/*from   ww  w.  j a  v a2 s. c  o m*/
                public FileRepresentation apply(UploadRequestEntry ure) {
                    return new FileRepresentation(ure);
                }
            }).toSet();
    if (files.size() > 0) {
        return files.toString();
    }
    return " - ";
}