当前位置: 首页>>代码示例>>Java>>正文


Java Iterables.isEmpty方法代码示例

本文整理汇总了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;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:22,代码来源:Intrinsics.java

示例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());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:Inliner.java

示例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;
}
 
开发者ID:isi-nlp,项目名称:tac-kbp-eal,代码行数:24,代码来源:DerivedQuerySelector2016.java

示例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);
			}
		}
	}
}
 
开发者ID:qas-guru,项目名称:martini-core,代码行数:20,代码来源:DefaultCategories.java

示例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;
}
 
开发者ID:HellFirePvP,项目名称:ModularMachinery,代码行数:18,代码来源:HybridStackHelper.java

示例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()));
        }
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:10,代码来源:ModelTypeInitializationException.java

示例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());
        }
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:13,代码来源:ModelNodeRenderer.java

示例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;
}
 
开发者ID:alfasoftware,项目名称:morf,代码行数:18,代码来源:Criterion.java

示例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();
		}
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:20,代码来源:RebuildWorkspaceProjectsScheduler.java

示例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;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:9,代码来源:DynamicPseudoScope.java

示例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();
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:14,代码来源:Strings.java

示例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);
    }
}
 
开发者ID:gchq,项目名称:koryphe,代码行数:13,代码来源:IsEmpty.java

示例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();
  }
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:8,代码来源:PseudoDistributedFileSystem.java

示例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());
}
 
开发者ID:bazelbuild,项目名称:bazel-buildfarm,代码行数:33,代码来源:AbstractServerInstance.java


注:本文中的com.google.common.collect.Iterables.isEmpty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。