本文整理汇总了Java中com.google.common.collect.Iterables.filter方法的典型用法代码示例。如果您正苦于以下问题:Java Iterables.filter方法的具体用法?Java Iterables.filter怎么用?Java Iterables.filter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.collect.Iterables
的用法示例。
在下文中一共展示了Iterables.filter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: listFolders
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
public static Iterable<File> listFolders(File root) {
return Iterables.filter(
Files.fileTreeTraverser().children( root ), new Predicate<File>() {
@Override
public boolean apply(File input) {
return input.isDirectory();
}
});
}
示例2: configure
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
public void configure(String deployName, String contextPath, List<WbModuleEntry> newEntries) {
Iterable<WbModuleEntry> toKeep = Iterables.filter(wbModuleEntries, not(instanceOf(WbDependentModule.class)));
this.wbModuleEntries = Lists.newArrayList(Sets.newLinkedHashSet(Iterables.concat(toKeep, newEntries)));
if (!isNullOrEmpty(deployName)) {
this.deployName = deployName;
}
if (!isNullOrEmpty(contextPath)) {
this.contextPath = contextPath;
}
}
示例3: getActiveSymptoms
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
Iterable<StaminaSymptom> getActiveSymptoms() {
return Iterables.filter(options.symptoms, new Predicate<StaminaSymptom>() {
@Override
public boolean apply(StaminaSymptom symptom) {
return symptom.range.contains(stamina);
}
});
}
示例4: toUnit
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
@Override
public Unit toUnit(Unit unit) {
for (Template template : Iterables.filter(unit.parts(), Template.class)) {
scope.declareInvokable(template.declaration().name());
}
return super.toUnit(unit);
}
示例5: compilar
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
public void compilar() {
StringBuilder sb = new StringBuilder();
Iterable<Ingrediente> _filter = Iterables.<Ingrediente>filter(IteratorExtensions.<EObject>toIterable(this.resource.getAllContents()), Ingrediente.class);
for (final Ingrediente i : _filter) {
sb.append(this.compilarTexto(i));
}
this.fsa.generateFile("ingredientes.txt", sb.toString());
Iterable<Restaurante> _filter_1 = Iterables.<Restaurante>filter(IteratorExtensions.<EObject>toIterable(this.resource.getAllContents()), Restaurante.class);
for (final Restaurante r : _filter_1) {
this.fsa.generateFile("resto_informacion.txt", this.compilarTexto(r));
}
}
示例6: getManifestThemeNames
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
public Iterable<String> getManifestThemeNames(InputStream is) {
return Iterables.filter(
Iterables.transform(
getAttrNames(is, manifestXpathExp),
new Function<String, String>() {
@Override
public String apply(String name) {
return name.startsWith("@style/") ? name.substring("@style/".length()) : null;
}
}),
Predicates.notNull());
}
示例7: getNonKeyFieldsFromMergeStatement
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
/**
* Returns the non key fields from a merge statement.
*
* @param statement a merge statement
* @return the non key fields
*/
protected Iterable<AliasedField> getNonKeyFieldsFromMergeStatement(final MergeStatement statement) {
return Iterables.filter(statement.getSelectStatement().getFields(), new Predicate<AliasedField>() {
@Override
public boolean apply(AliasedField input) {
boolean keyField = false;
for (AliasedField field : statement.getTableUniqueKey()) {
if (input.getImpliedName().equals(field.getImpliedName())) keyField = true;
}
return !keyField;
}
});
}
示例8: copyFiltered
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
public EventArgScoringAlignment<EquivClassType> copyFiltered(
final Predicate<EquivClassType> filter) {
return new EventArgScoringAlignment<EquivClassType>(docID(), argumentOutput, answerKey,
Iterables.filter(truePositiveECs, filter),
Iterables.filter(falsePositiveECs, filter),
Iterables.filter(falseNegativeECs, filter),
Iterables.filter(unassessed, filter),
Multimaps.filterKeys(ecsToAnswerKey, filter),
Multimaps.filterKeys(ecsToSystem, filter));
}
示例9: getPendingLogFilesToUpload
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
private Set<File> getPendingLogFilesToUpload(File containerLogDir) {
Set<File> candidates =
new HashSet<File>(Arrays.asList(containerLogDir.listFiles()));
for (File logFile : candidates) {
this.allExistingFileMeta.add(getLogFileMetaData(logFile));
}
if (this.logAggregationContext != null && candidates.size() > 0) {
filterFiles(
this.appFinished ? this.logAggregationContext.getIncludePattern()
: this.logAggregationContext.getRolledLogsIncludePattern(),
candidates, false);
filterFiles(
this.appFinished ? this.logAggregationContext.getExcludePattern()
: this.logAggregationContext.getRolledLogsExcludePattern(),
candidates, true);
Iterable<File> mask =
Iterables.filter(candidates, new Predicate<File>() {
@Override
public boolean apply(File next) {
return !alreadyUploadedLogFiles
.contains(getLogFileMetaData(next));
}
});
candidates = Sets.newHashSet(mask);
}
return candidates;
}
示例10: getDeletableFiles
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
@Override
public Iterable<FileStatus> getDeletableFiles(Iterable<FileStatus> files) {
// all members of this class are null if replication is disabled,
// so we cannot filter the files
if (this.getConf() == null) {
return files;
}
final Set<String> wals;
try {
// The concurrently created new WALs may not be included in the return list,
// but they won't be deleted because they're not in the checking set.
wals = loadWALsFromQueues();
} catch (KeeperException e) {
LOG.warn("Failed to read zookeeper, skipping checking deletable files");
return Collections.emptyList();
}
return Iterables.filter(files, new Predicate<FileStatus>() {
@Override
public boolean apply(FileStatus file) {
String wal = file.getPath().getName();
boolean logInReplicationQueue = wals.contains(wal);
if (LOG.isDebugEnabled()) {
if (logInReplicationQueue) {
LOG.debug("Found log in ZK, keeping: " + wal);
} else {
LOG.debug("Didn't find this log in ZK, deleting: " + wal);
}
}
return !logInReplicationQueue;
}});
}
示例11: mapGerelateerdeBetrokkenheden
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
private void mapGerelateerdeBetrokkenheden() {
final Iterable<Betrokkenheid> gerelateerdeBetrokkenheden = Iterables.filter(relatie.getBetrokkenheidSet(),
betr -> betr.getPersoon() == null || !betr.getPersoon().getId().equals(blobber.getPersoon().getId()));
for (final Betrokkenheid gerelateerdeBetrokkenheid : gerelateerdeBetrokkenheden) {
new GerelateerdeBetrokkenheidBlobMapper(blobber, gerelateerdeBetrokkenheid).map();
}
}
示例12: findByName
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
private static Iterable<UIClassDescriptor> findByName(
Iterable<UIClassDescriptor> classes, Predicate<UIClassDescriptor> predicate) {
return Iterables.filter(classes, predicate);
}
示例13: filterUpperBounds
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
private static Iterable<Type> filterUpperBounds(Iterable<Type> bounds) {
return Iterables.filter(bounds, Predicates.not(Predicates.<Type>equalTo(Object.class)));
}
示例14: format
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
/**
* Construct a {@code Formatter} given a Java compilation unit. Parses the code; builds a {@link
* JavaInput} and the corresponding {@link JavaOutput}.
*
* @param javaInput the input, a Java compilation unit
* @param javaOutput the {@link JavaOutput}
* @param options the {@link JavaFormatterOptions}
*/
static void format(
final JavaInput javaInput, JavaOutput javaOutput, JavaFormatterOptions options) {
Context context = new Context();
DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector<>();
context.put(DiagnosticListener.class, diagnostics);
Options.instance(context).put("allowStringFolding", "false");
JCCompilationUnit unit;
JavacFileManager fileManager = new JavacFileManager(context, true, UTF_8);
try {
fileManager.setLocation(StandardLocation.PLATFORM_CLASS_PATH, ImmutableList.<File>of());
} catch (IOException e) {
// impossible
throw new IOError(e);
}
SimpleJavaFileObject source =
new SimpleJavaFileObject(URI.create("source"), JavaFileObject.Kind.SOURCE) {
@Override
public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException {
return javaInput.getText();
}
};
Log.instance(context).useSource(source);
ParserFactory parserFactory = ParserFactory.instance(context);
Parser parser =
parserFactory.newParser(
javaInput.getText(),
/*keepDocComments=*/ true,
/*keepEndPos=*/ true,
/*keepLineMap=*/ true);
unit = parser.parseCompilationUnit();
unit.sourcefile = source;
javaInput.setCompilationUnit(unit);
Iterable<Diagnostic<? extends JavaFileObject>> errorDiagnostics =
Iterables.filter(diagnostics.getDiagnostics(), ERROR_DIAGNOSTIC);
if (!Iterables.isEmpty(errorDiagnostics)) {
throw FormattingError.fromJavacDiagnostics(errorDiagnostics);
}
OpsBuilder builder = new OpsBuilder(javaInput, javaOutput);
// Output the compilation unit.
new JavaInputAstVisitor(builder, options.indentationMultiplier()).scan(unit, null);
builder.sync(javaInput.getText().length());
builder.drain();
Doc doc = new DocBuilder().withOps(builder.build()).build();
doc.computeBreaks(
javaOutput.getCommentsHelper(), options.maxLineLength(), new Doc.State(+0, 0));
doc.write(javaOutput);
javaOutput.flush();
}
示例15: getAvailableDevices
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
@Override
public Iterable<Device> getAvailableDevices() {
return Iterables.filter(Iterables.transform(availableDevices, devices::get), d -> d != null);
}