下面列出了怎么用rx.functions.Func5的API类实例代码及写法,或者点击链接到github查看源代码。
TypeRegistry(Map<Class, List<Object>> overrides, Map<Class<? extends Annotation>, AnnotationBasedDataFetcherFactory> annotationToDataFetcherFactoryMap, Map<Class<? extends Annotation>,
DataFetcher> annotationToDataFetcherMap, Map<Class<? extends Annotation>, Func4<Field, Method, Class, Annotation, List<GraphQLArgument>>> annotationToArgumentsProviderMap,
Map<Class<? extends Annotation>, Func5<TypeRegistry, Field, Method, Class, Annotation, GraphQLOutputType>> annotationToGraphQLOutputTypeMap,
Map<Class, GraphQLType> javaTypeDeclaredAsScalarMap, Relay relay, boolean explicitRelayNodeScanEnabled) {
this.overrides = overrides;
this.annotationToDataFetcherFactoryMap = annotationToDataFetcherFactoryMap;
this.annotationToDataFetcherMap = annotationToDataFetcherMap;
this.annotationToArgumentsProviderMap = annotationToArgumentsProviderMap;
this.annotationToGraphQLOutputTypeMap = annotationToGraphQLOutputTypeMap;
this.javaTypeDeclaredAsScalarMap = javaTypeDeclaredAsScalarMap;
this.relay = relay;
if (relay != null) {
this.nodeInterface = relay.nodeInterface(this);
// register Node so we don't inadvertently recreate it later
this.registry.put(Node.class, this.nodeInterface);
this.nameRegistry.put(Node.class.getSimpleName(), this.nodeInterface);
}
this.explicitRelayNodeScanEnabled = explicitRelayNodeScanEnabled;
}
private GraphQLOutputType getGraphQLOutputTypeFromAnnotationsOnField(Class declaringClass, Method method, GraphQLOutputType graphQLOutputType, String name) {
Field field = ReflectionUtil.getFieldByName(declaringClass, name);
if (field != null) {
Annotation[] fieldAnnotations = field.getDeclaredAnnotations();
for (Annotation annotation: fieldAnnotations) {
// custom OutputType
if (annotationToGraphQLOutputTypeMap.containsKey(annotation.annotationType())) {
Func5<TypeRegistry, Field, Method, Class, Annotation, GraphQLOutputType> customGraphQLOutputTypeFunc = annotationToGraphQLOutputTypeMap.get(annotation.annotationType());
GraphQLOutputType outputType = customGraphQLOutputTypeFunc.call(this, field, method, declaringClass, annotation);
if (outputType != null) {
graphQLOutputType = outputType;
break;
}
}
}
}
return graphQLOutputType;
}
private GraphQLOutputType getGraphQLOutputTypeFromAnnotationsOnGetter(Class declaringClass, Method method) {
GraphQLOutputType graphQLOutputType = null;
Annotation[] methodAnnotations = method.getDeclaredAnnotations();
for (Annotation annotation: methodAnnotations) {
// custom OutputType
if (annotationToGraphQLOutputTypeMap.containsKey(annotation.annotationType())) {
Func5<TypeRegistry, Field, Method, Class, Annotation, GraphQLOutputType> customGraphQLOutputTypeFunc = annotationToGraphQLOutputTypeMap.get(annotation.annotationType());
GraphQLOutputType outputType = customGraphQLOutputTypeFunc.call(this, null, method, declaringClass, annotation);
if (outputType != null) {
graphQLOutputType = outputType;
break;
}
}
}
return graphQLOutputType;
}
public static <T1, T2, T3, T4, T5, R> Observable<R> toObservable(
final Func5<T1, T2, T3, T4, T5, R> func,
final T1 arg1, final T2 arg2, final T3 arg3, final T4 arg4, final T5 arg5) {
return Observable.create(new Observable.OnSubscribe<R>() {
@Override
public void call(Subscriber<? super R> subscriber) {
try {
final R result = func.call(arg1, arg2, arg3, arg4, arg5);
onNextIfSubscribed(subscriber, result);
onCompletedIfSubsribed(subscriber);
} catch (Exception e) {
onErrorIfSubscribed(subscriber, e);
}
}
});
}
public static <T1, T2, T3, T4, T5, R> Observable<R> combineLatest(Observable<? extends T1> o1, Observable<? extends T2> o2, Observable<? extends T3> o3, Observable<? extends T4> o4, Observable<? extends T5> o5, Func5<? super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? extends R> combineFunction) {
return combineLatest(Arrays.asList(new Observable[]{o1, o2, o3, o4, o5}), Functions.fromFunc(combineFunction));
}
public static <T1, T2, T3, T4, T5, R> Observable<R> zip(Observable<? extends T1> o1, Observable<? extends T2> o2, Observable<? extends T3> o3, Observable<? extends T4> o4, Observable<? extends T5> o5, Func5<? super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? extends R> zipFunction) {
return just(new Observable[]{o1, o2, o3, o4, o5}).lift(new OperatorZip(zipFunction));
}
@SuppressWarnings("unchecked")
public static final <T1, T2, T3, T4, T5, R> Observable<R> combineSinglesDelayError(Observable<? extends T1> o1, Observable<? extends T2> o2, Observable<? extends T3> o3, Observable<? extends T4> o4, Observable<? extends T5> o5,
Func5<? super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? extends R> combineFunction) {
return combineSinglesDelayError(asList(o1.single(), o2.single(), o3.single(), o4.single(), o5.single()), fromFunc(combineFunction));
}
public GlitrBuilder withAnnotationToGraphQLOutputTypeMap(Map<Class<? extends Annotation>, Func5<TypeRegistry, Field, Method, Class, Annotation, GraphQLOutputType>> annotationToGraphQLOutputTypeMap) {
this.annotationToGraphQLOutputTypeMap = annotationToGraphQLOutputTypeMap;
return this;
}
public GlitrBuilder addCustomFieldOutputTypeFunc(Class<? extends Annotation> annotationClass, Func5<TypeRegistry, Field, Method, Class, Annotation, GraphQLOutputType> argumentsFunc5) {
annotationToGraphQLOutputTypeMap.putIfAbsent(annotationClass, argumentsFunc5);
return this;
}
public TypeRegistryBuilder withAnnotationToGraphQLOutputTypeMap(Map<Class<? extends Annotation>, Func5<TypeRegistry, Field, Method, Class, Annotation, GraphQLOutputType>> annotationToGraphQLOutputTypeMap) {
this.annotationToGraphQLOutputTypeMap = annotationToGraphQLOutputTypeMap;
return this;
}
public TypeRegistryBuilder addCustomFieldOutputTypeFunc(Class<? extends Annotation> annotationClass, Func5<TypeRegistry, Field, Method, Class, Annotation, GraphQLOutputType> argumentsFunc5) {
annotationToGraphQLOutputTypeMap.putIfAbsent(annotationClass, argumentsFunc5);
return this;
}