本文整理匯總了Java中com.google.common.collect.FluentIterable類的典型用法代碼示例。如果您正苦於以下問題:Java FluentIterable類的具體用法?Java FluentIterable怎麽用?Java FluentIterable使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
FluentIterable類屬於com.google.common.collect包,在下文中一共展示了FluentIterable類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: filterToType
import com.google.common.collect.FluentIterable; //導入依賴的package包/類
public ElasticIndex filterToType(String name){
List<ElasticMapping> filtered = new ArrayList<>();
for(ElasticMapping m : mappings){
for(String namePiece : name.split(",")){
if(m.getName().equals(namePiece)){
filtered.add(m);
}
}
}
if(filtered.isEmpty()){
return null;
}
return new ElasticIndex(name, ImmutableList.<String>of(), FluentIterable.from(filtered).uniqueIndex(new Function<ElasticMapping, String>(){
@Override
public String apply(ElasticMapping input) {
return input.getName();
}}));
}
示例2: generateRequestOptionOverride
import com.google.common.collect.FluentIterable; //導入依賴的package包/類
private MethodSpec generateRequestOptionOverride(ExecutableElement methodToOverride) {
return MethodSpec.overriding(methodToOverride)
.returns(glideOptionsName)
.addCode(CodeBlock.builder()
.add("return ($T) super.$N(", glideOptionsName, methodToOverride.getSimpleName())
.add(FluentIterable.from(methodToOverride.getParameters())
.transform(new Function<VariableElement, String>() {
@Override
public String apply(VariableElement input) {
return input.getSimpleName().toString();
}
})
.join(Joiner.on(", ")))
.add(");\n")
.build())
.build();
}
示例3: useProvidedTypesForServices
import com.google.common.collect.FluentIterable; //導入依賴的package包/類
private Set<String> useProvidedTypesForServices(TypeElement typeElement, ImmutableList<TypeMirror> typesMirrors) {
List<String> wrongTypes = Lists.newArrayList();
List<String> types = Lists.newArrayList();
for (TypeMirror typeMirror : typesMirrors) {
if (typeMirror.getKind() != TypeKind.DECLARED
|| !processing().getTypeUtils().isAssignable(typeElement.asType(), typeMirror)) {
wrongTypes.add(typeMirror.toString());
} else {
types.add(typeMirror.toString());
}
}
if (!wrongTypes.isEmpty()) {
processing().getMessager().printMessage(
Diagnostic.Kind.ERROR,
"@Metainf.Service(value = {...}) contains types that are not implemented by "
+ typeElement.getSimpleName()
+ ": " + wrongTypes,
typeElement,
AnnotationMirrors.findAnnotation(typeElement.getAnnotationMirrors(), Metainf.Service.class));
}
return FluentIterable.from(types).toSet();
}
示例4: createPermissions
import com.google.common.collect.FluentIterable; //導入依賴的package包/類
/**
* Create permissions, note that permissionType + targetId should be unique
*/
@Transactional
public Set<Permission> createPermissions(Set<Permission> permissions) {
Multimap<String, String> targetIdPermissionTypes = HashMultimap.create();
for (Permission permission : permissions) {
targetIdPermissionTypes.put(permission.getTargetId(), permission.getPermissionType());
}
for (String targetId : targetIdPermissionTypes.keySet()) {
Collection<String> permissionTypes = targetIdPermissionTypes.get(targetId);
List<Permission> current =
permissionRepository.findByPermissionTypeInAndTargetId(permissionTypes, targetId);
Preconditions.checkState(CollectionUtils.isEmpty(current),
"Permission with permissionType %s targetId %s already exists!", permissionTypes,
targetId);
}
Iterable<Permission> results = permissionRepository.save(permissions);
return FluentIterable.from(results).toSet();
}
示例5: FilteredDataSetProducerAdapter
import com.google.common.collect.FluentIterable; //導入依賴的package包/類
/**
* Create a filtered adapter, passing in the list of tables to include.
* @param producer The wrapped {@link DataSetProducer}.
* @param includedTables The tables to include.
*/
public FilteredDataSetProducerAdapter(DataSetProducer producer, Collection<String> includedTables) {
super(producer);
final Set<String> includedSet = FluentIterable.from(includedTables)
.transform(new Function<String, String>() {
@Override
public String apply(String str) {
return str.toUpperCase();
}
})
.toSet();
this.includingPredicate = new Predicate<String>() {
@Override
public boolean apply(String input) {
return includedSet.contains(input);
}
};
}
示例6: delegate
import com.google.common.collect.FluentIterable; //導入依賴的package包/類
@Override
protected Set<TypeToken<? super T>> delegate() {
ImmutableSet<TypeToken<? super T>> result = classes;
if (result == null) {
@SuppressWarnings({"unchecked", "rawtypes"})
ImmutableList<TypeToken<? super T>> collectedTypes =
(ImmutableList)
TypeCollector.FOR_GENERIC_TYPE.classesOnly().collectTypes(TypeToken.this);
return (classes =
FluentIterable.from(collectedTypes)
.filter(TypeFilter.IGNORE_TYPE_VARIABLE_OR_WILDCARD)
.toSet());
} else {
return result;
}
}
示例7: assertExactlyTwoSubdirectories
import com.google.common.collect.FluentIterable; //導入依賴的package包/類
private void assertExactlyTwoSubdirectories(final File outputStoreDir) throws IOException {
checkArgument(outputStoreDir.isDirectory());
if (!new File(outputStoreDir, "arguments").isDirectory()) {
throw new IOException(
"Expected system output to be contain a subdirectory named 'arguments'");
}
if (!new File(outputStoreDir, "linking").isDirectory()) {
throw new IOException("Expected system output to be contain a subdirectory named 'linking'");
}
final ImmutableSet<String> subdirectoryNames =
FluentIterable.from(ImmutableList.copyOf(outputStoreDir.listFiles()))
.transform(FileUtils.ToName)
.toSet();
final boolean hasValidDirectoryStructure = subdirectoryNames.containsAll(REQUIRED_SUBDIRS)
&& ALLOWED_SUBDIRS.containsAll(subdirectoryNames);
if (!hasValidDirectoryStructure) {
throw new IOException(
"Invalid subdirectories ) " + subdirectoryNames + ". Required are: " + REQUIRED_SUBDIRS
+ "; allowed are " + ALLOWED_SUBDIRS);
}
}
示例8: getStatColumnsPerField
import com.google.common.collect.FluentIterable; //導入依賴的package包/類
protected Iterable<StatColumn> getStatColumnsPerField(final RelDataTypeField field) {
final RelDataTypeFamily family = field.getType().getFamily();
final Collection<StatType> dims = DIMENSIONS.get(family);
if (dims.isEmpty()) {
return ImmutableList.of();
}
return FluentIterable.from(dims)
.transform(new Function<StatType, StatColumn>() {
@Nullable
@Override
public StatColumn apply(@Nullable final StatType type) {
return new StatColumn(type, field);
}
});
}
示例9: builderIncludedTypes
import com.google.common.collect.FluentIterable; //導入依賴的package包/類
@Value.Lazy
List<TypeElement> builderIncludedTypes() {
Optional<FIncludeMirror> includes = builderInclude();
ImmutableList<TypeMirror> typeMirrors = includes.isPresent()
? ImmutableList.copyOf(includes.get().valueMirror())
: ImmutableList.<TypeMirror>of();
FluentIterable<TypeElement> typeElements = FluentIterable.from(typeMirrors)
.filter(DeclaredType.class)
.transform(DeclatedTypeToElement.FUNCTION);
ImmutableSet<String> uniqueTypeNames = typeElements
.filter(IsPublic.PREDICATE)
.transform(ElementToName.FUNCTION)
.toSet();
if (uniqueTypeNames.size() != typeMirrors.size()) {
report().annotationNamed(IncludeMirror.simpleName())
.warning("Some types were ignored, non-supported for inclusion: duplicates,"
+ " non declared reference types, non-public");
}
return typeElements.toList();
}
示例10: fromTypes
import com.google.common.collect.FluentIterable; //導入依賴的package包/類
public static TypeFetcher fromTypes() {
return new TypeFetcher() {
// this is technically invalid, as different apis might call. Won't happen, but could.
// make better
Iterable<TypeDeclaration> foundInApi;
@Override
public TypeDeclaration fetchType(Api api, final String name) throws GenerationException {
return FluentIterable.from(Optional.fromNullable(foundInApi).or(api.types()))
.firstMatch(namedPredicate(name)).or(fail(name));
}
};
}
示例11: toString
import com.google.common.collect.FluentIterable; //導入依賴的package包/類
@Override
public String toString() {
Iterable<String> errorMessages = FluentIterable.from(errors).transform(OBJECT_ERROR_TO_TABBED_MESSAGE);
StringBuilder help = new StringBuilder(500)
.append("Usage: check-filters.sh --config=<config_file>[,<config_file>,...]")
.append(System.lineSeparator())
.append("Errors found in the provided configuration file:")
.append(System.lineSeparator())
.append(Joiner.on(System.lineSeparator()).join(errorMessages))
.append(System.lineSeparator())
.append("Configuration file help:")
.append(System.lineSeparator())
.append(TAB)
.append("For more information and help please refer to ")
.append(
"https://stash/projects/HDW/repos/circus-train/circus-train-tool/circus-train-filter-tool/browse/README.md");
return help.toString();
}
示例12: createChainExecutor
import com.google.common.collect.FluentIterable; //導入依賴的package包/類
/**
* Creates a chain executor for the given sub graph of layouts, that last started at the given time, at the given
* refresh period.
*
* @param graph dependency graph
* @param subGraph sub graph
* @param startTimeOfLastChain last start time of the chain
* @param refreshPeriod refresh period
* @return chain executor
*/
private ChainExecutor createChainExecutor(DirectedGraph<DependencyNode, DefaultEdge> graph,
DirectedGraph<DependencyNode, DefaultEdge> subGraph,
long startTimeOfLastChain, long refreshPeriod, long gracePeriod) {
final List<Layout> layouts = FluentIterable.from(TopologicalOrderIterator.of(subGraph))
.transform(new Function<DependencyNode, Layout>() {
@Override
public Layout apply(DependencyNode node) {
return node.getLayout();
}
}).toList();
String uuid = UUID.randomUUID().toString();
String rootId = layouts.get(0).getId().getId();
logger.info("Creating chain executor for root node {} with id {}.", rootId, uuid);
if (logger.isDebugEnabled()) {
logger.debug("Sub graph for chain executor {}:{} is: {}.", rootId, uuid, layouts.toString());
}
return new ChainExecutor(graph, layouts, startTimeOfLastChain, refreshPeriod, gracePeriod, schedulerService,
materializationContext, accelerationService.getSettings().getLayoutRefreshMaxAttempts(), rootId + ":" + uuid);
}
示例13: getList
import com.google.common.collect.FluentIterable; //導入依賴的package包/類
private static <T> List<T> getList(
Map<?, ?> map,
Object key,
List<T> defaultValue,
Function<Object, T> transformation) {
Object value = map.get(key);
if (value == null) {
return defaultValue;
}
if (value instanceof String) {
value = Splitter.on(',').splitToList(value.toString());
}
if (!(value instanceof Collection)) {
return Collections.singletonList(transformation.apply(value));
}
return FluentIterable.from((Collection<?>) value).transform(transformation).toList();
}
示例14: projectInvisibleColumn
import com.google.common.collect.FluentIterable; //導入依賴的package包/類
@Override
public TableScan projectInvisibleColumn(String name) {
Set<String> names = new HashSet<>();
names.addAll(FluentIterable.from(projectedColumns).transform(new Function<SchemaPath, String>(){
@Override
public String apply(SchemaPath input) {
return input.getRootSegment().getPath();
}}).toList());
if(names.contains(name)){
// already included.
return this;
}
List<SchemaPath> columns = new ArrayList<>();
columns.addAll(projectedColumns);
columns.add(SchemaPath.getSimplePath(name));
return this.cloneWithProject(columns);
}
示例15: delegate
import com.google.common.collect.FluentIterable; //導入依賴的package包/類
@Override
protected Set<TypeToken<? super T>> delegate() {
ImmutableSet<TypeToken<? super T>> filteredTypes = types;
if (filteredTypes == null) {
// Java has no way to express ? super T when we parameterize TypeToken vs. Class.
@SuppressWarnings({"unchecked", "rawtypes"})
ImmutableList<TypeToken<? super T>> collectedTypes =
(ImmutableList) TypeCollector.FOR_GENERIC_TYPE.collectTypes(TypeToken.this);
return (types =
FluentIterable.from(collectedTypes)
.filter(TypeFilter.IGNORE_TYPE_VARIABLE_OR_WILDCARD)
.toSet());
} else {
return filteredTypes;
}
}