本文整理汇总了Java中com.google.common.collect.Iterables.find方法的典型用法代码示例。如果您正苦于以下问题:Java Iterables.find方法的具体用法?Java Iterables.find怎么用?Java Iterables.find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.collect.Iterables
的用法示例。
在下文中一共展示了Iterables.find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: get
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
@Override
public FileObject get() {
if (aProject != null) {
File manifestFile = aProject.getDefaultConfig().getSourceProvider().getManifestFile();
BuildTypeContainer buildTypeContainer = buildConfig.getCurrentBuildTypeContainer();
File buildManifestFile = buildTypeContainer != null
? buildTypeContainer.getSourceProvider().getManifestFile()
: null;
File m = Iterables.find(Lists.newArrayList(manifestFile, buildManifestFile), Predicates.notNull(), null);
if (m != null) {
return FileUtil.toFileObject(m);
}
}
return null;
}
示例2: findResourceFile
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
private ResourceLocation findResourceFile(SourceGroup[] resSG, final String value, final String folderName) {
FileObject resFile = Iterables.find(
Iterables.transform(
Arrays.asList(resSG),
new Function<SourceGroup, FileObject>() {
@Override
public FileObject apply(SourceGroup sg) {
return sg.getRootFolder().getFileObject(folderName + "/" + value + ".xml");
}
}),
Predicates.notNull(),
null);
if (resFile == null) {
LOG.log(Level.FINE, "Resource file {0} not found for {0}.", value);
return null;
}
return new ResourceLocation(resFile, -1);
}
示例3: getCountryByName
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
@Nullable
public static Country getCountryByName(final String countryName, Context context) {
try {
Locale locale = Iterables.find(Arrays.asList(Locale.getAvailableLocales()), new Predicate<Locale>() {
@Override
public boolean apply(Locale input) {
return input.getDisplayCountry(Locale.US).equals(countryName);
}
});
return new Country(locale.getCountry(),
locale.getDisplayName(),
Helper.getFlagDrawableId(locale.getCountry(), context));
} catch (NullPointerException e) {
return null;
}
}
示例4: testCorrectDataTypeMappingDate
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
/**
* Verify that the data type mapping is correct for date columns.
*/
@Test
public void testCorrectDataTypeMappingDate() throws SQLException {
// Given
final PreparedStatement statement = mock(PreparedStatement.class, RETURNS_SMART_NULLS);
when(connection.prepareStatement(anyString())).thenReturn(statement);
// This is the list of tables that's returned.
when(statement.executeQuery()).thenAnswer(new ReturnTablesMockResultSet(1)).thenAnswer(new ReturnTablesWithDateColumnMockResultSet(2));
// When
final Schema oracleMetaDataProvider = oracle.openSchema(connection, "TESTDATABASE", "TESTSCHEMA");
assertEquals("Table names", "[AREALTABLE]", oracleMetaDataProvider.tableNames().toString());
Column dateColumn = Iterables.find(oracleMetaDataProvider.getTable("AREALTABLE").columns(), new Predicate<Column>() {
@Override
public boolean apply(Column input) {
return "dateColumn".equalsIgnoreCase(input.getName());
}
});
assertEquals("Date column type", dateColumn.getType(), DataType.DATE);
}
示例5: resolveScalaCompilerLibraries
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
private static Map<String, ProjectLibrary> resolveScalaCompilerLibraries(Collection<Project> scalaProjects, boolean useScalaSdk) {
Map<String, ProjectLibrary> scalaCompilerLibraries = Maps.newHashMap();
for (Project scalaProject : scalaProjects) {
IdeaModule ideaModule = scalaProject.getExtensions().getByType(IdeaModel.class).getModule();
Iterable<File> files = getIdeaModuleLibraryDependenciesAsFiles(ideaModule);
ProjectLibrary library = createScalaSdkLibrary(scalaProject, files, useScalaSdk, ideaModule);
if (library != null) {
ProjectLibrary duplicate = Iterables.find(scalaCompilerLibraries.values(), Predicates.equalTo(library), null);
scalaCompilerLibraries.put(scalaProject.getPath(), duplicate == null ? library : duplicate);
}
}
return scalaCompilerLibraries;
}
示例6: planContains
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
public <T extends LogicalOperator> T planContains(final Class<T> operatorClazz) {
return (T) Iterables.find(logicalPlan().getSortedOperators(), new Predicate<LogicalOperator>() {
@Override
public boolean apply(LogicalOperator input) {
return input.getClass().equals(operatorClazz);
}
});
}
示例7: findSourceRoots2
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
@Override
public Result findSourceRoots2(final URL binaryRoot) {
Result r = findAarLibraryRoots(binaryRoot);
if (r != null) {
return r;
}
if (project == null) {
return null;
}
final File binRootDir = FileUtil.archiveOrDirForURL(binaryRoot);
if (binRootDir == null) {
return null;
}
Variant variant = Iterables.find(
project.getVariants(),
new Predicate<Variant>() {
@Override
public boolean apply(Variant input) {
return binRootDir.equals(input.getMainArtifact().getClassesFolder());
}
},
null);
if (variant != null) {
Iterable<FileObject> srcRoots = Iterables.filter(
Iterables.transform(
sourceRootsForVariant(variant),
new Function<File, FileObject>() {
@Override
public FileObject apply(File f) {
return FileUtil.toFileObject(f);
}
}),
Predicates.notNull());
return new GradleSourceResult(srcRoots);
}
return null;
}
示例8: findAarLibraryRoots
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
private Result findAarLibraryRoots(final URL binaryRoot) {
// FileUtil.getArchiveFile(binaryRoot);
AndroidLibrary aLib = null;
Variant variant = buildConfig.getCurrentVariant();
if (variant != null) {
aLib = Iterables.find(
variant.getMainArtifact().getDependencies().getLibraries(),
new Predicate<AndroidLibrary>() {
@Override
public boolean apply(AndroidLibrary lib) {
URL libUrl = FileUtil.urlForArchiveOrDir(FileUtil.normalizeFile(lib.getJarFile()));
return binaryRoot.equals(libUrl);
}
},
null);
}
if (aLib == null) {
return null;
}
// if (aLib instanceof AndroidLibraryProject) {
// AndroidLibraryProject libPrj = (AndroidLibraryProject) aLib;
// LOG.log(Level.FINE, "Found binary from AndroidLibrary {0}", libPrj.getProjectPath());
// } else {
LOG.log(Level.FINE, "Found unknown binary from AndroidLibrary {0}", aLib.getJarFile());
// }
return null;
}
示例9: findFlavorByName
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
@Nullable
public static ProductFlavorContainer findFlavorByName(Iterable<ProductFlavorContainer> flavors, final String name) {
return flavors == null || name == null
? null
: Iterables.find(
flavors,
new Predicate<ProductFlavorContainer>() {
@Override
public boolean apply(ProductFlavorContainer t) {
return name.equals(t.getProductFlavor().getName());
}
},
null);
}
示例10: getSourceProviderContainer
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
@Nullable
public static SourceProviderContainer getSourceProviderContainer(ProductFlavorContainer pfc, final String name) {
return pfc == null || name == null
? null
: Iterables.find(
pfc.getExtraSourceProviders(),
new Predicate<SourceProviderContainer>() {
@Override
public boolean apply(SourceProviderContainer t) {
return name.equals(t.getArtifactName());
}
},
null);
}
示例11: findBuildTypeByName
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
@Nullable
public static BuildTypeContainer findBuildTypeByName(Iterable<BuildTypeContainer> buildTypes, final String name) {
return buildTypes == null || name == null
? null
: Iterables.find(
buildTypes,
new Predicate<BuildTypeContainer>() {
@Override
public boolean apply(BuildTypeContainer t) {
return name.equals(t.getBuildType().getName());
}
},
null);
}
示例12: instrumentTestArtifact
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
@Nullable
public static AndroidArtifact instrumentTestArtifact(Iterable<AndroidArtifact> artifacts) {
return artifacts == null
? null
: Iterables.find(
artifacts,
new Predicate<AndroidArtifact>() {
@Override
public boolean apply(AndroidArtifact a) {
return AndroidProject.ARTIFACT_ANDROID_TEST.equals(a.getName());
}
},
null);
}
示例13: findVariantByName
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
@Nullable
public static Variant findVariantByName(Iterable<Variant> variants, final String name) {
return variants == null || name == null
? null
: Iterables.find(
variants,
new Predicate<Variant>() {
@Override
public boolean apply(Variant t) {
return name.equals(t.getName());
}
},
null);
}
示例14: addRenamedProject
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
public static Rel addRenamedProject(SqlHandlerConfig config, Rel rel, RelDataType validatedRowType) {
RelDataType t = rel.getRowType();
RexBuilder b = rel.getCluster().getRexBuilder();
List<RexNode> projections = Lists.newArrayList();
int projectCount = t.getFieldList().size();
for (int i =0; i < projectCount; i++) {
projections.add(b.makeInputRef(rel, i));
}
final List<String> fieldNames2 = SqlValidatorUtil.uniquify(
validatedRowType.getFieldNames(),
SqlValidatorUtil.F_SUGGESTER,
rel.getCluster().getTypeFactory().getTypeSystem().isSchemaCaseSensitive());
RelDataType newRowType = RexUtil.createStructType(rel.getCluster().getTypeFactory(), projections, fieldNames2);
ProjectRel topProj = ProjectRel.create(rel.getCluster(), rel.getTraitSet(), rel, projections, newRowType);
final boolean hasAnyType = Iterables.find(
validatedRowType.getFieldList(),
new Predicate<RelDataTypeField>() {
@Override
public boolean apply(@Nullable RelDataTypeField input) {
return input.getType().getSqlTypeName() == SqlTypeName.ANY;
}
},
null
) != null;
// Add a final non-trivial Project to get the validatedRowType, if child is not project or the input row type
// contains at least one field of type ANY
if (rel instanceof Project && MoreRelOptUtil.isTrivialProject(topProj, true) && !hasAnyType) {
return rel;
}
return topProj;
}
示例15: updateDatasetField
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
/**
* Update field schema
* @param datasetConfig old dataset config
* @param fieldName field's name
* @param fieldSchema new field schema
* @return updated dataset config
*/
private DatasetConfig updateDatasetField(DatasetConfig datasetConfig, final String fieldName, CompleteType fieldSchema) {
// clone the dataset config
Serializer<DatasetConfig> serializer = ProtostuffSerializer.of(DatasetConfig.getSchema());
DatasetConfig newDatasetConfig = serializer.deserialize(serializer.serialize(datasetConfig));
List<DatasetField> datasetFields = newDatasetConfig.getDatasetFieldsList();
if (datasetFields == null) {
datasetFields = Lists.newArrayList();
}
DatasetField datasetField = Iterables.find(datasetFields, new Predicate<DatasetField>() {
@Override
public boolean apply(@Nullable DatasetField input) {
return fieldName.equals(input.getFieldName());
}
}, null);
if (datasetField == null) {
datasetField = new DatasetField().setFieldName(fieldName);
datasetFields.add(datasetField);
}
datasetField.setFieldSchema(ByteString.copyFrom(fieldSchema.serialize()));
newDatasetConfig.setDatasetFieldsList(datasetFields);
return newDatasetConfig;
}