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>, Func4<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())) { Func4<Field, Method, Class, Annotation, GraphQLOutputType> customGraphQLOutputTypeFunc = annotationToGraphQLOutputTypeMap.get(annotation.annotationType()); GraphQLOutputType outputType = customGraphQLOutputTypeFunc.call(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())) { Func4<Field, Method, Class, Annotation, GraphQLOutputType> customGraphQLOutputTypeFunc = annotationToGraphQLOutputTypeMap.get(annotation.annotationType()); GraphQLOutputType outputType = customGraphQLOutputTypeFunc.call(null, method, declaringClass, annotation); if (outputType != null) { graphQLOutputType = outputType; break; } } } return graphQLOutputType; }
@Test public void test4SourcesOverload() { Observable<Integer> s1 = Observable.just(1); Observable<Integer> s2 = Observable.just(2); Observable<Integer> s3 = Observable.just(3); Observable<Integer> s4 = Observable.just(4); Observable<List<Integer>> result = Observable.combineLatest(s1, s2, s3, s4, new Func4<Integer, Integer, Integer, Integer, List<Integer>>() { @Override public List<Integer> call(Integer t1, Integer t2, Integer t3, Integer t4) { return Arrays.asList(t1, t2, t3, t4); } }); @SuppressWarnings("unchecked") Observer<Object> o = mock(Observer.class); result.subscribe(o); verify(o).onNext(Arrays.asList(1, 2, 3, 4)); verify(o).onComplete(); verify(o, never()).onError(any(Throwable.class)); }
public <T, T1, T2, T3, T4> void restartableFirst(int restartableId, final Func4<T1, T2, T3, T4, Observable<T>> observableFactory, final Action2<View, T> onNext, @Nullable final Action2<View, Throwable> onError) { restartable(restartableId, new Func4<T1, T2, T3, T4, Subscription>() { @Override public Subscription call(T1 arg1, T2 arg2, T3 arg3, T4 arg4) { return observableFactory.call(arg1, arg2, arg3, arg4) .compose(RxPresenter.this.<T>deliverFirst()) .subscribe(split(onNext, onError)); } }); }
private List<GraphQLArgument> getGraphQLArgumentsFromAnnotations(Field field, Method method, Class declaringClass, Annotation[] annotations) { List<GraphQLArgument> argumentList = new ArrayList<>(); for (Annotation annotation : annotations) { // custom arguments if (annotationToArgumentsProviderMap.containsKey(annotation.annotationType())) { Func4<Field, Method, Class, Annotation, List<GraphQLArgument>> customArgumentsFunc = annotationToArgumentsProviderMap.get(annotation.annotationType()); argumentList = customArgumentsFunc.call(field, method, declaringClass, annotation); } } return argumentList; }
private void loadPulseInPastWeekWithReactor(final Repo repo) { Observable<Integer> mergedPullsObservable = getModel().loadMergedPullsInPastWeekWithReactor(repo.owner.login, repo.name); Observable<Integer> proposedPullsObservable = getModel().loadProposedPullsInPastWeekWithReactor(repo.owner.login, repo.name); Observable<Integer> closedIssuesObservable = getModel().loadClosedIssuesInPastWeekWithReactor(repo.owner.login, repo.name); Observable<Integer> openedIssuesObservable = getModel().loadCreatedIssuesInPastWeekWithReactor(repo.owner.login, repo.name); Observable.combineLatest(mergedPullsObservable, proposedPullsObservable, closedIssuesObservable, openedIssuesObservable, new Func4<Integer, Integer, Integer, Integer, Integer[]>() { @Override public Integer[] call(Integer closedPullsCount, Integer openedPullsCount, Integer closedIssuesCount, Integer openedIssuesCount) { RepositoryFragment.this.closedPullsCount = closedPullsCount; RepositoryFragment.this.openedPullsCount = openedPullsCount; RepositoryFragment.this.closedIssuesCount = closedIssuesCount; RepositoryFragment.this.openedIssuesCount = openedIssuesCount; return new Integer[]{closedPullsCount, openedPullsCount, closedIssuesCount, openedIssuesCount}; } }).subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Action1<Integer[]>() { @Override public void call(Integer[] counts) { getUIView().showPulse(counts[0], counts[1], counts[2], counts[3]); } }, new Action1<Throwable>() { @Override public void call(Throwable throwable) { getUIView().showPulse(0, 0, 0, 0); } }); }
public static <T1, T2, T3, T4, R> Observable<R> combineLatest(Observable<? extends T1> o1, Observable<? extends T2> o2, Observable<? extends T3> o3, Observable<? extends T4> o4, Func4<? super T1, ? super T2, ? super T3, ? super T4, ? extends R> combineFunction) { return combineLatest(Arrays.asList(new Observable[]{o1, o2, o3, o4}), Functions.fromFunc(combineFunction)); }
public static <T1, T2, T3, T4, R> Observable<R> zip(Observable<? extends T1> o1, Observable<? extends T2> o2, Observable<? extends T3> o3, Observable<? extends T4> o4, Func4<? super T1, ? super T2, ? super T3, ? super T4, ? extends R> zipFunction) { return just(new Observable[]{o1, o2, o3, o4}).lift(new OperatorZip(zipFunction)); }
public static final <T1, T2, T3, T4, R> Single<R> zip(Single<? extends T1> o1, Single<? extends T2> o2, Single<? extends T3> o3, Single<? extends T4> o4, Func4<? super T1, ? super T2, ? super T3, ? super T4, ? extends R> zipFunction) { return just(new Observable[]{asObservable(o1), asObservable(o2), asObservable(o3), asObservable(o4)}).lift(new OperatorZip((Func4) zipFunction)); }
public OperatorZip(Func4 f) { this.zipFunction = Functions.fromFunc(f); }
public static final <T1, T2, T3, T4, R> Observable<R> combineLatest(Observable<? extends T1> o1, Observable<? extends T2> o2, Observable<? extends T3> o3, Observable<? extends T4> o4, Func4<? super T1, ? super T2, ? super T3, ? super T4, ? extends R> combineFunction) { return combineLatest(Arrays.asList(new Observable[]{o1, o2, o3, o4}), Functions.fromFunc(combineFunction)); }
public static final <T1, T2, T3, T4, R> Observable<R> zip(Observable<? extends T1> o1, Observable<? extends T2> o2, Observable<? extends T3> o3, Observable<? extends T4> o4, Func4<? super T1, ? super T2, ? super T3, ? super T4, ? extends R> zipFunction) { return just(new Observable[]{o1, o2, o3, o4}).lift(new OperatorZip(zipFunction)); }
public <T1, T2, T3, T4> void restartable(int restartableId, Func4<T1, T2, T3, T4, Subscription> factory) { if (workingSubscribers.containsKey(restartableId)) { stop(restartableId); } restartables4.put(restartableId, factory); }
public <T1, T2, T3, T4> void start(int restartableId, T1 arg1, T2 arg2, T3 arg3, T4 arg4) { stop(restartableId); Func4<T1, T2, T3, T4, Subscription> func4 = (Func4<T1, T2, T3, T4, Subscription>) restartables4.get(restartableId); if (func4 != null) workingSubscribers.put(restartableId, func4.call(arg1, arg2, arg3, arg4)); }
@SuppressWarnings("unchecked") public static final <T1, T2, T3, T4, R> Observable<R> combineSinglesDelayError(Observable<? extends T1> o1, Observable<? extends T2> o2, Observable<? extends T3> o3, Observable<? extends T4> o4, Func4<? super T1, ? super T2, ? super T3, ? super T4, ? extends R> combineFunction) { return combineSinglesDelayError(asList(o1.single(), o2.single(), o3.single(), o4.single()), fromFunc(combineFunction)); }
public GlitrBuilder withAnnotationToArgumentsProviderMap(Map<Class<? extends Annotation>, Func4<Field, Method, Class, Annotation, List<GraphQLArgument>>> annotationToArgumentsProviderMap) { this.annotationToArgumentsProviderMap = annotationToArgumentsProviderMap; return this; }
public GlitrBuilder withAnnotationToGraphQLOutputTypeMap(Map<Class<? extends Annotation>, Func4<Field, Method, Class, Annotation, GraphQLOutputType>> annotationToGraphQLOutputTypeMap) { this.annotationToGraphQLOutputTypeMap = annotationToGraphQLOutputTypeMap; return this; }
public GlitrBuilder addCustomFieldArgumentsFunc(Class<? extends Annotation> annotationClass, Func4<Field, Method, Class, Annotation, List<GraphQLArgument>> argumentsFunc4) { annotationToArgumentsProviderMap.putIfAbsent(annotationClass, argumentsFunc4); return this; }
public GlitrBuilder addCustomFieldOutputTypeFunc(Class<? extends Annotation> annotationClass, Func4<Field, Method, Class, Annotation, GraphQLOutputType> argumentsFunc4) { annotationToGraphQLOutputTypeMap.putIfAbsent(annotationClass, argumentsFunc4); return this; }
public TypeRegistryBuilder withAnnotationToArgumentsProviderMap(Map<Class<? extends Annotation>, Func4<Field, Method, Class, Annotation, List<GraphQLArgument>>> annotationToArgumentsProviderMap) { this.annotationToArgumentsProviderMap = annotationToArgumentsProviderMap; return this; }
public TypeRegistryBuilder withAnnotationToGraphQLOutputTypeMap(Map<Class<? extends Annotation>, Func4<Field, Method, Class, Annotation, GraphQLOutputType>> annotationToGraphQLOutputTypeMap) { this.annotationToGraphQLOutputTypeMap = annotationToGraphQLOutputTypeMap; return this; }
public TypeRegistryBuilder addCustomFieldArgumentsFunc(Class<? extends Annotation> annotationClass, Func4<Field, Method, Class, Annotation, List<GraphQLArgument>> argumentsFunc4) { annotationToArgumentsProviderMap.putIfAbsent(annotationClass, argumentsFunc4); return this; }
public TypeRegistryBuilder addCustomFieldOutputTypeFunc(Class<? extends Annotation> annotationClass, Func4<Field, Method, Class, Annotation, GraphQLOutputType> argumentsFunc4) { annotationToGraphQLOutputTypeMap.putIfAbsent(annotationClass, argumentsFunc4); return this; }
@SuppressWarnings({ "unchecked", "rawtypes" }) public OperatorZip(Func4 f) { this.zipFunction = Functions.fromFunc(f); }