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:org.onosproject.yang.compiler.plugin.buck.YangLibraryDescription.java

@Override
public boolean hasFlavors(ImmutableSet<Flavor> flavors) {
    return flavors.isEmpty() || flavors.contains(SOURCES);
}

From source file:com.google.caliper.runner.RunnerModule.java

@Provides
ImmutableSet<VirtualMachine> provideVirtualMachines(CaliperOptions options, CaliperConfig config)
        throws InvalidConfigurationException {
    ImmutableSet<String> vmNames = options.vmNames();
    ImmutableSet.Builder<VirtualMachine> builder = ImmutableSet.builder();
    if (vmNames.isEmpty()) {
        builder.add(new VirtualMachine("default", config.getDefaultVmConfig()));
    } else {//w w w. j av a 2s .c o  m
        for (String vmName : vmNames) {
            VmConfig vmConfig = config.getVmConfig(vmName);
            builder.add(new VirtualMachine(vmName, vmConfig));
        }
    }
    return builder.build();
}

From source file:com.tngtech.archunit.library.plantuml.PlantUmlParser.java

private ImmutableSet<Stereotype> identifyStereotypes(PlantUmlComponentMatcher matcher,
        ComponentName componentName) {/*from   www  .ja v  a  2  s  .  c o  m*/
    ImmutableSet.Builder<Stereotype> stereotypes = ImmutableSet.builder();
    for (String stereotype : matcher.matchStereoTypes()) {
        stereotypes.add(new Stereotype(stereotype));
    }

    ImmutableSet<Stereotype> result = stereotypes.build();
    if (result.isEmpty()) {
        throw new IllegalDiagramException(String.format(
                "Components must include at least one stereotype"
                        + " specifying the package identifier(<<..>>), but component '%s' does not",
                componentName.asString()));
    }
    return result;
}

From source file:com.facebook.buck.features.project.intellij.model.AbstractIjModuleAndroidFacet.java

public Optional<Path> getFirstManifestPath() {
    ImmutableSet<Path> androidManifestPaths = getManifestPaths();
    if (androidManifestPaths.isEmpty()) {
        return Optional.empty();
    } else {// www . j  av  a2 s. c o  m
        return Optional.of(androidManifestPaths.iterator().next());
    }
}

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

public static Optional<CoreDataModel> createBuildRulesForCoreDataDependencies(TargetGraph targetGraph,
        BuildRuleParams params, String moduleName, AppleCxxPlatform appleCxxPlatform) {
    TargetNode<?, ?> targetNode = targetGraph.get(params.getBuildTarget());

    ImmutableSet<AppleWrapperResourceArg> coreDataModelArgs = AppleBuildRules.collectTransitiveBuildRules(
            targetGraph, Optional.empty(), AppleBuildRules.CORE_DATA_MODEL_DESCRIPTION_CLASSES,
            ImmutableList.of(targetNode));

    BuildRuleParams coreDataModelParams = params.copyWithChanges(
            params.getBuildTarget().withAppendedFlavors(CoreDataModel.FLAVOR),
            Suppliers.ofInstance(ImmutableSortedSet.of()), Suppliers.ofInstance(ImmutableSortedSet.of()));

    if (coreDataModelArgs.isEmpty()) {
        return Optional.empty();
    } else {/* w w  w  . j av a2  s . c o m*/
        return Optional.of(new CoreDataModel(coreDataModelParams, appleCxxPlatform, moduleName,
                coreDataModelArgs.stream()
                        .map(input -> new PathSourcePath(params.getProjectFilesystem(), input.path))
                        .collect(MoreCollectors.toImmutableSet())));
    }
}

From source file:org.cyclop.service.search.intern.SearchServiceImpl.java

@Override
public Optional<FilterResult<T>> filter(ImmutableCollection<T> input, FieldAccessor<T> accessor,
        String... keywords) {/*from  ww w  .  j  a v a 2s . c o m*/

    ImmutableSet<String> normKeywords = normalize(keywords);
    if (normKeywords.isEmpty()) {
        return Optional.empty();
    }

    SortedMap<WeightSortingKey, T> sorted = new TreeMap<>(COMP);
    for (T el : input) {
        String elVal = accessor.getText(el);
        if (elVal == null) {
            continue;
        }
        String normElVal = normalize(elVal);
        int weigth = calculateWeight(normElVal, normKeywords);
        if (weigth == 0) {
            continue;
        }
        sorted.put(new WeightSortingKey(weigth, normElVal), el);
    }

    ImmutableList<T> result = mapResult(sorted);
    return Optional.of(new FilterResult<T>(result, normKeywords));
}

From source file:com.github.rinde.rinsim.core.pdptw.RandomVehicle.java

Optional<Parcel> findTarget() {
    final Collection<Parcel> available = pm.get().getParcels(ParcelState.AVAILABLE);
    final ImmutableSet<Parcel> contents = pm.get().getContents(this);
    if (available.isEmpty() && contents.isEmpty()) {
        return Optional.absent();
    }//  w w  w  . java 2  s  . c o  m
    boolean pickup;
    if (!available.isEmpty() && !contents.isEmpty()) {
        pickup = rng.nextBoolean();
    } else {
        pickup = !available.isEmpty();
    }
    if (pickup) {
        return Optional.of(newArrayList(available).get(rng.nextInt(available.size())));
    } else {
        return Optional.of(contents.asList().get(rng.nextInt(contents.size())));
    }
}

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

public static Optional<SceneKitAssets> createBuildRulesForSceneKitAssetsDependencies(TargetGraph targetGraph,
        BuildRuleParams params, AppleCxxPlatform appleCxxPlatform) {
    TargetNode<?, ?> targetNode = targetGraph.get(params.getBuildTarget());

    ImmutableSet<AppleWrapperResourceArg> sceneKitAssetsArgs = AppleBuildRules.collectTransitiveBuildRules(
            targetGraph, Optional.empty(), AppleBuildRules.SCENEKIT_ASSETS_DESCRIPTION_CLASSES,
            ImmutableList.of(targetNode));

    BuildRuleParams sceneKitAssetsParams = params.copyWithChanges(
            params.getBuildTarget().withAppendedFlavors(SceneKitAssets.FLAVOR),
            Suppliers.ofInstance(ImmutableSortedSet.of()), Suppliers.ofInstance(ImmutableSortedSet.of()));

    if (sceneKitAssetsArgs.isEmpty()) {
        return Optional.empty();
    } else {/*w  w w.  j a  v  a  2  s  .c o  m*/
        return Optional.of(new SceneKitAssets(sceneKitAssetsParams, appleCxxPlatform,
                sceneKitAssetsArgs.stream()
                        .map(input -> new PathSourcePath(params.getProjectFilesystem(), input.path))
                        .collect(MoreCollectors.toImmutableSet())));
    }
}

From source file:dagger.model.testing.BindingGraphSubject.java

private BindingSubject bindingWithKeyString(String keyString) {
    ImmutableSet<Binding> bindings = getBindingNodes(keyString);
    if (bindings.isEmpty()) {
        fail("has binding with key", keyString);
    }/*ww w . j  av a2 s .com*/
    // TODO(dpb): Handle multiple bindings for the same key.
    if (bindings.size() > 1) {
        failWithBadResults("has only one binding with key", keyString, "has the following bindings:", bindings);
    }
    return check("bindingWithKey(%s)", keyString).about(BindingSubject::new).that(getOnlyElement(bindings));
}

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

@Override
public void visitGraph(BindingGraph bindingGraph, DiagnosticReporter diagnosticReporter) {
    bindingGraph.edges().stream().flatMap(instancesOf(ChildFactoryMethodEdge.class)).forEach(edge -> {
        ImmutableSet<TypeElement> missingModules = findMissingModules(edge, bindingGraph);
        if (!missingModules.isEmpty()) {
            reportMissingModuleParameters(edge, missingModules, bindingGraph, diagnosticReporter);
        }/*from  www.j  a  va2 s  .  c  om*/
    });
}