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

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

Introduction

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

Prototype

boolean isEmpty();

Source Link

Document

Returns true if this set contains no elements.

Usage

From source file:com.google.caliper.runner.target.TargetModule.java

@Singleton
@Provides/*w  w w .j  a v a  2 s  .  c o  m*/
static ImmutableSet<Target> provideTargets(Device device, CaliperOptions options, CaliperConfig config) {
    ImmutableSet<String> vmNames = options.vmNames();
    if (vmNames.isEmpty()) {
        return ImmutableSet.of(device.createDefaultTarget());
    }

    ImmutableSet.Builder<Target> builder = ImmutableSet.builder();
    for (String vmName : vmNames) {
        builder.add(device.createTarget(config.getVmConfig(vmName)));
    }
    return builder.build();
}

From source file:com.google.devtools.build.lib.skyframe.FilesetEntryValue.java

static FilesetEntryValue of(ImmutableSet<FilesetOutputSymlink> symlinks) {
    if (symlinks.isEmpty()) {
        return EMPTY;
    } else {//from w  w w .j  a  v  a  2 s .co m
        return new FilesetEntryValue(symlinks);
    }
}

From source file:org.fenixedu.bennu.core.groups.UserGroup.java

public static Group of(ImmutableSet<User> members) {
    if (members.isEmpty()) {
        return NobodyGroup.get();
    }//from   ww  w .java 2s .c  om
    return new UserGroup(members);
}

From source file:google.registry.mapreduce.inputs.EppResourceInputs.java

/**
 * Returns a MapReduce {@link Input} that loads all {@link ImmutableObject} objects of a given
 * type, including deleted resources, that are child entities of all {@link EppResource} objects
 * of a given type./*from  w ww  .j a va  2 s  .c  o m*/
 *
 * <p>Note: Do not concatenate multiple EntityInputs together (this is inefficient as it iterates
 * through all buckets multiple times). Specify the types in a single input, or load all types by
 * specifying {@link EppResource} and/or {@link ImmutableObject} as the class.
 */
public static <R extends EppResource, I extends ImmutableObject> Input<I> createChildEntityInput(
        ImmutableSet<Class<? extends R>> parentClasses, ImmutableSet<Class<? extends I>> childClasses) {
    checkArgument(!parentClasses.isEmpty(), "Must provide at least one parent type.");
    checkArgument(!childClasses.isEmpty(), "Must provide at least one child type.");
    return new ChildEntityInput<>(parentClasses, childClasses);
}

From source file:com.google.api.server.spi.auth.EndpointsPeerAuthenticator.java

private static ImmutableSet<String> getLocalHostAddresses() {
    ImmutableSet.Builder<String> builder = new ImmutableSet.Builder<>();
    try {/*from w  w w .  jav  a  2s .co m*/
        builder.add(InetAddress.getLocalHost().getHostAddress());
    } catch (IOException e) {
        // try next.
    }
    try {
        builder.add(InetAddress.getByName(null).getHostAddress());
    } catch (IOException e) {
        // try next.
    }
    try {
        for (InetAddress inetAddress : InetAddress.getAllByName("localhost")) {
            builder.add(inetAddress.getHostAddress());
        }
    } catch (IOException e) {
        // check at the end.
    }
    ImmutableSet<String> localHostSet = builder.build();
    if (localHostSet.isEmpty()) {
        logger.warning("Unable to lookup local addresses.");
    }
    return localHostSet;
}

From source file:dagger.internal.codegen.MapKeys.java

/**
 * If {@code bindingElement} is annotated with a {@link MapKey} annotation, returns it.
 *
 * @throws IllegalArgumentException if the element is annotated with more than one {@code MapKey}
 *     annotation/*from  www .  j  a v  a2 s.c o m*/
 */
static Optional<AnnotationMirror> getMapKey(Element bindingElement) {
    ImmutableSet<? extends AnnotationMirror> mapKeys = getMapKeys(bindingElement);
    return mapKeys.isEmpty() ? Optional.empty() : Optional.<AnnotationMirror>of(getOnlyElement(mapKeys));
}

From source file:com.google.errorprone.bugpatterns.MutableMethodReturnType.java

private static Optional<String> getCommonImmutableTypeForAllReturnStatementsTypes(
        ImmutableSet<ClassType> returnStatementsTypes) {
    checkState(!returnStatementsTypes.isEmpty());

    ClassType arbitraryClassType = returnStatementsTypes.asList().get(0);
    ImmutableList<String> superTypes = getImmutableSuperTypesForClassType(arbitraryClassType);

    return superTypes.stream().filter(areAllReturnStatementsAssignable(returnStatementsTypes)).findFirst();
}

From source file:com.google.devtools.build.lib.analysis.SkylarkProviderValidationUtil.java

public static void checkOrphanArtifacts(RuleContext ruleContext) throws EvalException {
    ImmutableSet<Artifact> orphanArtifacts = ruleContext.getAnalysisEnvironment().getOrphanArtifacts();
    if (!orphanArtifacts.isEmpty()) {
        throw new EvalException(null, "The following files have no generating action:\n"
                + Joiner.on("\n").join(Iterables.transform(orphanArtifacts, new Function<Artifact, String>() {
                    @Override/* w ww.  j av  a  2s. co  m*/
                    public String apply(Artifact artifact) {
                        return artifact.getRootRelativePathString();
                    }
                })));
    }
}

From source file:de.metas.ui.web.handlingunits.HUEditorRowFilters.java

public static Predicate<HUEditorRow> toPredicate(@NonNull final HUEditorRowFilter filter) {
    Predicate<HUEditorRow> predicate = Predicates.alwaysTrue();
    if (filter == HUEditorRowFilter.ALL) {
        return predicate;
    }/*from w  ww  .  ja v a  2  s . c  o  m*/

    // Filter by row type
    final Select rowType = filter.getSelect();
    if (rowType == Select.ALL) {
        // nothing
    } else if (rowType == Select.ONLY_TOPLEVEL) {
        predicate = predicate.and(HUEditorRow::isTopLevel);
    } else if (rowType == Select.LU) {
        predicate = predicate.and(HUEditorRow::isLU);
    } else if (rowType == Select.TU) {
        predicate = predicate.and(HUEditorRow::isTU);
    } else if (rowType == Select.CU) {
        predicate = predicate.and(HUEditorRow::isCU);
    } else {
        throw new AdempiereException("Unknown: " + rowType);
    }

    // Filter by string filter
    final String stringFilter = filter.getUserInputFilter();
    if (!Check.isEmpty(stringFilter, true)) {
        predicate = predicate.and(row -> row.matchesStringFilter(stringFilter));
    }

    // Exclude M_HU_IDs
    final ImmutableSet<HuId> excludeHUIds = filter.getExcludeHUIds();
    if (!excludeHUIds.isEmpty()) {
        predicate = predicate.and(row -> !excludeHUIds.contains(row.getHuId()));
    }

    // Include HUStatuses
    final ImmutableSet<String> onlyHUStatuses = filter.getOnlyHUStatuses();
    if (!onlyHUStatuses.isEmpty()) {
        predicate = predicate.and(row -> onlyHUStatuses.contains(row.getHUStatus()));
    }

    // Exclude HUStatuses
    final ImmutableSet<String> excludeHUStatuses = filter.getExcludeHUStatuses();
    if (!excludeHUStatuses.isEmpty()) {
        predicate = predicate.and(row -> !excludeHUStatuses.contains(row.getHUStatus()));
    }

    return predicate;
}

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

public static Predicate<BuildTarget> containsFlavors(FlavorDomain<?> domain) {
    return input -> {
        ImmutableSet<Flavor> flavorSet = Sets.intersection(domain.getFlavors(), input.getFlavors())
                .immutableCopy();//from w w  w . jav a 2s . c om
        return !flavorSet.isEmpty();
    };
}