本文整理汇总了Java中com.google.common.collect.Iterables.isEmpty方法的典型用法代码示例。如果您正苦于以下问题:Java Iterables.isEmpty方法的具体用法?Java Iterables.isEmpty怎么用?Java Iterables.isEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.collect.Iterables
的用法示例。
在下文中一共展示了Iterables.isEmpty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: if
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
public static boolean $if(Object value) {
if (value == null) {
return false;
}
if (value instanceof Boolean) {
return ((Boolean) value).booleanValue();
}
if (value instanceof String) {
return !((String) value).isEmpty();
}
if (value instanceof Iterable<?>) {
return !Iterables.isEmpty((Iterable<?>) value);
}
if (value instanceof Number) {
return ((Number) value).intValue() != 0;
}
if (value instanceof Optional<?>) {
return ((Optional<?>) value).isPresent();
}
return true;
}
示例2: addBodyIfNecessary
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
private void addBodyIfNecessary(
ForStatement.Builder builder,
List<Trees.Expression> params,
Iterable<? extends Trees.TemplatePart> bodyParts) {
// body goes as one special parameter, don't handle other mismatches
if (Iterables.isEmpty(bodyParts)) {
return;
}
Preconditions.checkState(inlinable.declaration().parameters().size() == params.size() + 1);
Trees.Parameter lastParameter = Iterables.getLast(inlinable.declaration().parameters());
LetStatement.Builder letBuilder = LetStatement.builder()
.addAllParts(bodyParts)
.declaration(InvokableDeclaration.builder()
.name(remappedIdentifier(lastParameter.name()))
.build());
remapped.add(lastParameter.name());
builder.addParts(letBuilder.build());
}
示例3: intersectedCopy
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
@MoveToBUECommon
private static <T> ImmutableSet<T> intersectedCopy(Iterable<? extends Iterable<? extends T>> iterables) {
if (Iterables.isEmpty(iterables)) {
return ImmutableSet.of();
}
ImmutableSet<T> ret = null;
for (final Iterable<? extends T> iterable : iterables) {
if (ret == null) {
ret = ImmutableSet.copyOf(iterable);
} else {
ret = Sets.intersection(ret, ImmutableSet.copyOf(iterable)).immutableCopy();
}
// as soon as we realize the intersection is empty there is no need to do more work
if (ret.isEmpty()) {
break;
}
}
return ret;
}
示例4: afterPropertiesSet
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
@Override
public void afterPropertiesSet() throws Exception {
Map<String, Category> beans = applicationContext.getBeansOfType(Category.class);
Collection<Category> categories = beans.values();
for (Category category : categories) {
String name = category.getName();
Iterable<String> parentNames = category.getParentNames();
if (Iterables.isEmpty(parentNames)) {
ascendingHierarchy.put(name, null);
}
else {
for (String parentName : parentNames) {
ascendingHierarchy.put(name, parentName);
}
}
}
}
示例5: attemptGasStackMatch
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
@Optional.Method(modid = "mekanism")
private T attemptGasStackMatch(Iterable<T> ingredients, T ingredientToMatch) {
if(ingredientToMatch instanceof HybridFluidGas) {
if(!Iterables.isEmpty(ingredients)) {
GasStack toMatch = ((HybridFluidGas) ingredientToMatch).asGasStack();
for (T hybridFluid : ingredients) {
if(hybridFluid != null && hybridFluid instanceof HybridFluidGas) {
HybridFluidGas hybridFluidGas = (HybridFluidGas) hybridFluid;
if(hybridFluidGas.asGasStack().getGas() == toMatch.getGas()) { //Identical check to the GasStackHelper in mek
return (T) hybridFluidGas;
}
}
}
}
}
return null;
}
示例6: maybeAppendConstructibles
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
private static void maybeAppendConstructibles(StringBuilder s, Iterable<? extends ModelType<?>> constructibleTypes, int pad) {
if (!Iterables.isEmpty(constructibleTypes)) {
String padding = pad(pad);
s.append(String.format("%n%s- or a type which Gradle is capable of constructing:", padding));
for (ModelType<?> modelType : constructibleTypes) {
s.append(String.format("%n %s- %s", padding, modelType.getName()));
}
}
}
示例7: maybePrintRules
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
private void maybePrintRules(ModelNode model, StyledTextOutput styledTextoutput) {
if (omitDetails()) {
return;
}
Iterable<ModelRuleDescriptor> executedRules = uniqueExecutedRulesExcludingCreator(model);
if (!Iterables.isEmpty(executedRules)) {
printNestedAttributeTitle(styledTextoutput, "Rules:");
for (ModelRuleDescriptor ruleDescriptor : executedRules) {
printNestedAttribute(styledTextoutput, "⤷ " + ruleDescriptor.toString());
}
}
}
示例8: Criterion
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
/**
* Construct a new criterion with an operator and series of other criteria.
* This is commonly used for the "AND" and "OR" operators.
*
* @param operator the operator to use in the criterion
* @param criteria the criteria
*/
public Criterion(Operator operator, Iterable<Criterion> criteria) {
if (criteria == null || Iterables.isEmpty(criteria)) {
throw new IllegalArgumentException("Must specify at least one criterion");
}
this.operator = operator;
this.criteria = AliasedField.immutableDslEnabled() ? ImmutableList.copyOf(criteria) : Lists.newArrayList(criteria);
this.selectStatement = null;
this.value = null;
this.field = null;
}
示例9: scheduleBuildIfNecessary
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
/**
* Schedules a build with the given projects. Does nothing if the {@link Platform platform} is not running, or the
* iterable of projects is empty.
*
* @param toUpdate
* an iterable of projects to build.
*/
public void scheduleBuildIfNecessary(final Iterable<IProject> toUpdate) {
if (Platform.isRunning() && !Iterables.isEmpty(toUpdate)) {
final Workspace workspace = (Workspace) ResourcesPlugin.getWorkspace();
final IBuildConfiguration[] projectsToReBuild = from(asList(workspace.getBuildOrder()))
.filter(config -> Iterables.contains(toUpdate, config.getProject()))
.toArray(IBuildConfiguration.class);
if (!Arrays2.isEmpty(projectsToReBuild)) {
new RebuildWorkspaceProjectsJob(projectsToReBuild).schedule();
}
}
}
示例10: getElements
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
@Override
public Iterable<IEObjectDescription> getElements(QualifiedName name) {
Iterable<IEObjectDescription> parentResult = parent.getElements(name);
if (Iterables.isEmpty(parentResult)) {
return Collections.<IEObjectDescription> singletonList(new UnresolvableObjectDescription(name));
}
return parentResult;
}
示例11: collectionToDelimitedString
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
public static String collectionToDelimitedString(Iterable<?> coll, String delim, String prefix, String suffix, StringBuilder sb) {
if (Iterables.isEmpty(coll)) {
return "";
}
Iterator<?> it = coll.iterator();
while (it.hasNext()) {
sb.append(prefix).append(it.next()).append(suffix);
if (it.hasNext()) {
sb.append(delim);
}
}
return sb.toString();
}
示例12: apply
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
@Override
@SuppressFBWarnings(value = "DE_MIGHT_IGNORE", justification = "Any exceptions are to be ignored")
public Boolean apply(final Iterable input) {
if (null == input) {
throw new IllegalArgumentException("Input cannot be null");
}
try {
return Iterables.isEmpty(input);
} finally {
CloseableUtil.close(input);
}
}
示例13: buildDependencies
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
protected void buildDependencies(@NotNull final Iterable<HybrisModuleDescriptor> moduleDescriptors) {
Validate.notNull(moduleDescriptors);
for (HybrisModuleDescriptor moduleDescriptor : moduleDescriptors) {
final Set<String> requiredExtensionNames = moduleDescriptor.getRequiredExtensionNames();
if (isEmpty(requiredExtensionNames)) {
continue;
}
final Set<HybrisModuleDescriptor> dependencies = new HashSet<HybrisModuleDescriptor>(
requiredExtensionNames.size()
);
for (String requiresExtensionName : requiredExtensionNames) {
final Iterable<HybrisModuleDescriptor> dependsOn = this.findHybrisModuleDescriptorsByName(
moduleDescriptors, requiresExtensionName
);
if (Iterables.isEmpty(dependsOn)) {
LOG.warn(String.format(
"Module '%s' contains unsatisfied dependency '%s'.",
moduleDescriptor.getName(), requiresExtensionName
));
} else {
for (HybrisModuleDescriptor hybrisModuleDescriptor : dependsOn) {
dependencies.add(hybrisModuleDescriptor);
}
}
}
if (moduleDescriptor.isAddOn()) {
this.processAddOnBackwardDependencies(moduleDescriptors, moduleDescriptor, dependencies);
}
moduleDescriptor.setDependenciesTree(dependencies);
}
}
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:41,代码来源:DefaultHybrisProjectDescriptor.java
示例14: getEndpoints
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
private Iterable<NodeEndpoint> getEndpoints(){
if(Iterables.isEmpty(endpointProvider.get())){
return globalConfig.getEndpointProvider().get();
} else {
return endpointProvider.get();
}
}
示例15: validateAction
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
private void validateAction(Action action) {
Digest commandDigest = action.getCommandDigest();
ImmutableSet.Builder<Digest> inputDigests = new ImmutableSet.Builder<>();
inputDigests.add(commandDigest);
validateActionInputs(action.getInputRootDigest(), inputDigests);
// A requested input (or the [Command][] of the [Action][]) was not found in
// the [ContentAddressableStorage][].
Iterable<Digest> missingBlobDigests = findMissingBlobs(inputDigests.build());
if (!Iterables.isEmpty(missingBlobDigests)) {
Preconditions.checkState(
Iterables.isEmpty(missingBlobDigests),
MISSING_INPUT);
}
// FIXME should input/output collisions (through directories) be another
// invalid action?
filesUniqueAndSortedPrecondition(action.getOutputFilesList());
filesUniqueAndSortedPrecondition(action.getOutputDirectoriesList());
Command command;
try {
command = Command.parseFrom(getBlob(commandDigest));
} catch (InvalidProtocolBufferException ex) {
Preconditions.checkState(
false,
INVALID_DIGEST);
return;
}
environmentVariablesUniqueAndSortedPrecondition(
command.getEnvironmentVariablesList());
}