├── .gitattributes ├── .github ├── dependabot.yml └── workflows │ ├── gradle-wrapper-validation.yml │ └── gradle.yml ├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── build.gradle ├── config ├── checkstyle │ ├── checkstyle.xml │ └── suppressions.xml └── license │ ├── HEADER │ └── HEADER_JAVA ├── gradle.properties ├── gradle ├── stylesheet.css └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── pmd.xml ├── push.sh ├── settings.gradle └── src ├── jmh └── java │ └── hu │ └── akarnokd │ └── rxjava3 │ ├── ExamplePerf.java │ ├── FlatMapExPerf.java │ ├── PerfAsyncConsumer.java │ └── PerfConsumer.java ├── main └── java │ └── hu │ └── akarnokd │ └── rxjava3 │ ├── async │ ├── AnyValue.java │ ├── AsyncFlowable.java │ ├── AsyncObservable.java │ ├── DisposableFlowable.java │ ├── DisposableObservable.java │ ├── FlowableFromCallableNull.java │ ├── FutureCompletable.java │ ├── ObservableFromSupplierNull.java │ └── package-info.java │ ├── basetypes │ ├── BasicEmptyQueueSubscription.java │ ├── BasicNonoIntQueueSubscription.java │ ├── BasicNonoSubscriber.java │ ├── BasicRefNonoSubscriber.java │ ├── BasicRefQueueSubscription.java │ ├── BasicSoloQueueSubscription.java │ ├── BlockingGetSubscriber.java │ ├── FuturePerhapsSubscriber.java │ ├── Nono.java │ ├── NonoAmbArray.java │ ├── NonoAmbIterable.java │ ├── NonoAndThen.java │ ├── NonoAndThenPublisher.java │ ├── NonoBlockingAwaitSubscriber.java │ ├── NonoCache.java │ ├── NonoComplete.java │ ├── NonoConcat.java │ ├── NonoConcatArray.java │ ├── NonoConcatIterable.java │ ├── NonoCreate.java │ ├── NonoDefer.java │ ├── NonoDelay.java │ ├── NonoDelaySubscription.java │ ├── NonoDoFinally.java │ ├── NonoDoOnLifecycle.java │ ├── NonoError.java │ ├── NonoErrorSupplier.java │ ├── NonoFlatMapSignal.java │ ├── NonoFromAction.java │ ├── NonoFromCompletable.java │ ├── NonoFromFuture.java │ ├── NonoFromMaybe.java │ ├── NonoFromObservable.java │ ├── NonoFromPublisher.java │ ├── NonoFromSingle.java │ ├── NonoHide.java │ ├── NonoLambdaSubscriber.java │ ├── NonoLift.java │ ├── NonoMapError.java │ ├── NonoMerge.java │ ├── NonoMergeArray.java │ ├── NonoMergeIterable.java │ ├── NonoNever.java │ ├── NonoObserveOn.java │ ├── NonoOnErrorComplete.java │ ├── NonoOnErrorResume.java │ ├── NonoProcessor.java │ ├── NonoRepeat.java │ ├── NonoRepeatUntil.java │ ├── NonoRepeatWhen.java │ ├── NonoRetry.java │ ├── NonoRetryWhen.java │ ├── NonoRetryWhile.java │ ├── NonoSubscribeOn.java │ ├── NonoTakeUntil.java │ ├── NonoTimeout.java │ ├── NonoTimer.java │ ├── NonoToMaybe.java │ ├── NonoToPerhaps.java │ ├── NonoUnsubscribeOn.java │ ├── NonoUsing.java │ ├── Perhaps.java │ ├── PerhapsAmbArray.java │ ├── PerhapsAmbIterable.java │ ├── PerhapsAndThenNono.java │ ├── PerhapsCache.java │ ├── PerhapsCreate.java │ ├── PerhapsDefaultIfEmpty.java │ ├── PerhapsDefer.java │ ├── PerhapsDelay.java │ ├── PerhapsDelayPublisher.java │ ├── PerhapsDelaySubscription.java │ ├── PerhapsDoFinally.java │ ├── PerhapsDoOnLifecycle.java │ ├── PerhapsEmpty.java │ ├── PerhapsError.java │ ├── PerhapsErrorSupplier.java │ ├── PerhapsFilter.java │ ├── PerhapsFlatMap.java │ ├── PerhapsFlatMapPublisher.java │ ├── PerhapsFlatMapSignal.java │ ├── PerhapsFromAction.java │ ├── PerhapsFromCallable.java │ ├── PerhapsFromCompletable.java │ ├── PerhapsFromFuture.java │ ├── PerhapsFromMaybe.java │ ├── PerhapsFromPublisher.java │ ├── PerhapsFromSingle.java │ ├── PerhapsHide.java │ ├── PerhapsJust.java │ ├── PerhapsLift.java │ ├── PerhapsMap.java │ ├── PerhapsMapError.java │ ├── PerhapsNever.java │ ├── PerhapsObserveOn.java │ ├── PerhapsOnErrorResumeNext.java │ ├── PerhapsOnErrorResumeWith.java │ ├── PerhapsOnErrorReturnItem.java │ ├── PerhapsProcessor.java │ ├── PerhapsRetry.java │ ├── PerhapsRetryWhen.java │ ├── PerhapsRetryWhile.java │ ├── PerhapsSubscribeOn.java │ ├── PerhapsSwitchIfEmpty.java │ ├── PerhapsTakeUntil.java │ ├── PerhapsTimeout.java │ ├── PerhapsTimer.java │ ├── PerhapsToFlowable.java │ ├── PerhapsToMaybe.java │ ├── PerhapsToObservable.java │ ├── PerhapsUnsubscribeOn.java │ ├── PerhapsUsing.java │ ├── PerhapsZipArray.java │ ├── PerhapsZipIterable.java │ ├── Solo.java │ ├── SoloAmbArray.java │ ├── SoloAmbIterable.java │ ├── SoloAndThen.java │ ├── SoloCache.java │ ├── SoloCreate.java │ ├── SoloDefer.java │ ├── SoloDelay.java │ ├── SoloDelayPublisher.java │ ├── SoloDelaySubscription.java │ ├── SoloDoFinally.java │ ├── SoloDoOnLifecycle.java │ ├── SoloError.java │ ├── SoloErrorSupplier.java │ ├── SoloFilter.java │ ├── SoloFlatMap.java │ ├── SoloFlatMapPublisher.java │ ├── SoloFlatMapSignal.java │ ├── SoloFromCallable.java │ ├── SoloFromFuture.java │ ├── SoloFromPublisher.java │ ├── SoloFromSingle.java │ ├── SoloHide.java │ ├── SoloJust.java │ ├── SoloLift.java │ ├── SoloMap.java │ ├── SoloMapError.java │ ├── SoloNever.java │ ├── SoloObserveOn.java │ ├── SoloOnErrorResumeNext.java │ ├── SoloOnErrorResumeWith.java │ ├── SoloOnErrorReturnItem.java │ ├── SoloProcessor.java │ ├── SoloRetry.java │ ├── SoloRetryWhen.java │ ├── SoloRetryWhile.java │ ├── SoloSubscribeOn.java │ ├── SoloTakeUntil.java │ ├── SoloTimeout.java │ ├── SoloTimer.java │ ├── SoloToFlowable.java │ ├── SoloToObservable.java │ ├── SoloToSingle.java │ ├── SoloUnsubscribeOn.java │ ├── SoloUsing.java │ ├── SoloZipArray.java │ ├── SoloZipIterable.java │ └── package-info.java │ ├── consumers │ ├── AbstractDisposableAutoRelease.java │ ├── CompletableConsumers.java │ ├── DisposableAutoReleaseMultiObserver.java │ ├── DisposableAutoReleaseObserver.java │ ├── DisposableAutoReleaseSubscriber.java │ ├── FlowableConsumers.java │ ├── MaybeConsumers.java │ ├── ObservableConsumers.java │ ├── SingleConsumers.java │ └── package-info.java │ ├── debug │ ├── CompletableOnAssembly.java │ ├── CompletableOnAssemblyScalarSupplier.java │ ├── CompletableOnAssemblySupplier.java │ ├── FlowableOnAssembly.java │ ├── FlowableOnAssemblyConnectable.java │ ├── FlowableOnAssemblyScalarSupplier.java │ ├── FlowableOnAssemblySupplier.java │ ├── MaybeOnAssembly.java │ ├── MaybeOnAssemblyScalarSupplier.java │ ├── MaybeOnAssemblySupplier.java │ ├── ObservableOnAssembly.java │ ├── ObservableOnAssemblyConnectable.java │ ├── ObservableOnAssemblyScalarSupplier.java │ ├── ObservableOnAssemblySupplier.java │ ├── ParallelFlowableOnAssembly.java │ ├── RxJavaAssemblyException.java │ ├── RxJavaAssemblyTracking.java │ ├── SavedHooks.java │ ├── SingleOnAssembly.java │ ├── SingleOnAssemblyScalarSupplier.java │ ├── SingleOnAssemblySupplier.java │ ├── multihook │ │ ├── MultiHandlerManager.java │ │ ├── OnScheduleMultiHandlerManager.java │ │ └── package-info.java │ ├── package-info.java │ └── validator │ │ ├── CompletableValidator.java │ │ ├── ConnectableFlowableValidator.java │ │ ├── ConnectableObservableValidator.java │ │ ├── FlowableValidator.java │ │ ├── MaybeValidator.java │ │ ├── MultipleOnSubscribeCallsException.java │ │ ├── MultipleTerminationsException.java │ │ ├── NullOnErrorParameterException.java │ │ ├── NullOnNextParameterException.java │ │ ├── NullOnSubscribeParameterException.java │ │ ├── NullOnSuccessParameterException.java │ │ ├── ObservableValidator.java │ │ ├── OnNextAfterTerminationException.java │ │ ├── OnSubscribeNotCalledException.java │ │ ├── OnSuccessAfterTerminationException.java │ │ ├── ParallelFlowableValidator.java │ │ ├── ProtocolNonConformanceException.java │ │ ├── RxJavaProtocolValidator.java │ │ ├── SingleValidator.java │ │ └── package-info.java │ ├── expr │ ├── CompletableIfThen.java │ ├── CompletableSwitchCase.java │ ├── FlowableIfThen.java │ ├── FlowableSwitchCase.java │ ├── FlowableWhileDoWhile.java │ ├── MaybeIfThen.java │ ├── MaybeSwitchCase.java │ ├── ObservableIfThen.java │ ├── ObservableSwitchCase.java │ ├── ObservableWhileDoWhile.java │ ├── SingleIfThen.java │ ├── SingleSwitchCase.java │ ├── StatementCompletable.java │ ├── StatementFlowable.java │ ├── StatementMaybe.java │ ├── StatementObservable.java │ ├── StatementSingle.java │ └── package-info.java │ ├── functions │ ├── Consumer3.java │ ├── Consumer4.java │ ├── Consumer5.java │ ├── Consumer6.java │ ├── Consumer7.java │ ├── Consumer8.java │ ├── Consumer9.java │ ├── FunctionTagging.java │ ├── FunctionsEx.java │ ├── PlainBiConsumer.java │ ├── PlainBiFunction.java │ ├── PlainConsumer.java │ ├── PlainFunction.java │ ├── PlainFunction3.java │ ├── PlainFunction4.java │ ├── PlainFunction5.java │ ├── PlainFunction6.java │ ├── PlainFunction7.java │ ├── PlainFunction8.java │ ├── PlainFunction9.java │ ├── SimpleCallable.java │ └── package-info.java │ ├── joins │ ├── ActivePlan0.java │ ├── ActivePlan1.java │ ├── ActivePlan2.java │ ├── ActivePlan3.java │ ├── ActivePlan4.java │ ├── ActivePlan5.java │ ├── ActivePlan6.java │ ├── ActivePlan7.java │ ├── ActivePlan8.java │ ├── ActivePlan9.java │ ├── ActivePlanN.java │ ├── JoinObservable.java │ ├── JoinObserver.java │ ├── JoinObserver1.java │ ├── JoinPatterns.java │ ├── Pattern1.java │ ├── Pattern2.java │ ├── Pattern3.java │ ├── Pattern4.java │ ├── Pattern5.java │ ├── Pattern6.java │ ├── Pattern7.java │ ├── Pattern8.java │ ├── Pattern9.java │ ├── PatternN.java │ ├── Plan.java │ ├── Plan1.java │ ├── Plan2.java │ ├── Plan3.java │ ├── Plan4.java │ ├── Plan5.java │ ├── Plan6.java │ ├── Plan7.java │ ├── Plan8.java │ ├── Plan9.java │ ├── PlanN.java │ └── package-info.java │ ├── math │ ├── FlowableAverageDouble.java │ ├── FlowableAverageFloat.java │ ├── FlowableMinMax.java │ ├── FlowableSource.java │ ├── FlowableSumDouble.java │ ├── FlowableSumFloat.java │ ├── FlowableSumInt.java │ ├── FlowableSumLong.java │ ├── MathFlowable.java │ ├── MathObservable.java │ ├── ObservableAverageDouble.java │ ├── ObservableAverageFloat.java │ ├── ObservableMinMax.java │ ├── ObservableSource.java │ ├── ObservableSumDouble.java │ ├── ObservableSumFloat.java │ ├── ObservableSumInt.java │ ├── ObservableSumLong.java │ └── package-info.java │ ├── operators │ ├── BasicEmitter.java │ ├── BasicMergeSubscription.java │ ├── CompletableFlatMapSignalCompletable.java │ ├── CompletableFlatMapSignalFlowable.java │ ├── CompletableFlatMapSignalMaybe.java │ ├── CompletableFlatMapSignalObservable.java │ ├── CompletableFlatMapSignalSingle.java │ ├── CompletableTransformers.java │ ├── Completables.java │ ├── ExpandStrategy.java │ ├── FlowableAsyncEmitter.java │ ├── FlowableBufferPredicate.java │ ├── FlowableCacheLast.java │ ├── FlowableCoalesce.java │ ├── FlowableDebounceFirst.java │ ├── FlowableErrorJump.java │ ├── FlowableEvery.java │ ├── FlowableExpand.java │ ├── FlowableFilterAsync.java │ ├── FlowableFlatMapAsync.java │ ├── FlowableFlatMapSync.java │ ├── FlowableGenerateAsync.java │ ├── FlowableIndexOf.java │ ├── FlowableIntervalBackpressure.java │ ├── FlowableMapAsync.java │ ├── FlowableMapFilter.java │ ├── FlowableOnBackpressureTimeout.java │ ├── FlowableOrderedMerge.java │ ├── FlowablePartialCollect.java │ ├── FlowableRepeatScalar.java │ ├── FlowableRepeatSupplier.java │ ├── FlowableRequestObserveOn.java │ ├── FlowableRequestSample.java │ ├── FlowableRequestSampleTime.java │ ├── FlowableSpanout.java │ ├── FlowableSwitchFlatMap.java │ ├── FlowableSwitchIfEmptyMany.java │ ├── FlowableSwitchIfEmptyManyArray.java │ ├── FlowableSwitchOnFirst.java │ ├── FlowableTimeoutLast.java │ ├── FlowableTransformers.java │ ├── FlowableValve.java │ ├── FlowableWindowPredicate.java │ ├── FlowableZipLatest.java │ ├── Flowables.java │ ├── MaybeFlatMapSignalCompletable.java │ ├── MaybeFlatMapSignalFlowable.java │ ├── MaybeFlatMapSignalMaybe.java │ ├── MaybeFlatMapSignalObservable.java │ ├── MaybeFlatMapSignalSingle.java │ ├── MaybeTransformers.java │ ├── Maybes.java │ ├── ObservableErrorJump.java │ ├── ObservableFilterAsync.java │ ├── ObservableFlatMapDrop.java │ ├── ObservableFlatMapLatest.java │ ├── ObservableIndexOf.java │ ├── ObservableMapAsync.java │ ├── ObservableObserveOnDrop.java │ ├── ObservableObserveOnLatest.java │ ├── ObservableTransformers.java │ ├── ObservableValve.java │ ├── Observables.java │ ├── PartialCollectEmitter.java │ ├── SingleFlatMapSignalCompletable.java │ ├── SingleFlatMapSignalFlowable.java │ ├── SingleFlatMapSignalMaybe.java │ ├── SingleFlatMapSignalObservable.java │ ├── SingleFlatMapSignalSingle.java │ ├── SingleTransformers.java │ ├── Singles.java │ └── package-info.java │ ├── parallel │ ├── ParallelOrderedMerge.java │ ├── ParallelSumDouble.java │ ├── ParallelSumInteger.java │ ├── ParallelSumLong.java │ ├── ParallelTransformers.java │ └── package-info.java │ ├── processors │ ├── DispatchWorkProcessor.java │ ├── FlowableProcessorWrap.java │ ├── FlowableProcessors.java │ ├── RefCountProcessor.java │ └── package-info.java │ ├── schedulers │ ├── BlockingScheduler.java │ ├── ParallelScheduler.java │ ├── SharedScheduler.java │ └── package-info.java │ ├── string │ ├── FlowableCharSequence.java │ ├── FlowableSplit.java │ ├── ObservableCharSequence.java │ ├── StringFlowable.java │ ├── StringObservable.java │ └── package-info.java │ ├── subjects │ ├── DispatchWorkSubject.java │ ├── RefCountSubject.java │ ├── Subjects.java │ ├── UnicastWorkSubject.java │ └── package-info.java │ └── util │ ├── AlwaysFalseBooleanSupplier.java │ ├── AlwaysTrueBooleanSupplier.java │ ├── BiFunctionSecondIdentity.java │ ├── CompositeSubscription.java │ ├── SelfComparator.java │ ├── SneakyThrows.java │ ├── SpmcLinkedArrayQueue.java │ ├── SpscOneQueue.java │ └── package-info.java └── test └── java └── hu └── akarnokd └── rxjava3 ├── async ├── AsyncFlowableTest.java └── AsyncObservableTest.java ├── basetypes ├── NonoProcessorTest.java ├── NonoTest.java ├── PerhapsTest.java └── SoloTest.java ├── consumers ├── CompletableConsumersTest.java ├── FlowableConsumersTest.java ├── MaybeConsumersTest.java ├── ObservableConsumersTest.java └── SingleConsumersTest.java ├── debug ├── RxJava3AssemblyTrackingTest.java ├── multihook │ └── OnScheduleMultiHandlerManagerTest.java └── validator │ └── RxJavaProtocolValidatorTest.java ├── expr ├── StatementCompletableTest.java ├── StatementFlowableTest.java ├── StatementMaybeTest.java ├── StatementObservableTest.java └── StatementSingleTest.java ├── functions └── FunctionTaggingTest.java ├── joins └── OperatorJoinsTest.java ├── math ├── MathFlowableTest.java └── MathObservableTest.java ├── operators ├── CompletableFlatMapSignalCompletableTest.java ├── CompletableFlatMapSignalFlowableTest.java ├── CompletableFlatMapSignalMaybeTest.java ├── CompletableFlatMapSignalObservableTest.java ├── CompletableFlatMapSignalSingleTest.java ├── CompletableTransformersTest.java ├── CompletablesTest.java ├── FlowableBufferPredicateTest.java ├── FlowableCacheLastTest.java ├── FlowableCoalesceTest.java ├── FlowableDebounceFirstTest.java ├── FlowableErrorJumpTest.java ├── FlowableEveryTest.java ├── FlowableExpandTest.java ├── FlowableFilterAsyncTest.java ├── FlowableFlatMapAsyncTest.java ├── FlowableFlatMapSyncTest.java ├── FlowableGenerateAsyncTest.java ├── FlowableIndexOfTest.java ├── FlowableIntervalBackpressureTest.java ├── FlowableMapAsyncTest.java ├── FlowableMapFilterConditionalTest.java ├── FlowableMapFilterTest.java ├── FlowableOnBackpressureTimeoutTest.java ├── FlowableOrderedMergeTest.java ├── FlowablePartialCollectTest.java ├── FlowableRepeatCallableTest.java ├── FlowableRequestObserveOnTest.java ├── FlowableRequestSampleTest.java ├── FlowableRequestSampleTimeTest.java ├── FlowableSpanoutTest.java ├── FlowableSwitchFlatMapTest.java ├── FlowableSwitchIfEmptyManyArrayTest.java ├── FlowableSwitchIfEmptyManyTest.java ├── FlowableSwitchOnFirstTest.java ├── FlowableTimeoutLastTest.java ├── FlowableTransformersTest.java ├── FlowableValveTest.java ├── FlowableWindowPredicateTest.java ├── FlowableZipLatestTest.java ├── FlowablesTest.java ├── MaybeFlatMapSignalCompletableTest.java ├── MaybeFlatMapSignalFlowableTest.java ├── MaybeFlatMapSignalMaybeTest.java ├── MaybeFlatMapSignalObservableTest.java ├── MaybeFlatMapSignalSingleTest.java ├── ObservableErrorJumpTest.java ├── ObservableFilterAsyncTest.java ├── ObservableFlatMapDropTest.java ├── ObservableFlatMapLatestTest.java ├── ObservableIndexOfTest.java ├── ObservableMapAsyncTest.java ├── ObservableObserveOnDropTest.java ├── ObservableObserveOnLatestTest.java ├── ObservableTransformersTest.java ├── ObservableValveTest.java ├── ObservablesTest.java ├── SingleFlatMapSignalCompletableTest.java ├── SingleFlatMapSignalFlowableTest.java ├── SingleFlatMapSignalMaybeTest.java ├── SingleFlatMapSignalObservableTest.java ├── SingleFlatMapSignalSingleTest.java ├── SingleTransformersTest.java └── SinglesTest.java ├── parallel ├── ParallelOrderedMergeTest.java └── ParallelSumTest.java ├── processors ├── DispatchWorkProcessorTest.java ├── FlowableProcessorsTest.java └── RefCountProcessorTest.java ├── schedulers ├── BlockingSchedulerTest.java ├── ParallelSchedulerTest.java └── SharedSchedulerTest.java ├── string ├── FlowableCharSequenceTest.java ├── StringFlowableTest.java └── StringObservableTest.java ├── subjects ├── DispatchWorkSubjectTest.java ├── RefCountSubjectTest.java ├── SubjectsTest.java └── UnicastWorkSubjectTest.java ├── test ├── BaseTest.java ├── BaseTestConsumerEx.java ├── TestException.java ├── TestHelper.java ├── TestObserverEx.java └── TestSubscriberEx.java ├── util └── SpmcLinkedArrayQueueTest.java └── validation ├── CheckLocalVariablesInTests.java ├── NewLinesBeforeAnnotation.java └── TooManyEmptyNewLines.java /.gitattributes: -------------------------------------------------------------------------------- 1 | # Set default behaviour, in case users don't have core.autocrlf set. 2 | * text=auto 3 | 4 | # Explicitly declare text files we want to always be normalized and converted 5 | # to native line endings on checkout. 6 | *.java text 7 | *.groovy text 8 | *.scala text 9 | *.clj text 10 | *.txt text 11 | *.md text 12 | 13 | # Denote all files that are truly binary and should not be modified. 14 | *.png binary 15 | *.jpg binary 16 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: gradle 4 | directory: "/" 5 | schedule: 6 | interval: daily 7 | time: "04:00" 8 | open-pull-requests-limit: 20 9 | ignore: 10 | - dependency-name: com.vanniktech:gradle-maven-publish-plugin 11 | versions: 12 | - 0.14.0 13 | - 0.14.1 14 | - 0.14.2 15 | - 0.15.0 16 | -------------------------------------------------------------------------------- /.github/workflows/gradle-wrapper-validation.yml: -------------------------------------------------------------------------------- 1 | name: "Validate Gradle Wrapper" 2 | on: [push, pull_request] 3 | 4 | jobs: 5 | validation: 6 | name: "Validation" 7 | runs-on: ubuntu-latest 8 | steps: 9 | - uses: actions/checkout@v2 10 | - uses: gradle/wrapper-validation-action@v1 11 | -------------------------------------------------------------------------------- /.github/workflows/gradle.yml: -------------------------------------------------------------------------------- 1 | # This workflow will build a Java project with Gradle 2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle 3 | 4 | name: Java CI with Gradle 5 | 6 | on: 7 | push: 8 | branches: [ 3.x ] 9 | pull_request: 10 | branches: [ 3.x ] 11 | 12 | jobs: 13 | build: 14 | 15 | runs-on: ubuntu-latest 16 | env: 17 | CI_PULL_REQUEST: ${{ github.event.number }} 18 | JAVADOCS_TOKEN: ${{ secrets.JAVADOCS_TOKEN }} 19 | CI_BUILD_NUMBER: ${{ github.run_number }} 20 | steps: 21 | - uses: actions/checkout@v2 22 | - name: Set up JDK 1.8 23 | uses: actions/setup-java@v1 24 | with: 25 | java-version: 1.8 26 | - name: Cache Gradle packages 27 | uses: actions/cache@v2 28 | with: 29 | path: ~/.gradle/caches 30 | key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} 31 | restore-keys: ${{ runner.os }}-gradle 32 | - name: Grant execute permission for gradlew 33 | run: chmod +x gradlew 34 | - name: Grant execute permission for push 35 | run: chmod +x push.sh 36 | - name: Build with Gradle 37 | run: ./gradlew build javadoc --stacktrace 38 | - name: Upload to Codecov 39 | uses: codecov/codecov-action@v1 40 | - name: Push Javadocs 41 | run: ./push.sh 42 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | 3 | # Package Files # 4 | *.jar 5 | *.war 6 | *.ear 7 | /build/ 8 | 9 | .gradle 10 | .m2 11 | /.nb-gradle/ 12 | /bin/ 13 | .settings/ 14 | .nb-gradle-properties 15 | .classpath 16 | .project 17 | .settings 18 | .metadata 19 | .checkstyle 20 | bin/ 21 | !/gradle/wrapper/gradle-wrapper.jar 22 | .pmd 23 | .ruleset 24 | local.properties -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | 3 | jdk: 4 | - openjdk8 5 | 6 | before_install: 7 | - chmod +x gradlew 8 | 9 | after_success: 10 | - bash <(curl -s https://codecov.io/bash) 11 | - bash ./push.sh 12 | 13 | # cache between builds 14 | cache: 15 | directories: 16 | - $HOME/.m2 17 | - $HOME/.gradle 18 | 19 | -------------------------------------------------------------------------------- /config/checkstyle/checkstyle.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /config/checkstyle/suppressions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /config/license/HEADER: -------------------------------------------------------------------------------- 1 | Copyright 2016-present David Karnok 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | -------------------------------------------------------------------------------- /config/license/HEADER_JAVA: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | GROUP=com.github.akarnokd 2 | VERSION_NAME=3.1.1 3 | version=3.1.1 4 | 5 | POM_ARTIFACT_ID=rxjava3-extensions 6 | POM_NAME=RxJava 3 extra sources, operators and components 7 | POM_PACKAGING=jar 8 | 9 | POM_DESCRIPTION=RxJava 3.x extra sources, operators and components and ports of many 1.x companion libraries. 10 | POM_INCEPTION_YEAR=2016 11 | 12 | POM_URL=https://github.com/akarnokd/RxJavaExtensions 13 | POM_SCM_URL=https://github.com/akarnokd/RxJavaExtensions 14 | POM_SCM_CONNECTION=scm:git:git://github.com/akarnokd/RxJavaExtensions.git 15 | POM_SCM_DEV_CONNECTION=scm:git:ssh://git@github.com/akarnokd/RxJavaExtensions.git 16 | 17 | POM_LICENCE_NAME=The Apache Software License, Version 2.0 18 | POM_LICENCE_URL=https://www.apache.org/licenses/LICENSE-2.0.txt 19 | POM_LICENCE_DIST=repo 20 | 21 | POM_DEVELOPER_ID=akarnokd 22 | POM_DEVELOPER_NAME=David Karnok 23 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akarnokd/RxJavaExtensions/ca1c4490ec45cab302c8dcf781f72e8aed2cdcaa/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /push.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # ---------------------------------------------------------- 3 | # Automatically push back the generated JavaDocs to gh-pages 4 | # ---------------------------------------------------------- 5 | # based on https://gist.github.com/willprice/e07efd73fb7f13f917ea 6 | 7 | # specify the common address for the repository 8 | targetRepo=github.com/akarnokd/RxJavaExtensions.git 9 | # ======================================================================= 10 | 11 | # only for main pushes, for now 12 | if [ "$CI_PULL_REQUEST" == "true" ]; then 13 | echo -e "Pull request detected, skipping JavaDocs pushback." 14 | exit 0 15 | fi 16 | 17 | # check if the token is actually there 18 | if [ "$JAVADOCS_TOKEN" == "" ]; then 19 | echo -e "No access to GitHub, skipping JavaDocs pushback." 20 | exit 0 21 | fi 22 | 23 | # prepare the git information 24 | git config --global user.email "akarnokd@gmail.com" 25 | git config --global user.name "akarnokd" 26 | 27 | # setup the remote 28 | git remote add origin-pages https://${JAVADOCS_TOKEN}@${targetRepo} > /dev/null 2>&1 29 | 30 | # stash changes due to chmod 31 | git stash 32 | 33 | # get the gh-pages 34 | git fetch --all 35 | git branch -a 36 | git checkout -b gh-pages origin-pages/gh-pages 37 | 38 | # remove old dir 39 | rm -rf javadoc 40 | 41 | ls ./build 42 | # copy and overwrite new doc 43 | yes | cp -rfv ./build/docs/javadoc/ javadoc/ 44 | 45 | # stage all changed and new files 46 | git add *.html 47 | git add *.css 48 | git add *.js 49 | git add javadoc/package-list 50 | 51 | # commit all 52 | git commit --message "CI build: $CI_BUILD_NUMBER" 53 | 54 | 55 | # push it 56 | git push --quiet --set-upstream origin-pages gh-pages 57 | 58 | # we are done 59 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'rxjava3-extensions' 2 | -------------------------------------------------------------------------------- /src/jmh/java/hu/akarnokd/rxjava3/ExamplePerf.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3; 18 | 19 | import java.util.concurrent.TimeUnit; 20 | 21 | import org.openjdk.jmh.annotations.*; 22 | 23 | /** 24 | * Example benchmark. Run from command line as 25 | *
26 | * gradle jmh -Pjmh='ExamplePerf' 27 | */ 28 | @BenchmarkMode(Mode.Throughput) 29 | @Warmup(iterations = 5) 30 | @Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) 31 | @OutputTimeUnit(TimeUnit.SECONDS) 32 | @Fork(value = 1) 33 | @State(Scope.Thread) 34 | public class ExamplePerf { 35 | 36 | @Param({"1", "10", "100", "1000", "10000", "100000", "1000000"}) 37 | public int count; 38 | 39 | /** 40 | * Insert setup code here. 41 | */ 42 | @Setup 43 | public void setup() { 44 | 45 | } 46 | 47 | } -------------------------------------------------------------------------------- /src/jmh/java/hu/akarnokd/rxjava3/PerfConsumer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3; 18 | 19 | import org.openjdk.jmh.infra.Blackhole; 20 | import org.reactivestreams.*; 21 | 22 | import io.reactivex.rxjava3.core.*; 23 | import io.reactivex.rxjava3.disposables.Disposable; 24 | 25 | public final class PerfConsumer implements Subscriber, Observer, 26 | SingleObserver, MaybeObserver, CompletableObserver { 27 | 28 | final Blackhole bh; 29 | 30 | PerfConsumer(Blackhole bh) { 31 | this.bh = bh; 32 | } 33 | 34 | @Override 35 | public void onSuccess(Object t) { 36 | bh.consume(t); 37 | } 38 | 39 | @Override 40 | public void onSubscribe(Disposable d) { 41 | bh.consume(d); 42 | } 43 | 44 | @Override 45 | public void onSubscribe(Subscription s) { 46 | s.request(Long.MAX_VALUE); 47 | bh.consume(s); 48 | } 49 | 50 | @Override 51 | public void onNext(Object t) { 52 | bh.consume(t); 53 | } 54 | 55 | @Override 56 | public void onError(Throwable t) { 57 | bh.consume(t); 58 | } 59 | 60 | @Override 61 | public void onComplete() { 62 | bh.consume(true); 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/async/AnyValue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.async; 18 | 19 | /** 20 | * Placeholder instance when one has to return something (and used to return {@code null} in 1.x). 21 | */ 22 | public enum AnyValue { 23 | /** An arbitrary object value. */ 24 | INSTANCE; 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/async/DisposableFlowable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.async; 18 | 19 | import io.reactivex.rxjava3.core.Flowable; 20 | import io.reactivex.rxjava3.disposables.Disposable; 21 | 22 | /** 23 | * A {@link Flowable} that also offers a means to dispose it, cancelling/disposing 24 | * some shared underlying computation or resource via {@link Disposable#dispose()}. 25 | * 26 | * @param the value type of the sequence 27 | */ 28 | public abstract class DisposableFlowable extends Flowable implements Disposable { 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/async/DisposableObservable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.async; 18 | 19 | import io.reactivex.rxjava3.core.Observable; 20 | import io.reactivex.rxjava3.disposables.Disposable; 21 | 22 | /** 23 | * A {@link Observable} that also offers a means to dispose it, cancelling/disposing 24 | * some shared underlying computation or resource via {@link Disposable#dispose()}. 25 | * 26 | * @param the value type of the sequence 27 | */ 28 | public abstract class DisposableObservable extends Observable implements Disposable { 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/async/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Utility methods to jumpstart a reactive sequence via 19 | * {@link hu.akarnokd.rxjava3.async.AsyncFlowable AsyncFlowable} 20 | * and {@link hu.akarnokd.rxjava3.async.AsyncObservable AsyncObservable}; 21 | * port of the RxJavaAsyncUtil library. 22 | */ 23 | package hu.akarnokd.rxjava3.async; -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/basetypes/BasicEmptyQueueSubscription.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.basetypes; 18 | 19 | import io.reactivex.rxjava3.operators.QueueSubscription; 20 | 21 | /** 22 | * Base class for empty, async-fuseable intermediate operators. 23 | */ 24 | abstract class BasicEmptyQueueSubscription implements QueueSubscription { 25 | 26 | @Override 27 | public final boolean offer(Void e) { 28 | throw new UnsupportedOperationException("Should not be called!"); 29 | } 30 | 31 | @Override 32 | public final boolean offer(Void v1, Void v2) { 33 | throw new UnsupportedOperationException("Should not be called!"); 34 | } 35 | 36 | @Override 37 | public final void clear() { 38 | // no-op 39 | } 40 | 41 | @Override 42 | public final boolean isEmpty() { 43 | return true; 44 | } 45 | 46 | @Override 47 | public final Void poll() throws Exception { 48 | return null; 49 | } 50 | 51 | @Override 52 | public void request(long n) { 53 | // no-op 54 | } 55 | 56 | @Override 57 | public final int requestFusion(int mode) { 58 | return mode & ASYNC; 59 | } 60 | } -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/basetypes/BasicNonoIntQueueSubscription.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.basetypes; 18 | 19 | import java.util.concurrent.atomic.AtomicInteger; 20 | 21 | import io.reactivex.rxjava3.operators.QueueSubscription; 22 | 23 | /** 24 | * Base class for atomic integer, async-fuseable intermediate operators. 25 | */ 26 | abstract class BasicNonoIntQueueSubscription extends AtomicInteger implements QueueSubscription { 27 | 28 | private static final long serialVersionUID = -4226314340037668732L; 29 | 30 | @Override 31 | public final boolean offer(Void e) { 32 | throw new UnsupportedOperationException("Should not be called!"); 33 | } 34 | 35 | @Override 36 | public final boolean offer(Void v1, Void v2) { 37 | throw new UnsupportedOperationException("Should not be called!"); 38 | } 39 | 40 | @Override 41 | public final void clear() { 42 | // no-op 43 | } 44 | 45 | @Override 46 | public final boolean isEmpty() { 47 | return true; 48 | } 49 | 50 | @Override 51 | public final Void poll() throws Exception { 52 | return null; 53 | } 54 | 55 | @Override 56 | public final void request(long n) { 57 | // no-op 58 | } 59 | 60 | @Override 61 | public final int requestFusion(int mode) { 62 | return mode & ASYNC; 63 | } 64 | } -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/basetypes/BasicNonoSubscriber.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.basetypes; 18 | 19 | import org.reactivestreams.*; 20 | 21 | import io.reactivex.rxjava3.internal.subscriptions.SubscriptionHelper; 22 | 23 | /** 24 | * Basic subscriber that supports queue fusion and defaults onSubscribe, onNext and cancel. 25 | */ 26 | abstract class BasicNonoSubscriber extends BasicEmptyQueueSubscription implements Subscriber { 27 | 28 | protected final Subscriber downstream; 29 | 30 | protected Subscription upstream; 31 | 32 | BasicNonoSubscriber(Subscriber downstream) { 33 | this.downstream = downstream; 34 | } 35 | 36 | @Override 37 | public void onSubscribe(Subscription s) { 38 | if (SubscriptionHelper.validate(this.upstream, s)) { 39 | this.upstream = s; 40 | 41 | downstream.onSubscribe(this); 42 | } 43 | } 44 | 45 | @Override 46 | public final void onNext(Object t) { 47 | // never called 48 | } 49 | 50 | @Override 51 | public void cancel() { 52 | upstream.cancel(); 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/basetypes/BasicSoloQueueSubscription.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.basetypes; 18 | 19 | import io.reactivex.rxjava3.operators.QueueSubscription; 20 | 21 | /** 22 | * Base class that defaults the offer() methods of QueueSubscription. 23 | * 24 | * @param the value type 25 | */ 26 | abstract class BasicSoloQueueSubscription implements QueueSubscription { 27 | 28 | @Override 29 | public final boolean offer(T e) { 30 | throw new UnsupportedOperationException("Should not be called!"); 31 | } 32 | 33 | @Override 34 | public final boolean offer(T v1, T v2) { 35 | throw new UnsupportedOperationException("Should not be called!"); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/basetypes/NonoAmbArray.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.basetypes; 18 | 19 | import org.reactivestreams.Subscriber; 20 | 21 | import hu.akarnokd.rxjava3.basetypes.NonoAmbIterable.AmbSubscriber; 22 | import io.reactivex.rxjava3.exceptions.Exceptions; 23 | 24 | /** 25 | * Terminate as soon as one of the Mono sources terminates. 26 | */ 27 | final class NonoAmbArray extends Nono { 28 | 29 | final Nono[] sources; 30 | 31 | NonoAmbArray(Nono[] sources) { 32 | this.sources = sources; 33 | } 34 | 35 | @Override 36 | protected void subscribeActual(Subscriber s) { 37 | AmbSubscriber parent = new AmbSubscriber(s); 38 | s.onSubscribe(parent); 39 | 40 | try { 41 | for (Nono np : sources) { 42 | if (parent.get() != 0) { 43 | break; 44 | } 45 | np.subscribe(parent); 46 | } 47 | } catch (Throwable ex) { 48 | Exceptions.throwIfFatal(ex); 49 | parent.onError(ex); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/basetypes/NonoComplete.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.basetypes; 18 | 19 | import org.reactivestreams.Subscriber; 20 | 21 | import io.reactivex.rxjava3.functions.Supplier; 22 | import io.reactivex.rxjava3.internal.subscriptions.EmptySubscription; 23 | 24 | /** 25 | * Completes the subscriber immediately. 26 | */ 27 | final class NonoComplete extends Nono implements Supplier { 28 | 29 | static final NonoComplete INSTANCE = new NonoComplete(); 30 | 31 | @Override 32 | protected void subscribeActual(Subscriber s) { 33 | EmptySubscription.complete(s); 34 | } 35 | 36 | @Override 37 | public Void get() throws Exception { 38 | return null; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/basetypes/NonoDefer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.basetypes; 18 | 19 | import java.util.Objects; 20 | 21 | import org.reactivestreams.Subscriber; 22 | 23 | import io.reactivex.rxjava3.exceptions.Exceptions; 24 | import io.reactivex.rxjava3.functions.Supplier; 25 | import io.reactivex.rxjava3.internal.subscriptions.EmptySubscription; 26 | 27 | final class NonoDefer extends Nono { 28 | 29 | final Supplier supplier; 30 | 31 | NonoDefer(Supplier supplier) { 32 | this.supplier = supplier; 33 | } 34 | 35 | @Override 36 | protected void subscribeActual(Subscriber s) { 37 | Nono np; 38 | 39 | try { 40 | np = Objects.requireNonNull(supplier.get(), "The supplier returned a null Nono"); 41 | } catch (Throwable ex) { 42 | Exceptions.throwIfFatal(ex); 43 | EmptySubscription.error(ex, s); 44 | return; 45 | } 46 | 47 | np.subscribe(s); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/basetypes/NonoError.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.basetypes; 18 | 19 | import org.reactivestreams.Subscriber; 20 | 21 | import io.reactivex.rxjava3.functions.Supplier; 22 | import io.reactivex.rxjava3.internal.subscriptions.EmptySubscription; 23 | 24 | /** 25 | * Signals a constant Throwable to the subscriber. 26 | */ 27 | final class NonoError extends Nono implements Supplier { 28 | 29 | final Throwable error; 30 | 31 | NonoError(Throwable error) { 32 | this.error = error; 33 | } 34 | 35 | @Override 36 | protected void subscribeActual(Subscriber s) { 37 | EmptySubscription.error(error, s); 38 | } 39 | 40 | @Override 41 | public Void get() throws Throwable { 42 | throw error; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/basetypes/NonoFromAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.basetypes; 18 | 19 | import org.reactivestreams.Subscriber; 20 | 21 | import io.reactivex.rxjava3.exceptions.Exceptions; 22 | import io.reactivex.rxjava3.functions.*; 23 | import io.reactivex.rxjava3.internal.subscriptions.EmptySubscription; 24 | 25 | /** 26 | * Execute an action and complete the sequence or relay it error. 27 | */ 28 | final class NonoFromAction extends Nono implements Supplier { 29 | 30 | final Action action; 31 | 32 | NonoFromAction(Action action) { 33 | this.action = action; 34 | } 35 | 36 | @Override 37 | protected void subscribeActual(Subscriber s) { 38 | s.onSubscribe(EmptySubscription.INSTANCE); 39 | try { 40 | action.run(); 41 | } catch (Throwable ex) { 42 | Exceptions.throwIfFatal(ex); 43 | s.onError(ex); 44 | return; 45 | } 46 | s.onComplete(); 47 | } 48 | 49 | @Override 50 | public Void get() throws Throwable { 51 | action.run(); 52 | return null; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/basetypes/NonoHide.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.basetypes; 18 | 19 | import org.reactivestreams.Subscriber; 20 | 21 | import hu.akarnokd.rxjava3.basetypes.SoloHide.HideSubscriber; 22 | 23 | /** 24 | * Hides the identity of the upstream and downstream including 25 | * breaking fusion. 26 | */ 27 | final class NonoHide extends Nono { 28 | 29 | final Nono source; 30 | 31 | NonoHide(Nono source) { 32 | this.source = source; 33 | } 34 | 35 | @Override 36 | protected void subscribeActual(Subscriber s) { 37 | source.subscribe(new HideSubscriber(s)); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/basetypes/NonoLift.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.basetypes; 18 | 19 | import java.util.Objects; 20 | 21 | import org.reactivestreams.Subscriber; 22 | 23 | import io.reactivex.rxjava3.exceptions.Exceptions; 24 | import io.reactivex.rxjava3.functions.Function; 25 | import io.reactivex.rxjava3.internal.subscriptions.EmptySubscription; 26 | 27 | /** 28 | * Transform the downstream Subscriber into an upstream Subscriber. 29 | */ 30 | final class NonoLift extends Nono { 31 | 32 | final Nono source; 33 | 34 | final Function, Subscriber> lifter; 35 | 36 | NonoLift(Nono source, Function, Subscriber> lifter) { 37 | this.source = source; 38 | this.lifter = lifter; 39 | } 40 | 41 | @Override 42 | protected void subscribeActual(Subscriber s) { 43 | Subscriber z; 44 | 45 | try { 46 | z = Objects.requireNonNull(lifter.apply(s), "The lifter returned a null Subscriber"); 47 | } catch (Throwable ex) { 48 | Exceptions.throwIfFatal(ex); 49 | EmptySubscription.error(ex, s); 50 | return; 51 | } 52 | 53 | source.subscribe(z); 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/basetypes/NonoNever.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.basetypes; 18 | 19 | import org.reactivestreams.Subscriber; 20 | 21 | import io.reactivex.rxjava3.internal.subscriptions.EmptySubscription; 22 | 23 | /** 24 | * Completes the subscriber immediately. 25 | */ 26 | final class NonoNever extends Nono { 27 | 28 | static final NonoNever INSTANCE = new NonoNever(); 29 | 30 | @Override 31 | protected void subscribeActual(Subscriber s) { 32 | s.onSubscribe(EmptySubscription.INSTANCE); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/basetypes/NonoOnErrorComplete.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.basetypes; 18 | 19 | import org.reactivestreams.Subscriber; 20 | 21 | /** 22 | * If the upstream signals an error, turn it into an onComplete. 23 | */ 24 | final class NonoOnErrorComplete extends Nono { 25 | 26 | final Nono source; 27 | 28 | NonoOnErrorComplete(Nono source) { 29 | this.source = source; 30 | } 31 | 32 | @Override 33 | protected void subscribeActual(Subscriber s) { 34 | source.subscribe(new OnErrorCompleteSubscriber(s)); 35 | } 36 | 37 | static final class OnErrorCompleteSubscriber extends BasicNonoSubscriber { 38 | 39 | OnErrorCompleteSubscriber(Subscriber downstream) { 40 | super(downstream); 41 | } 42 | 43 | @Override 44 | public void onError(Throwable t) { 45 | downstream.onComplete(); 46 | } 47 | 48 | @Override 49 | public void onComplete() { 50 | downstream.onComplete(); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/basetypes/NonoRetry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.basetypes; 18 | 19 | import org.reactivestreams.Subscriber; 20 | 21 | import hu.akarnokd.rxjava3.basetypes.NonoRepeat.RedoSubscriber; 22 | 23 | /** 24 | * Repeatedly re-subscribe to the source Nono if it fails. 25 | */ 26 | final class NonoRetry extends Nono { 27 | 28 | final Nono source; 29 | 30 | final long times; 31 | 32 | NonoRetry(Nono source, long times) { 33 | this.source = source; 34 | this.times = times; 35 | } 36 | 37 | @Override 38 | protected void subscribeActual(Subscriber s) { 39 | source.subscribe(new RetrySubscriber(s, times, source)); 40 | } 41 | 42 | static final class RetrySubscriber extends RedoSubscriber { 43 | 44 | private static final long serialVersionUID = 3432411068139897716L; 45 | 46 | RetrySubscriber(Subscriber downstream, long times, Nono source) { 47 | super(downstream, times, source); 48 | } 49 | 50 | @Override 51 | public void onError(Throwable t) { 52 | active = false; 53 | subscribeNext(t); 54 | } 55 | 56 | @Override 57 | public void onComplete() { 58 | downstream.onComplete(); 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/basetypes/PerhapsAmbIterable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.basetypes; 18 | 19 | import java.util.Objects; 20 | 21 | import org.reactivestreams.Subscriber; 22 | 23 | import hu.akarnokd.rxjava3.basetypes.SoloAmbArray.AmbSubscriber; 24 | import io.reactivex.rxjava3.exceptions.Exceptions; 25 | 26 | /** 27 | * Signal the events of the first source that signals. 28 | * 29 | * @param the value type 30 | */ 31 | final class PerhapsAmbIterable extends Perhaps { 32 | 33 | final Iterable> sources; 34 | 35 | PerhapsAmbIterable(Iterable> sources) { 36 | this.sources = sources; 37 | } 38 | 39 | @Override 40 | protected void subscribeActual(Subscriber s) { 41 | AmbSubscriber parent = new AmbSubscriber<>(s); 42 | s.onSubscribe(parent); 43 | 44 | try { 45 | for (Perhaps source : sources) { 46 | Objects.requireNonNull(source, "One of the sources is null") 47 | .subscribe(parent); 48 | } 49 | } catch (Throwable ex) { 50 | Exceptions.throwIfFatal(ex); 51 | parent.onError(ex); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/basetypes/PerhapsDefer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.basetypes; 18 | 19 | import java.util.Objects; 20 | 21 | import org.reactivestreams.Subscriber; 22 | 23 | import io.reactivex.rxjava3.exceptions.Exceptions; 24 | import io.reactivex.rxjava3.functions.Supplier; 25 | import io.reactivex.rxjava3.internal.subscriptions.EmptySubscription; 26 | 27 | /** 28 | * Defers the creation of the actual Perhaps until subscription time. 29 | * 30 | * @param the value type 31 | */ 32 | final class PerhapsDefer extends Perhaps { 33 | 34 | final Supplier> supplier; 35 | 36 | PerhapsDefer(Supplier> supplier) { 37 | this.supplier = supplier; 38 | } 39 | 40 | @Override 41 | protected void subscribeActual(Subscriber s) { 42 | Perhaps sp; 43 | 44 | try { 45 | sp = Objects.requireNonNull(supplier.get(), "The supplier returned a null Solo"); 46 | } catch (Throwable ex) { 47 | Exceptions.throwIfFatal(ex); 48 | EmptySubscription.error(ex, s); 49 | return; 50 | } 51 | 52 | sp.subscribe(s); 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/basetypes/PerhapsDoFinally.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.basetypes; 18 | 19 | import org.reactivestreams.Subscriber; 20 | 21 | import hu.akarnokd.rxjava3.basetypes.SoloDoFinally.DoFinallySubscriber; 22 | import io.reactivex.rxjava3.functions.Action; 23 | 24 | /** 25 | * Execute an action exactly once after the upstream terminates or the 26 | * downstream cancels. 27 | * @param the input and output element type 28 | */ 29 | final class PerhapsDoFinally extends Perhaps { 30 | 31 | final Perhaps source; 32 | 33 | final Action onFinally; 34 | 35 | PerhapsDoFinally(Perhaps source, Action onFinally) { 36 | this.source = source; 37 | this.onFinally = onFinally; 38 | } 39 | 40 | @Override 41 | protected void subscribeActual(Subscriber s) { 42 | source.subscribe(new DoFinallySubscriber(s, onFinally)); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/basetypes/PerhapsEmpty.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.basetypes; 18 | 19 | import org.reactivestreams.Subscriber; 20 | 21 | import io.reactivex.rxjava3.functions.Supplier; 22 | import io.reactivex.rxjava3.internal.subscriptions.EmptySubscription; 23 | 24 | /** 25 | * Completes the subscriber immediately. 26 | */ 27 | final class PerhapsEmpty extends Perhaps implements Supplier { 28 | 29 | static final PerhapsEmpty INSTANCE = new PerhapsEmpty(); 30 | 31 | @SuppressWarnings("unchecked") 32 | static Perhaps instance() { 33 | return (Perhaps)INSTANCE; 34 | } 35 | 36 | @Override 37 | protected void subscribeActual(Subscriber s) { 38 | EmptySubscription.complete(s); 39 | } 40 | 41 | @Override 42 | public Object get() throws Exception { 43 | return null; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/basetypes/PerhapsError.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.basetypes; 18 | 19 | import org.reactivestreams.Subscriber; 20 | 21 | import io.reactivex.rxjava3.functions.Supplier; 22 | import io.reactivex.rxjava3.internal.subscriptions.EmptySubscription; 23 | 24 | /** 25 | * Signals a Throwable. 26 | * 27 | * @param the value type 28 | */ 29 | final class PerhapsError extends Perhaps implements Supplier { 30 | 31 | final Throwable error; 32 | 33 | PerhapsError(Throwable error) { 34 | this.error = error; 35 | } 36 | 37 | @Override 38 | protected void subscribeActual(Subscriber s) { 39 | EmptySubscription.error(error, s); 40 | } 41 | 42 | @Override 43 | public T get() throws Throwable { 44 | throw error; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/basetypes/PerhapsErrorSupplier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.basetypes; 18 | 19 | import java.util.Objects; 20 | 21 | import org.reactivestreams.Subscriber; 22 | 23 | import io.reactivex.rxjava3.exceptions.Exceptions; 24 | import io.reactivex.rxjava3.functions.Supplier; 25 | import io.reactivex.rxjava3.internal.subscriptions.EmptySubscription; 26 | 27 | /** 28 | * Signals a Throwable returned by a Supplier. 29 | * 30 | * @param the value type 31 | */ 32 | final class PerhapsErrorSupplier extends Perhaps implements Supplier { 33 | 34 | final Supplier errorSupplier; 35 | 36 | PerhapsErrorSupplier(Supplier errorSupplier) { 37 | this.errorSupplier = errorSupplier; 38 | } 39 | 40 | @Override 41 | protected void subscribeActual(Subscriber s) { 42 | Throwable ex; 43 | 44 | try { 45 | ex = Objects.requireNonNull(errorSupplier.get(), "The errorSupplier returned a null Throwable"); 46 | } catch (Throwable exc) { 47 | Exceptions.throwIfFatal(exc); 48 | ex = exc; 49 | } 50 | 51 | EmptySubscription.error(ex, s); 52 | } 53 | 54 | @Override 55 | public T get() throws Throwable { 56 | throw Objects.requireNonNull(errorSupplier.get(), "The errorSupplier returned a null Throwable"); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/basetypes/PerhapsFromAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.basetypes; 18 | 19 | import org.reactivestreams.Subscriber; 20 | 21 | import io.reactivex.rxjava3.exceptions.Exceptions; 22 | import io.reactivex.rxjava3.functions.*; 23 | import io.reactivex.rxjava3.internal.subscriptions.EmptySubscription; 24 | 25 | /** 26 | * Executes an Action and terminates. 27 | * 28 | * @param the value type 29 | */ 30 | final class PerhapsFromAction extends Perhaps implements Supplier { 31 | 32 | final Action action; 33 | 34 | PerhapsFromAction(Action action) { 35 | this.action = action; 36 | } 37 | 38 | @Override 39 | protected void subscribeActual(Subscriber s) { 40 | s.onSubscribe(EmptySubscription.INSTANCE); 41 | 42 | try { 43 | get(); 44 | } catch (Throwable ex) { 45 | Exceptions.throwIfFatal(ex); 46 | s.onError(ex); 47 | return; 48 | } 49 | 50 | s.onComplete(); 51 | } 52 | 53 | @Override 54 | public T get() throws Throwable { 55 | action.run(); 56 | return null; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/basetypes/PerhapsFromSingle.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.basetypes; 18 | 19 | import org.reactivestreams.Subscriber; 20 | 21 | import hu.akarnokd.rxjava3.basetypes.SoloFromSingle.FromSingleObserver; 22 | import io.reactivex.rxjava3.core.SingleSource; 23 | 24 | /** 25 | * Wrap a Single into a Perhaps. 26 | * 27 | * @param the value type 28 | */ 29 | final class PerhapsFromSingle extends Perhaps { 30 | 31 | final SingleSource source; 32 | 33 | PerhapsFromSingle(SingleSource source) { 34 | this.source = source; 35 | } 36 | 37 | @Override 38 | protected void subscribeActual(Subscriber s) { 39 | source.subscribe(new FromSingleObserver(s)); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/basetypes/PerhapsHide.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.basetypes; 18 | 19 | import org.reactivestreams.Subscriber; 20 | 21 | import hu.akarnokd.rxjava3.basetypes.SoloHide.HideSubscriber; 22 | 23 | /** 24 | * Hides the identity of the upstream Solo and its Subscription. 25 | * 26 | * @param the value type 27 | */ 28 | final class PerhapsHide extends Perhaps { 29 | 30 | final Perhaps source; 31 | 32 | PerhapsHide(Perhaps source) { 33 | this.source = source; 34 | } 35 | 36 | @Override 37 | protected void subscribeActual(Subscriber s) { 38 | source.subscribe(new HideSubscriber(s)); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/basetypes/PerhapsJust.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.basetypes; 18 | 19 | import org.reactivestreams.Subscriber; 20 | 21 | import io.reactivex.rxjava3.operators.ScalarSupplier; 22 | import io.reactivex.rxjava3.internal.subscriptions.ScalarSubscription; 23 | 24 | /** 25 | * Signals exactly one value. 26 | * 27 | * @param the value type 28 | */ 29 | final class PerhapsJust extends Perhaps implements ScalarSupplier { 30 | 31 | final T value; 32 | 33 | PerhapsJust(T value) { 34 | this.value = value; 35 | } 36 | 37 | @Override 38 | protected void subscribeActual(Subscriber s) { 39 | s.onSubscribe(new ScalarSubscription<>(s, value)); 40 | } 41 | 42 | @Override 43 | public T get() { 44 | return value; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/basetypes/PerhapsLift.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.basetypes; 18 | 19 | import java.util.Objects; 20 | 21 | import org.reactivestreams.Subscriber; 22 | 23 | import io.reactivex.rxjava3.exceptions.Exceptions; 24 | import io.reactivex.rxjava3.functions.Function; 25 | import io.reactivex.rxjava3.internal.subscriptions.EmptySubscription; 26 | 27 | /** 28 | * Map the downstream Subscriber into an upstream Subscriber. 29 | * 30 | * @param the upstream value type 31 | * @param the downstream value type 32 | */ 33 | final class PerhapsLift extends Perhaps { 34 | 35 | final Perhaps source; 36 | 37 | final Function, Subscriber> onLift; 38 | 39 | PerhapsLift(Perhaps source, Function, Subscriber> onLift) { 40 | this.source = source; 41 | this.onLift = onLift; 42 | } 43 | 44 | @Override 45 | protected void subscribeActual(Subscriber s) { 46 | Subscriber parent; 47 | 48 | try { 49 | parent = Objects.requireNonNull(onLift.apply(s), "The onLift returned a null Subscriber"); 50 | } catch (Throwable ex) { 51 | Exceptions.throwIfFatal(ex); 52 | EmptySubscription.error(ex, s); 53 | return; 54 | } 55 | 56 | source.subscribe(parent); 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/basetypes/PerhapsMap.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.basetypes; 18 | 19 | import org.reactivestreams.Subscriber; 20 | 21 | import hu.akarnokd.rxjava3.basetypes.SoloMap.MapSubscriber; 22 | import io.reactivex.rxjava3.functions.Function; 23 | 24 | /** 25 | * Map the value of upstream via a function. 26 | * 27 | * @param the source value type 28 | * @param the result value type 29 | */ 30 | final class PerhapsMap extends Perhaps { 31 | 32 | final Perhaps source; 33 | 34 | final Function mapper; 35 | 36 | PerhapsMap(Perhaps source, Function mapper) { 37 | this.source = source; 38 | this.mapper = mapper; 39 | } 40 | 41 | @Override 42 | protected void subscribeActual(Subscriber s) { 43 | source.subscribe(new MapSubscriber(s, mapper)); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/basetypes/PerhapsMapError.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.basetypes; 18 | 19 | import org.reactivestreams.Subscriber; 20 | 21 | import hu.akarnokd.rxjava3.basetypes.SoloMapError.MapErrorSubscriber; 22 | import io.reactivex.rxjava3.functions.Function; 23 | 24 | /** 25 | * Map the error of upstream to another Throwable. 26 | * 27 | * @param the source value type 28 | */ 29 | final class PerhapsMapError extends Perhaps { 30 | 31 | final Perhaps source; 32 | 33 | final Function errorMapper; 34 | 35 | PerhapsMapError(Perhaps source, Function errorMapper) { 36 | this.source = source; 37 | this.errorMapper = errorMapper; 38 | } 39 | 40 | @Override 41 | protected void subscribeActual(Subscriber s) { 42 | source.subscribe(new MapErrorSubscriber(s, errorMapper)); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/basetypes/PerhapsNever.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.basetypes; 18 | 19 | import org.reactivestreams.Subscriber; 20 | 21 | import io.reactivex.rxjava3.internal.subscriptions.EmptySubscription; 22 | 23 | /** 24 | * Never signals an event other than onSubscribe. 25 | */ 26 | final class PerhapsNever extends Perhaps { 27 | 28 | static final PerhapsNever INSTANCE = new PerhapsNever(); 29 | 30 | @SuppressWarnings("unchecked") 31 | static Perhaps instance() { 32 | return (Perhaps)INSTANCE; 33 | } 34 | 35 | @Override 36 | protected void subscribeActual(Subscriber s) { 37 | s.onSubscribe(EmptySubscription.INSTANCE); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/basetypes/PerhapsObserveOn.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.basetypes; 18 | 19 | import org.reactivestreams.Subscriber; 20 | 21 | import hu.akarnokd.rxjava3.basetypes.SoloObserveOn.ObserveOnSubscriber; 22 | import io.reactivex.rxjava3.core.Scheduler; 23 | 24 | /** 25 | * Delivers the upstream's onNext, onError and onComplete on the specified 26 | * scheduler. 27 | * 28 | * @param the value type 29 | */ 30 | final class PerhapsObserveOn extends Perhaps { 31 | 32 | final Perhaps source; 33 | 34 | final Scheduler scheduler; 35 | 36 | PerhapsObserveOn(Perhaps source, Scheduler scheduler) { 37 | this.source = source; 38 | this.scheduler = scheduler; 39 | } 40 | 41 | @Override 42 | protected void subscribeActual(Subscriber s) { 43 | source.subscribe(new ObserveOnSubscriber(s, scheduler.createWorker())); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/basetypes/PerhapsSubscribeOn.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.basetypes; 18 | 19 | import org.reactivestreams.Subscriber; 20 | 21 | import hu.akarnokd.rxjava3.basetypes.SoloSubscribeOn.SubscribeOnSubscriber; 22 | import io.reactivex.rxjava3.core.Scheduler; 23 | import io.reactivex.rxjava3.core.Scheduler.Worker; 24 | import io.reactivex.rxjava3.internal.disposables.DisposableHelper; 25 | 26 | /** 27 | * Subscribe to the upstream on the specified scheduler. 28 | * 29 | * @param the value type 30 | */ 31 | final class PerhapsSubscribeOn extends Perhaps { 32 | 33 | final Perhaps source; 34 | 35 | final Scheduler scheduler; 36 | 37 | PerhapsSubscribeOn(Perhaps source, Scheduler scheduler) { 38 | this.source = source; 39 | this.scheduler = scheduler; 40 | } 41 | 42 | @Override 43 | protected void subscribeActual(Subscriber s) { 44 | Worker worker = scheduler.createWorker(); 45 | 46 | SubscribeOnSubscriber parent = new SubscribeOnSubscriber<>(s, worker, source); 47 | s.onSubscribe(parent); 48 | 49 | DisposableHelper.replace(parent.task, worker.schedule(parent)); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/basetypes/PerhapsTimer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.basetypes; 18 | 19 | import java.util.concurrent.TimeUnit; 20 | 21 | import org.reactivestreams.Subscriber; 22 | 23 | import hu.akarnokd.rxjava3.basetypes.SoloTimer.TimerSubscriber; 24 | import io.reactivex.rxjava3.core.Scheduler; 25 | import io.reactivex.rxjava3.disposables.Disposable; 26 | import io.reactivex.rxjava3.internal.disposables.DisposableHelper; 27 | 28 | /** 29 | * Signal a 0L after the specified time delay. 30 | */ 31 | final class PerhapsTimer extends Perhaps { 32 | 33 | final long delay; 34 | 35 | final TimeUnit unit; 36 | 37 | final Scheduler scheduler; 38 | 39 | PerhapsTimer(long delay, TimeUnit unit, Scheduler scheduler) { 40 | this.delay = delay; 41 | this.unit = unit; 42 | this.scheduler = scheduler; 43 | } 44 | 45 | @Override 46 | protected void subscribeActual(Subscriber s) { 47 | TimerSubscriber parent = new TimerSubscriber(s); 48 | s.onSubscribe(parent); 49 | 50 | Disposable d = scheduler.scheduleDirect(parent, delay, unit); 51 | DisposableHelper.replace(parent.task, d); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/basetypes/PerhapsUnsubscribeOn.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.basetypes; 18 | 19 | import org.reactivestreams.Subscriber; 20 | 21 | import hu.akarnokd.rxjava3.basetypes.SoloUnsubscribeOn.UnsubscribeOnSubscriber; 22 | import io.reactivex.rxjava3.core.Scheduler; 23 | 24 | /** 25 | * Call cancel from downstream on the specified Scheduler. 26 | * 27 | * @param the value type 28 | */ 29 | final class PerhapsUnsubscribeOn extends Perhaps { 30 | 31 | final Perhaps source; 32 | 33 | final Scheduler scheduler; 34 | 35 | PerhapsUnsubscribeOn(Perhaps source, Scheduler scheduler) { 36 | this.source = source; 37 | this.scheduler = scheduler; 38 | } 39 | 40 | @Override 41 | protected void subscribeActual(Subscriber s) { 42 | source.subscribe(new UnsubscribeOnSubscriber(s, scheduler)); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/basetypes/SoloAmbIterable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.basetypes; 18 | 19 | import java.util.Objects; 20 | 21 | import org.reactivestreams.Subscriber; 22 | 23 | import hu.akarnokd.rxjava3.basetypes.SoloAmbArray.AmbSubscriber; 24 | import io.reactivex.rxjava3.exceptions.Exceptions; 25 | 26 | /** 27 | * Signal the events of the first source that signals. 28 | * 29 | * @param the value type 30 | */ 31 | final class SoloAmbIterable extends Solo { 32 | 33 | final Iterable> sources; 34 | 35 | SoloAmbIterable(Iterable> sources) { 36 | this.sources = sources; 37 | } 38 | 39 | @Override 40 | protected void subscribeActual(Subscriber s) { 41 | AmbSubscriber parent = new AmbSubscriber<>(s); 42 | s.onSubscribe(parent); 43 | 44 | try { 45 | for (Solo source : sources) { 46 | Objects.requireNonNull(source, "One of the sources is null") 47 | .subscribe(parent); 48 | } 49 | } catch (Throwable ex) { 50 | Exceptions.throwIfFatal(ex); 51 | parent.onError(ex); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/basetypes/SoloDefer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.basetypes; 18 | 19 | import java.util.Objects; 20 | 21 | import org.reactivestreams.Subscriber; 22 | 23 | import io.reactivex.rxjava3.exceptions.Exceptions; 24 | import io.reactivex.rxjava3.functions.Supplier; 25 | import io.reactivex.rxjava3.internal.subscriptions.EmptySubscription; 26 | 27 | /** 28 | * Defers the creation of the actual Solo until subscription time. 29 | * 30 | * @param the value type 31 | */ 32 | final class SoloDefer extends Solo { 33 | 34 | final Supplier> supplier; 35 | 36 | SoloDefer(Supplier> supplier) { 37 | this.supplier = supplier; 38 | } 39 | 40 | @Override 41 | protected void subscribeActual(Subscriber s) { 42 | Solo sp; 43 | 44 | try { 45 | sp = Objects.requireNonNull(supplier.get(), "The supplier returned a null Solo"); 46 | } catch (Throwable ex) { 47 | Exceptions.throwIfFatal(ex); 48 | EmptySubscription.error(ex, s); 49 | return; 50 | } 51 | 52 | sp.subscribe(s); 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/basetypes/SoloError.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.basetypes; 18 | 19 | import org.reactivestreams.Subscriber; 20 | 21 | import io.reactivex.rxjava3.functions.Supplier; 22 | import io.reactivex.rxjava3.internal.subscriptions.EmptySubscription; 23 | 24 | /** 25 | * Signals a Throwable. 26 | * 27 | * @param the value type 28 | */ 29 | final class SoloError extends Solo implements Supplier { 30 | 31 | final Throwable error; 32 | 33 | SoloError(Throwable error) { 34 | this.error = error; 35 | } 36 | 37 | @Override 38 | protected void subscribeActual(Subscriber s) { 39 | EmptySubscription.error(error, s); 40 | } 41 | 42 | @Override 43 | public T get() throws Throwable { 44 | throw error; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/basetypes/SoloErrorSupplier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.basetypes; 18 | 19 | import java.util.Objects; 20 | 21 | import org.reactivestreams.Subscriber; 22 | 23 | import io.reactivex.rxjava3.exceptions.Exceptions; 24 | import io.reactivex.rxjava3.functions.Supplier; 25 | import io.reactivex.rxjava3.internal.subscriptions.EmptySubscription; 26 | 27 | /** 28 | * Signals a Throwable returned by a supplier. 29 | * 30 | * @param the value type 31 | */ 32 | final class SoloErrorSupplier extends Solo implements Supplier { 33 | 34 | final Supplier errorSupplier; 35 | 36 | SoloErrorSupplier(Supplier errorSupplier) { 37 | this.errorSupplier = errorSupplier; 38 | } 39 | 40 | @Override 41 | protected void subscribeActual(Subscriber s) { 42 | Throwable ex; 43 | 44 | try { 45 | ex = Objects.requireNonNull(errorSupplier.get(), "The errorSupplier returned a null Throwable"); 46 | } catch (Throwable exc) { 47 | Exceptions.throwIfFatal(exc); 48 | ex = exc; 49 | } 50 | 51 | EmptySubscription.error(ex, s); 52 | } 53 | 54 | @Override 55 | public T get() throws Throwable { 56 | throw Objects.requireNonNull(errorSupplier.get(), "The errorSupplier returned a null Throwable"); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/basetypes/SoloJust.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.basetypes; 18 | 19 | import org.reactivestreams.Subscriber; 20 | 21 | import io.reactivex.rxjava3.operators.ScalarSupplier; 22 | import io.reactivex.rxjava3.internal.subscriptions.ScalarSubscription; 23 | 24 | /** 25 | * Signals exactly one value. 26 | * 27 | * @param the value type 28 | */ 29 | final class SoloJust extends Solo implements ScalarSupplier { 30 | 31 | final T value; 32 | 33 | SoloJust(T value) { 34 | this.value = value; 35 | } 36 | 37 | @Override 38 | protected void subscribeActual(Subscriber s) { 39 | s.onSubscribe(new ScalarSubscription<>(s, value)); 40 | } 41 | 42 | @Override 43 | public T get() { 44 | return value; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/basetypes/SoloLift.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.basetypes; 18 | 19 | import java.util.Objects; 20 | 21 | import org.reactivestreams.Subscriber; 22 | 23 | import io.reactivex.rxjava3.exceptions.Exceptions; 24 | import io.reactivex.rxjava3.functions.Function; 25 | import io.reactivex.rxjava3.internal.subscriptions.EmptySubscription; 26 | 27 | /** 28 | * Map the downstream Subscriber into an upstream Subscriber. 29 | * 30 | * @param the upstream value type 31 | * @param the downstream value type 32 | */ 33 | final class SoloLift extends Solo { 34 | 35 | final Solo source; 36 | 37 | final Function, Subscriber> onLift; 38 | 39 | SoloLift(Solo source, Function, Subscriber> onLift) { 40 | this.source = source; 41 | this.onLift = onLift; 42 | } 43 | 44 | @Override 45 | protected void subscribeActual(Subscriber s) { 46 | Subscriber parent; 47 | 48 | try { 49 | parent = Objects.requireNonNull(onLift.apply(s), "The onLift returned a null Subscriber"); 50 | } catch (Throwable ex) { 51 | Exceptions.throwIfFatal(ex); 52 | EmptySubscription.error(ex, s); 53 | return; 54 | } 55 | 56 | source.subscribe(parent); 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/basetypes/SoloNever.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.basetypes; 18 | 19 | import org.reactivestreams.Subscriber; 20 | 21 | import io.reactivex.rxjava3.internal.subscriptions.EmptySubscription; 22 | 23 | /** 24 | * Never signals an event other than onSubscribe. 25 | */ 26 | final class SoloNever extends Solo { 27 | 28 | static final SoloNever INSTANCE = new SoloNever(); 29 | 30 | @SuppressWarnings("unchecked") 31 | static Solo instance() { 32 | return (Solo)INSTANCE; 33 | } 34 | 35 | @Override 36 | protected void subscribeActual(Subscriber s) { 37 | s.onSubscribe(EmptySubscription.INSTANCE); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/basetypes/SoloToFlowable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.basetypes; 18 | 19 | import org.reactivestreams.Subscriber; 20 | 21 | import io.reactivex.rxjava3.core.Flowable; 22 | 23 | /** 24 | * Converts a Solo into a Flowable. 25 | * 26 | * @param the value type 27 | */ 28 | final class SoloToFlowable extends Flowable { 29 | 30 | final Solo source; 31 | 32 | SoloToFlowable(Solo source) { 33 | this.source = source; 34 | } 35 | 36 | @Override 37 | protected void subscribeActual(Subscriber s) { 38 | source.subscribe(s); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/basetypes/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Proof-of-concept backpressure enabled 0..1 element reactive types: 19 | * {@link hu.akarnokd.rxjava3.basetypes.Solo Solo}, {@link hu.akarnokd.rxjava3.basetypes.Perhaps Perhaps} 20 | * and {@link hu.akarnokd.rxjava3.basetypes.Nono Nono}. 21 | */ 22 | package hu.akarnokd.rxjava3.basetypes; -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/consumers/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Utility methods to create special consumer types, such as auto-release consumers via 19 | * {@link hu.akarnokd.rxjava3.consumers.FlowableConsumers FlowableConsumers}, 20 | * {@link hu.akarnokd.rxjava3.consumers.ObservableConsumers ObservableConsumers}, 21 | * {@link hu.akarnokd.rxjava3.consumers.MaybeConsumers MaybeConsumers}, 22 | * {@link hu.akarnokd.rxjava3.consumers.SingleConsumers SingleConsumers} and 23 | * {@link hu.akarnokd.rxjava3.consumers.CompletableConsumers CompletableConsumers}. 24 | */ 25 | package hu.akarnokd.rxjava3.consumers; -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/debug/CompletableOnAssemblyScalarSupplier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.debug; 18 | 19 | import hu.akarnokd.rxjava3.debug.CompletableOnAssembly.OnAssemblyCompletableObserver; 20 | import io.reactivex.rxjava3.core.*; 21 | import io.reactivex.rxjava3.operators.ScalarSupplier; 22 | 23 | /** 24 | * Wraps a CompletableSource and inject the assembly info. 25 | */ 26 | final class CompletableOnAssemblyScalarSupplier extends Completable implements ScalarSupplier { 27 | 28 | final CompletableSource source; 29 | 30 | final RxJavaAssemblyException assembled; 31 | 32 | CompletableOnAssemblyScalarSupplier(CompletableSource source) { 33 | this.source = source; 34 | this.assembled = new RxJavaAssemblyException(); 35 | } 36 | 37 | @Override 38 | protected void subscribeActual(CompletableObserver observer) { 39 | source.subscribe(new OnAssemblyCompletableObserver(observer, assembled)); 40 | } 41 | 42 | @SuppressWarnings("unchecked") 43 | @Override 44 | public Object get() { 45 | return ((ScalarSupplier)source).get(); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/debug/CompletableOnAssemblySupplier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.debug; 18 | 19 | import hu.akarnokd.rxjava3.debug.CompletableOnAssembly.OnAssemblyCompletableObserver; 20 | import io.reactivex.rxjava3.core.*; 21 | import io.reactivex.rxjava3.exceptions.Exceptions; 22 | import io.reactivex.rxjava3.functions.Supplier; 23 | 24 | /** 25 | * Wraps a CompletableSource and inject the assembly info. 26 | */ 27 | final class CompletableOnAssemblySupplier extends Completable implements Supplier { 28 | 29 | final CompletableSource source; 30 | 31 | final RxJavaAssemblyException assembled; 32 | 33 | CompletableOnAssemblySupplier(CompletableSource source) { 34 | this.source = source; 35 | this.assembled = new RxJavaAssemblyException(); 36 | } 37 | 38 | @Override 39 | protected void subscribeActual(CompletableObserver observer) { 40 | source.subscribe(new OnAssemblyCompletableObserver(observer, assembled)); 41 | } 42 | 43 | @SuppressWarnings("unchecked") 44 | @Override 45 | public Object get() throws Throwable { 46 | try { 47 | return ((Supplier)source).get(); 48 | } catch (Throwable ex) { 49 | Exceptions.throwIfFatal(ex); 50 | throw assembled.appendLast(ex); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/debug/FlowableOnAssemblyScalarSupplier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.debug; 18 | 19 | import org.reactivestreams.*; 20 | 21 | import hu.akarnokd.rxjava3.debug.FlowableOnAssembly.*; 22 | import io.reactivex.rxjava3.core.Flowable; 23 | import io.reactivex.rxjava3.operators.*; 24 | 25 | /** 26 | * Wraps a Publisher and inject the assembly info. 27 | * 28 | * @param the value type 29 | */ 30 | final class FlowableOnAssemblyScalarSupplier extends Flowable implements ScalarSupplier { 31 | 32 | final Publisher source; 33 | 34 | final RxJavaAssemblyException assembled; 35 | 36 | FlowableOnAssemblyScalarSupplier(Publisher source) { 37 | this.source = source; 38 | this.assembled = new RxJavaAssemblyException(); 39 | } 40 | 41 | @Override 42 | protected void subscribeActual(Subscriber s) { 43 | if (s instanceof ConditionalSubscriber) { 44 | source.subscribe(new OnAssemblyConditionalSubscriber((ConditionalSubscriber)s, assembled)); 45 | } else { 46 | source.subscribe(new OnAssemblySubscriber(s, assembled)); 47 | } 48 | } 49 | 50 | @SuppressWarnings("unchecked") 51 | @Override 52 | public T get() { 53 | return ((ScalarSupplier)source).get(); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/debug/MaybeOnAssemblyScalarSupplier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.debug; 18 | 19 | import hu.akarnokd.rxjava3.debug.MaybeOnAssembly.OnAssemblyMaybeObserver; 20 | import io.reactivex.rxjava3.core.*; 21 | import io.reactivex.rxjava3.operators.ScalarSupplier; 22 | 23 | /** 24 | * Wraps a MaybeSource and inject the assembly info. 25 | * 26 | * @param the value type 27 | */ 28 | final class MaybeOnAssemblyScalarSupplier extends Maybe implements ScalarSupplier { 29 | 30 | final MaybeSource source; 31 | 32 | final RxJavaAssemblyException assembled; 33 | 34 | MaybeOnAssemblyScalarSupplier(MaybeSource source) { 35 | this.source = source; 36 | this.assembled = new RxJavaAssemblyException(); 37 | } 38 | 39 | @Override 40 | protected void subscribeActual(MaybeObserver observer) { 41 | source.subscribe(new OnAssemblyMaybeObserver(observer, assembled)); 42 | } 43 | 44 | @SuppressWarnings("unchecked") 45 | @Override 46 | public T get() { 47 | return ((ScalarSupplier)source).get(); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/debug/MaybeOnAssemblySupplier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.debug; 18 | 19 | import hu.akarnokd.rxjava3.debug.MaybeOnAssembly.OnAssemblyMaybeObserver; 20 | import io.reactivex.rxjava3.core.*; 21 | import io.reactivex.rxjava3.exceptions.Exceptions; 22 | import io.reactivex.rxjava3.functions.Supplier; 23 | 24 | /** 25 | * Wraps a MaybeSource and inject the assembly info. 26 | * 27 | * @param the value type 28 | */ 29 | final class MaybeOnAssemblySupplier extends Maybe implements Supplier { 30 | 31 | final MaybeSource source; 32 | 33 | final RxJavaAssemblyException assembled; 34 | 35 | MaybeOnAssemblySupplier(MaybeSource source) { 36 | this.source = source; 37 | this.assembled = new RxJavaAssemblyException(); 38 | } 39 | 40 | @Override 41 | protected void subscribeActual(MaybeObserver observer) { 42 | source.subscribe(new OnAssemblyMaybeObserver(observer, assembled)); 43 | } 44 | 45 | @SuppressWarnings("unchecked") 46 | @Override 47 | public T get() throws Throwable { 48 | try { 49 | return ((Supplier)source).get(); 50 | } catch (Throwable ex) { 51 | Exceptions.throwIfFatal(ex); 52 | throw (Exception)assembled.appendLast(ex); 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/debug/ObservableOnAssemblyConnectable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.debug; 18 | 19 | import hu.akarnokd.rxjava3.debug.ObservableOnAssembly.OnAssemblyObserver; 20 | import io.reactivex.rxjava3.core.Observer; 21 | import io.reactivex.rxjava3.disposables.Disposable; 22 | import io.reactivex.rxjava3.functions.Consumer; 23 | import io.reactivex.rxjava3.observables.ConnectableObservable; 24 | 25 | /** 26 | * Wraps a ObservableSource and inject the assembly info. 27 | * 28 | * @param the value type 29 | */ 30 | final class ObservableOnAssemblyConnectable extends ConnectableObservable { 31 | 32 | final ConnectableObservable source; 33 | 34 | final RxJavaAssemblyException assembled; 35 | 36 | ObservableOnAssemblyConnectable(ConnectableObservable source) { 37 | this.source = source; 38 | this.assembled = new RxJavaAssemblyException(); 39 | } 40 | 41 | @Override 42 | protected void subscribeActual(Observer observer) { 43 | source.subscribe(new OnAssemblyObserver(observer, assembled)); 44 | } 45 | 46 | @Override 47 | public void connect(Consumer connection) { 48 | source.connect(connection); 49 | } 50 | 51 | @Override 52 | public void reset() { 53 | source.reset(); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/debug/ObservableOnAssemblyScalarSupplier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.debug; 18 | 19 | import hu.akarnokd.rxjava3.debug.ObservableOnAssembly.OnAssemblyObserver; 20 | import io.reactivex.rxjava3.core.*; 21 | import io.reactivex.rxjava3.operators.ScalarSupplier; 22 | 23 | /** 24 | * Wraps a ObservableSource and inject the assembly info. 25 | * 26 | * @param the value type 27 | */ 28 | final class ObservableOnAssemblyScalarSupplier extends Observable implements ScalarSupplier { 29 | 30 | final ObservableSource source; 31 | 32 | final RxJavaAssemblyException assembled; 33 | 34 | ObservableOnAssemblyScalarSupplier(ObservableSource source) { 35 | this.source = source; 36 | this.assembled = new RxJavaAssemblyException(); 37 | } 38 | 39 | @Override 40 | protected void subscribeActual(Observer observer) { 41 | source.subscribe(new OnAssemblyObserver(observer, assembled)); 42 | } 43 | 44 | @SuppressWarnings("unchecked") 45 | @Override 46 | public T get() { 47 | return ((ScalarSupplier)source).get(); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/debug/ObservableOnAssemblySupplier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.debug; 18 | 19 | import hu.akarnokd.rxjava3.debug.ObservableOnAssembly.OnAssemblyObserver; 20 | import io.reactivex.rxjava3.core.*; 21 | import io.reactivex.rxjava3.exceptions.Exceptions; 22 | import io.reactivex.rxjava3.functions.Supplier; 23 | 24 | /** 25 | * Wraps a ObservableSource and inject the assembly info. 26 | * 27 | * @param the value type 28 | */ 29 | final class ObservableOnAssemblySupplier extends Observable implements Supplier { 30 | 31 | final ObservableSource source; 32 | 33 | final RxJavaAssemblyException assembled; 34 | 35 | ObservableOnAssemblySupplier(ObservableSource source) { 36 | this.source = source; 37 | this.assembled = new RxJavaAssemblyException(); 38 | } 39 | 40 | @Override 41 | protected void subscribeActual(Observer observer) { 42 | source.subscribe(new OnAssemblyObserver(observer, assembled)); 43 | } 44 | 45 | @SuppressWarnings("unchecked") 46 | @Override 47 | public T get() throws Throwable { 48 | try { 49 | return ((Supplier)source).get(); 50 | } catch (Throwable ex) { 51 | Exceptions.throwIfFatal(ex); 52 | throw assembled.appendLast(ex); 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/debug/SavedHooks.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.debug; 18 | 19 | /** 20 | * Remembers the previous hooks overridden by the debug 21 | * function and allows restoring them via the {@link #restore()} 22 | * method call. 23 | * @since 0.17.4 24 | */ 25 | public interface SavedHooks { 26 | 27 | /** 28 | * Restore the previous set of hooks. 29 | */ 30 | void restore(); 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/debug/SingleOnAssemblyScalarSupplier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.debug; 18 | 19 | import hu.akarnokd.rxjava3.debug.SingleOnAssembly.OnAssemblySingleObserver; 20 | import io.reactivex.rxjava3.core.*; 21 | import io.reactivex.rxjava3.operators.ScalarSupplier; 22 | 23 | /** 24 | * Wraps a Publisher and inject the assembly info. 25 | * 26 | * @param the value type 27 | */ 28 | final class SingleOnAssemblyScalarSupplier extends Single implements ScalarSupplier { 29 | 30 | final SingleSource source; 31 | 32 | final RxJavaAssemblyException assembled; 33 | 34 | SingleOnAssemblyScalarSupplier(SingleSource source) { 35 | this.source = source; 36 | this.assembled = new RxJavaAssemblyException(); 37 | } 38 | 39 | @Override 40 | protected void subscribeActual(SingleObserver observer) { 41 | source.subscribe(new OnAssemblySingleObserver(observer, assembled)); 42 | } 43 | 44 | @SuppressWarnings("unchecked") 45 | @Override 46 | public T get() { 47 | return ((ScalarSupplier)source).get(); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/debug/SingleOnAssemblySupplier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.debug; 18 | 19 | import hu.akarnokd.rxjava3.debug.SingleOnAssembly.OnAssemblySingleObserver; 20 | import io.reactivex.rxjava3.core.*; 21 | import io.reactivex.rxjava3.exceptions.Exceptions; 22 | import io.reactivex.rxjava3.functions.Supplier; 23 | 24 | /** 25 | * Wraps a Publisher and inject the assembly info. 26 | * 27 | * @param the value type 28 | */ 29 | final class SingleOnAssemblySupplier extends Single implements Supplier { 30 | 31 | final SingleSource source; 32 | 33 | final RxJavaAssemblyException assembled; 34 | 35 | SingleOnAssemblySupplier(SingleSource source) { 36 | this.source = source; 37 | this.assembled = new RxJavaAssemblyException(); 38 | } 39 | 40 | @Override 41 | protected void subscribeActual(SingleObserver observer) { 42 | source.subscribe(new OnAssemblySingleObserver(observer, assembled)); 43 | } 44 | 45 | @SuppressWarnings("unchecked") 46 | @Override 47 | public T get() throws Throwable { 48 | try { 49 | return ((Supplier)source).get(); 50 | } catch (Throwable ex) { 51 | Exceptions.throwIfFatal(ex); 52 | throw assembled.appendLast(ex); 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/debug/multihook/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Proof of concept {@link io.reactivex.rxjava3.plugins.RxJavaPlugins RxJavaPlugins} 19 | * hook implementation for handling multiple hooks to 20 | * the {@code onSchedule} callback via 21 | * {@link hu.akarnokd.rxjava3.debug.multihook.OnScheduleMultiHandlerManager OnScheduleMultiHandlerManager}. 22 | */ 23 | package hu.akarnokd.rxjava3.debug.multihook; -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/debug/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Debugging support to remember where operators have been created in the 19 | * code via {@link io.reactivex.rxjava3.plugins.RxJavaPlugins RxJavaPlugins}' assembly hooks, enabled via 20 | * {@link hu.akarnokd.rxjava3.debug.RxJavaAssemblyTracking RxJavaAssemblyTracking}. 21 | */ 22 | package hu.akarnokd.rxjava3.debug; -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/debug/validator/ConnectableFlowableValidator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.debug.validator; 18 | 19 | import org.reactivestreams.Subscriber; 20 | 21 | import hu.akarnokd.rxjava3.functions.PlainConsumer; 22 | import io.reactivex.rxjava3.disposables.Disposable; 23 | import io.reactivex.rxjava3.flowables.ConnectableFlowable; 24 | import io.reactivex.rxjava3.functions.Consumer; 25 | 26 | /** 27 | * Validates a ConnectableFlowable. 28 | * @param the value type 29 | * @since 0.17.4 30 | */ 31 | final class ConnectableFlowableValidator extends ConnectableFlowable { 32 | 33 | final ConnectableFlowable source; 34 | 35 | final PlainConsumer onViolation; 36 | 37 | ConnectableFlowableValidator(ConnectableFlowable source, PlainConsumer onViolation) { 38 | this.source = source; 39 | this.onViolation = onViolation; 40 | } 41 | 42 | @Override 43 | protected void subscribeActual(Subscriber s) { 44 | source.subscribe(new FlowableValidator.ValidatorConsumer(s, onViolation)); 45 | } 46 | 47 | @Override 48 | public void connect(Consumer connection) { 49 | source.connect(connection); 50 | } 51 | 52 | @Override 53 | public void reset() { 54 | source.reset(); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/debug/validator/ConnectableObservableValidator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.debug.validator; 18 | 19 | import hu.akarnokd.rxjava3.functions.PlainConsumer; 20 | import io.reactivex.rxjava3.core.Observer; 21 | import io.reactivex.rxjava3.disposables.Disposable; 22 | import io.reactivex.rxjava3.functions.Consumer; 23 | import io.reactivex.rxjava3.observables.ConnectableObservable; 24 | 25 | /** 26 | * Validates a ConnectableObservable. 27 | * @param the value type 28 | * @since 0.17.4 29 | */ 30 | final class ConnectableObservableValidator extends ConnectableObservable { 31 | 32 | final ConnectableObservable source; 33 | 34 | final PlainConsumer onViolation; 35 | 36 | ConnectableObservableValidator(ConnectableObservable source, PlainConsumer onViolation) { 37 | this.source = source; 38 | this.onViolation = onViolation; 39 | } 40 | 41 | @Override 42 | protected void subscribeActual(Observer observer) { 43 | source.subscribe(new ObservableValidator.ValidatorConsumer(observer, onViolation)); 44 | } 45 | 46 | @Override 47 | public void connect(Consumer connection) { 48 | source.connect(connection); 49 | } 50 | 51 | @Override 52 | public void reset() { 53 | source.reset(); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/debug/validator/MultipleOnSubscribeCallsException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.debug.validator; 18 | 19 | /** 20 | * Indicates there were multiple {@code onSubscribe} calls. 21 | * @since 0.17.4 22 | */ 23 | public final class MultipleOnSubscribeCallsException extends ProtocolNonConformanceException { 24 | 25 | private static final long serialVersionUID = -6096755460680899745L; 26 | 27 | public MultipleOnSubscribeCallsException() { 28 | super(); 29 | } 30 | 31 | } -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/debug/validator/MultipleTerminationsException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.debug.validator; 18 | 19 | /** 20 | * Indicates there were multiple {@code onError} or {@code onComplete} calls. 21 | * @since 0.17.4 22 | */ 23 | public final class MultipleTerminationsException extends ProtocolNonConformanceException { 24 | 25 | private static final long serialVersionUID = -6096755460680899745L; 26 | 27 | public MultipleTerminationsException() { 28 | super(); 29 | } 30 | 31 | public MultipleTerminationsException(Throwable cause) { 32 | super(cause); 33 | } 34 | 35 | } -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/debug/validator/NullOnErrorParameterException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.debug.validator; 18 | 19 | /** 20 | * Indicates the {@code onError} was called with a {@code null} {@code Throwable}. 21 | * @since 0.17.4 22 | */ 23 | public final class NullOnErrorParameterException extends ProtocolNonConformanceException { 24 | 25 | private static final long serialVersionUID = -6096755460680899745L; 26 | 27 | public NullOnErrorParameterException() { 28 | super(); 29 | } 30 | 31 | } -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/debug/validator/NullOnNextParameterException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.debug.validator; 18 | 19 | /** 20 | * Indicates the {@code onNext} was called with a {@code null} value. 21 | * @since 0.17.4 22 | */ 23 | public final class NullOnNextParameterException extends ProtocolNonConformanceException { 24 | 25 | private static final long serialVersionUID = -6096755460680899745L; 26 | 27 | public NullOnNextParameterException() { 28 | super(); 29 | } 30 | 31 | } -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/debug/validator/NullOnSubscribeParameterException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.debug.validator; 18 | 19 | /** 20 | * Indicates the {@code onSubscribe} was called with a {@code null} {@code Disposable} or {@code Subscription}. 21 | * @since 0.17.4 22 | */ 23 | public final class NullOnSubscribeParameterException extends ProtocolNonConformanceException { 24 | 25 | private static final long serialVersionUID = -6096755460680899745L; 26 | 27 | public NullOnSubscribeParameterException() { 28 | super(); 29 | } 30 | 31 | } -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/debug/validator/NullOnSuccessParameterException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.debug.validator; 18 | 19 | /** 20 | * Indicates the {@code onSuccess} was called with a {@code null} value. 21 | * @since 0.17.4 22 | */ 23 | public final class NullOnSuccessParameterException extends ProtocolNonConformanceException { 24 | 25 | private static final long serialVersionUID = -6096755460680899745L; 26 | 27 | public NullOnSuccessParameterException() { 28 | super(); 29 | } 30 | 31 | } -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/debug/validator/OnNextAfterTerminationException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.debug.validator; 18 | 19 | /** 20 | * The {@code onNext} was invoked after an {@code onError} or {@code onComplete} call. 21 | * @since 0.17.4 22 | */ 23 | public final class OnNextAfterTerminationException extends ProtocolNonConformanceException { 24 | 25 | private static final long serialVersionUID = -6096755460680899745L; 26 | 27 | public OnNextAfterTerminationException() { 28 | super(); 29 | } 30 | 31 | } -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/debug/validator/OnSubscribeNotCalledException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.debug.validator; 18 | 19 | /** 20 | * The {@code onSubscribe} was not called before calling {@code onNext}, 21 | * {@code onSuccess}, {@code onError} or {@code onComplete}. 22 | */ 23 | public final class OnSubscribeNotCalledException extends ProtocolNonConformanceException { 24 | 25 | private static final long serialVersionUID = -6096755460680899745L; 26 | 27 | public OnSubscribeNotCalledException() { 28 | super(); 29 | } 30 | 31 | public OnSubscribeNotCalledException(Throwable cause) { 32 | super(cause); 33 | } 34 | 35 | } -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/debug/validator/OnSuccessAfterTerminationException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.debug.validator; 18 | 19 | /** 20 | * The {@code onSuccess} was invoked after an {@code onError} or {@code onComplete} call. 21 | * @since 0.17.4 22 | */ 23 | public final class OnSuccessAfterTerminationException extends ProtocolNonConformanceException { 24 | 25 | private static final long serialVersionUID = -6096755460680899745L; 26 | 27 | public OnSuccessAfterTerminationException() { 28 | super(); 29 | } 30 | 31 | } -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/debug/validator/ParallelFlowableValidator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.debug.validator; 18 | 19 | import org.reactivestreams.Subscriber; 20 | 21 | import hu.akarnokd.rxjava3.functions.PlainConsumer; 22 | import io.reactivex.rxjava3.parallel.ParallelFlowable; 23 | 24 | /** 25 | * Validates a ParallelFlowable. 26 | * @param the value type 27 | * @since 0.17.4 28 | */ 29 | final class ParallelFlowableValidator extends ParallelFlowable { 30 | 31 | final ParallelFlowable source; 32 | 33 | final PlainConsumer onViolation; 34 | 35 | ParallelFlowableValidator(ParallelFlowable source, PlainConsumer onViolation) { 36 | this.source = source; 37 | this.onViolation = onViolation; 38 | } 39 | 40 | @Override 41 | public void subscribe(Subscriber[] s) { 42 | validate(s); 43 | int n = source.parallelism(); 44 | @SuppressWarnings("unchecked") 45 | Subscriber[] actual = new Subscriber[n]; 46 | for (int i = 0; i < n; i++) { 47 | actual[i] = new FlowableValidator.ValidatorConsumer<>(s[i], onViolation); 48 | } 49 | source.subscribe(actual); 50 | } 51 | 52 | @Override 53 | public int parallelism() { 54 | return source.parallelism(); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/debug/validator/ProtocolNonConformanceException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.debug.validator; 18 | 19 | /** 20 | * Base exception type indicating a failure in conforming the Reactive-Streams 21 | * or derived protocol. 22 | */ 23 | public abstract class ProtocolNonConformanceException extends IllegalStateException { 24 | 25 | private static final long serialVersionUID = -6096755460680899745L; 26 | 27 | public ProtocolNonConformanceException() { 28 | super(); 29 | } 30 | 31 | public ProtocolNonConformanceException(String message, Throwable cause) { 32 | super(message, cause); 33 | } 34 | 35 | public ProtocolNonConformanceException(String s) { 36 | super(s); 37 | } 38 | 39 | public ProtocolNonConformanceException(Throwable cause) { 40 | super(cause); 41 | } 42 | 43 | } -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/debug/validator/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Protocol validation support via {@link io.reactivex.rxjava3.plugins.RxJavaPlugins RxJavaPlugins} 19 | * hook implementations enalbed via 20 | * {@link hu.akarnokd.rxjava3.debug.validator.RxJavaProtocolValidator RxJavaProtocolValidator}. 21 | */ 22 | package hu.akarnokd.rxjava3.debug.validator; -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/expr/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Utility methods for computational expressions and statements via 19 | * {@link hu.akarnokd.rxjava3.expr.StatementFlowable StatementFlowable} 20 | * and {@link hu.akarnokd.rxjava3.expr.StatementObservable StatementObservable}; 21 | * a port of the 22 | * RxJavaComputationExpression 23 | * library. 24 | */ 25 | package hu.akarnokd.rxjava3.expr; -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/functions/Consumer3.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.functions; 18 | 19 | /** 20 | * Functional interface for a callback that consumes multipe values at the same 21 | * and may throw a checked exception. 22 | * 23 | * @param the first value type 24 | * @param the second value type 25 | * @param the third value type 26 | */ 27 | public interface Consumer3 { 28 | 29 | /** 30 | * Consum the input parameters. 31 | * @param t1 the first parameter 32 | * @param t2 the second parameter 33 | * @param t3 the third parameter 34 | * @throws Throwable on error 35 | */ 36 | void accept(T1 t1, T2 t2, T3 t3) throws Throwable; 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/functions/Consumer4.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.functions; 18 | 19 | /** 20 | * Functional interface for a callback that consumes multipe values at the same 21 | * and may throw a checked exception. 22 | * 23 | * @param the first value type 24 | * @param the second value type 25 | * @param the third value type 26 | * @param the fourth value type 27 | */ 28 | public interface Consumer4 { 29 | 30 | /** 31 | * Consum the input parameters. 32 | * @param t1 the first parameter 33 | * @param t2 the second parameter 34 | * @param t3 the third parameter 35 | * @param t4 the fourth parameter 36 | * @throws Throwable on error 37 | */ 38 | void accept(T1 t1, T2 t2, T3 t3, T4 t4) throws Throwable; 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/functions/Consumer5.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.functions; 18 | 19 | /** 20 | * Functional interface for a callback that consumes multipe values at the same 21 | * and may throw a checked exception. 22 | * 23 | * @param the first value type 24 | * @param the second value type 25 | * @param the third value type 26 | * @param the fourth value type 27 | * @param the fifth value type 28 | */ 29 | public interface Consumer5 { 30 | 31 | /** 32 | * Consum the input parameters. 33 | * @param t1 the first parameter 34 | * @param t2 the second parameter 35 | * @param t3 the third parameter 36 | * @param t4 the fourth parameter 37 | * @param t5 the fifth parameter 38 | * @throws Throwable on error 39 | */ 40 | void accept(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5) throws Throwable; 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/functions/Consumer6.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.functions; 18 | 19 | /** 20 | * Functional interface for a callback that consumes multipe values at the same 21 | * and may throw a checked exception. 22 | * 23 | * @param the first value type 24 | * @param the second value type 25 | * @param the third value type 26 | * @param the fourth value type 27 | * @param the fifth value type 28 | * @param the sixth value type 29 | */ 30 | public interface Consumer6 { 31 | 32 | /** 33 | * Consum the input parameters. 34 | * @param t1 the first parameter 35 | * @param t2 the second parameter 36 | * @param t3 the third parameter 37 | * @param t4 the fourth parameter 38 | * @param t5 the fifth parameter 39 | * @param t6 the sixth parameter 40 | * @throws Throwable on error 41 | */ 42 | void accept(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6) throws Throwable; 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/functions/Consumer7.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.functions; 18 | 19 | /** 20 | * Functional interface for a callback that consumes multipe values at the same 21 | * and may throw a checked exception. 22 | * 23 | * @param the first value type 24 | * @param the second value type 25 | * @param the third value type 26 | * @param the fourth value type 27 | * @param the fifth value type 28 | * @param the sixth value type 29 | * @param the seventh value type 30 | */ 31 | public interface Consumer7 { 32 | 33 | /** 34 | * Consum the input parameters. 35 | * @param t1 the first parameter 36 | * @param t2 the second parameter 37 | * @param t3 the third parameter 38 | * @param t4 the fourth parameter 39 | * @param t5 the fifth parameter 40 | * @param t6 the sixth parameter 41 | * @param t7 the seventh parameter 42 | * @throws Throwable on error 43 | */ 44 | void accept(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7) throws Throwable; 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/functions/Consumer8.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.functions; 18 | 19 | /** 20 | * Functional interface for a callback that consumes multipe values at the same 21 | * and may throw a checked exception. 22 | * 23 | * @param the first value type 24 | * @param the second value type 25 | * @param the third value type 26 | * @param the fourth value type 27 | * @param the fifth value type 28 | * @param the sixth value type 29 | * @param the seventh value type 30 | * @param the eighth value type 31 | */ 32 | public interface Consumer8 { 33 | 34 | /** 35 | * Consum the input parameters. 36 | * @param t1 the first parameter 37 | * @param t2 the second parameter 38 | * @param t3 the third parameter 39 | * @param t4 the fourth parameter 40 | * @param t5 the fifth parameter 41 | * @param t6 the sixth parameter 42 | * @param t7 the seventh parameter 43 | * @param t8 the eighth parameter 44 | * @throws Throwable on error 45 | */ 46 | void accept(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8) throws Throwable; 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/functions/Consumer9.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.functions; 18 | 19 | /** 20 | * Functional interface for a callback that consumes multipe values at the same 21 | * and may throw a checked exception. 22 | * 23 | * @param the first value type 24 | * @param the second value type 25 | * @param the third value type 26 | * @param the fourth value type 27 | * @param the fifth value type 28 | * @param the sixth value type 29 | * @param the seventh value type 30 | * @param the eighth value type 31 | * @param the ninth value type 32 | */ 33 | public interface Consumer9 { 34 | 35 | /** 36 | * Consum the input parameters. 37 | * @param t1 the first parameter 38 | * @param t2 the second parameter 39 | * @param t3 the third parameter 40 | * @param t4 the fourth parameter 41 | * @param t5 the fifth parameter 42 | * @param t6 the sixth parameter 43 | * @param t7 the seventh parameter 44 | * @param t8 the eighth parameter 45 | * @param t9 the ninth parameter 46 | * @throws Throwable on error 47 | */ 48 | void accept(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9) throws Throwable; 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/functions/PlainBiConsumer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.functions; 18 | 19 | import io.reactivex.rxjava3.functions.BiConsumer; 20 | 21 | /** 22 | * A {@link BiConsumer} with suppressed exception on its 23 | * {@link #accept(Object, Object)} method. 24 | * 25 | * @param the first argument type 26 | * @param the second argument type 27 | * @since 0.18.0 28 | */ 29 | public interface PlainBiConsumer 30 | extends BiConsumer { 31 | 32 | @Override 33 | void accept(T1 t1, T2 t2); 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/functions/PlainBiFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.functions; 18 | 19 | import io.reactivex.rxjava3.functions.BiFunction; 20 | 21 | /** 22 | * A {@link BiFunction} with suppressed exception on its 23 | * {@link #apply(Object, Object)} method. 24 | * 25 | * @param the first argument type 26 | * @param the second argument type 27 | * @param the output value type 28 | */ 29 | public interface PlainBiFunction 30 | extends BiFunction { 31 | 32 | @Override 33 | R apply(T1 t1, T2 t2); 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/functions/PlainConsumer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.functions; 18 | 19 | import io.reactivex.rxjava3.functions.Consumer; 20 | 21 | /** 22 | * A {@link Consumer} with suppressed exception on its {@link #accept(Object)} method. 23 | * 24 | * @param the input value type 25 | * @since 0.17.4 26 | */ 27 | public interface PlainConsumer extends Consumer { 28 | 29 | @Override 30 | void accept(T t); 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/functions/PlainFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.functions; 18 | 19 | import io.reactivex.rxjava3.functions.Function; 20 | 21 | /** 22 | * A {@link Function} with suppressed exception on its {@link #apply(Object)} method. 23 | * 24 | * @param the input value type 25 | * @param the output value type 26 | */ 27 | public interface PlainFunction extends Function { 28 | 29 | @Override 30 | R apply(T t); 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/functions/PlainFunction3.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.functions; 18 | 19 | import io.reactivex.rxjava3.functions.Function3; 20 | 21 | /** 22 | * A {@link Function3} with suppressed exception on its 23 | * {@link #apply(Object, Object, Object)} method. 24 | * 25 | * @param the first argument type 26 | * @param the second argument type 27 | * @param the third argument type 28 | * @param the output value type 29 | */ 30 | public interface PlainFunction3 31 | extends Function3 { 32 | 33 | @Override 34 | R apply(T1 t1, T2 t2, T3 t3); 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/functions/PlainFunction4.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.functions; 18 | 19 | import io.reactivex.rxjava3.functions.Function4; 20 | 21 | /** 22 | * A {@link Function4} with suppressed exception on its 23 | * {@link #apply(Object, Object, Object, Object)} method. 24 | * 25 | * @param the first argument type 26 | * @param the second argument type 27 | * @param the third argument type 28 | * @param the fourth argument type 29 | * @param the output value type 30 | */ 31 | public interface PlainFunction4 32 | extends Function4 { 33 | 34 | @Override 35 | R apply(T1 t1, T2 t2, T3 t3, T4 t4); 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/functions/PlainFunction5.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.functions; 18 | 19 | import io.reactivex.rxjava3.functions.Function5; 20 | 21 | /** 22 | * A {@link Function5} with suppressed exception on its 23 | * {@link #apply(Object, Object, Object, Object, Object)} method. 24 | * 25 | * @param the first argument type 26 | * @param the second argument type 27 | * @param the third argument type 28 | * @param the fourth argument type 29 | * @param the fifth argument type 30 | * @param the output value type 31 | */ 32 | public interface PlainFunction5 33 | extends Function5 { 34 | 35 | @Override 36 | R apply(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5); 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/functions/PlainFunction6.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.functions; 18 | 19 | import io.reactivex.rxjava3.functions.Function6; 20 | 21 | /** 22 | * A {@link Function6} with suppressed exception on its 23 | * {@link #apply(Object, Object, Object, Object, Object, Object)} method. 24 | * 25 | * @param the first argument type 26 | * @param the second argument type 27 | * @param the third argument type 28 | * @param the fourth argument type 29 | * @param the fifth argument type 30 | * @param the sixth argument type 31 | * @param the output value type 32 | */ 33 | public interface PlainFunction6 34 | extends Function6 { 35 | 36 | @Override 37 | R apply(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6); 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/functions/PlainFunction7.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.functions; 18 | 19 | import io.reactivex.rxjava3.functions.Function7; 20 | 21 | /** 22 | * A {@link Function7} with suppressed exception on its 23 | * {@link #apply(Object, Object, Object, Object, Object, Object, Object)} method. 24 | * 25 | * @param the first argument type 26 | * @param the second argument type 27 | * @param the third argument type 28 | * @param the fourth argument type 29 | * @param the fifth argument type 30 | * @param the sixth argument type 31 | * @param the sevent argument type 32 | * @param the output value type 33 | */ 34 | public interface PlainFunction7 35 | extends Function7 { 36 | 37 | @Override 38 | R apply(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7); 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/functions/PlainFunction8.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.functions; 18 | 19 | import io.reactivex.rxjava3.functions.Function8; 20 | 21 | /** 22 | * A {@link Function8} with suppressed exception on its 23 | * {@link #apply(Object, Object, Object, Object, Object, Object, Object, Object)} method. 24 | * 25 | * @param the first argument type 26 | * @param the second argument type 27 | * @param the third argument type 28 | * @param the fourth argument type 29 | * @param the fifth argument type 30 | * @param the sixth argument type 31 | * @param the sevent argument type 32 | * @param the eighth argument type 33 | * @param the output value type 34 | */ 35 | public interface PlainFunction8 36 | extends Function8 { 37 | 38 | @Override 39 | R apply(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8); 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/functions/PlainFunction9.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.functions; 18 | 19 | import io.reactivex.rxjava3.functions.Function9; 20 | 21 | /** 22 | * A {@link Function9} with suppressed exception on its 23 | * {@link #apply(Object, Object, Object, Object, Object, Object, Object, Object, Object)} method. 24 | * 25 | * @param the first argument type 26 | * @param the second argument type 27 | * @param the third argument type 28 | * @param the fourth argument type 29 | * @param the fifth argument type 30 | * @param the sixth argument type 31 | * @param the sevent argument type 32 | * @param the eighth argument type 33 | * @param the ninth argument type 34 | * @param the output value type 35 | */ 36 | public interface PlainFunction9 37 | extends Function9 { 38 | 39 | @Override 40 | R apply(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9); 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/functions/SimpleCallable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.functions; 18 | 19 | import java.util.concurrent.Callable; 20 | 21 | /** 22 | * A {@link Callable} with suppressed exception on its {@link #call()} method. 23 | * @param the value type 24 | */ 25 | public interface SimpleCallable extends Callable { 26 | 27 | @Override 28 | T call(); 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/functions/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Functional interface definitions for {@link io.reactivex.rxjava3.functions.Consumer Consumer}s with 19 | * 3..9 arguments and {@link io.reactivex.rxjava3.functions.Function Function}s without the 20 | * {@code throws Exception} clause in their definition. 21 | */ 22 | package hu.akarnokd.rxjava3.functions; -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/joins/ActivePlan0.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.joins; 18 | 19 | import java.util.*; 20 | 21 | /** 22 | * Represents an activated plan. 23 | */ 24 | abstract class ActivePlan0 { 25 | protected final Map joinObservers = new HashMap<>(); 26 | 27 | protected abstract void match() throws Throwable; 28 | 29 | protected void addJoinObserver(JoinObserver joinObserver) { 30 | joinObservers.put(joinObserver, joinObserver); 31 | } 32 | 33 | protected void dequeue() { 34 | for (JoinObserver jo : joinObservers.values()) { 35 | jo.dequeue(); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/joins/ActivePlan1.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.joins; 18 | 19 | import io.reactivex.rxjava3.core.Notification; 20 | import io.reactivex.rxjava3.functions.*; 21 | 22 | /** 23 | * Represents an active plan. 24 | * @param the first value type 25 | */ 26 | final class ActivePlan1 extends ActivePlan0 { 27 | private final Consumer onNext; 28 | private final Action onCompleted; 29 | private final JoinObserver1 jo1; 30 | 31 | ActivePlan1(JoinObserver1 jo1, Consumer onNext, Action onCompleted) { 32 | this.onNext = onNext; 33 | this.onCompleted = onCompleted; 34 | this.jo1 = jo1; 35 | addJoinObserver(jo1); 36 | } 37 | 38 | @Override 39 | protected void match() throws Throwable { 40 | if (!jo1.queue().isEmpty()) { 41 | Notification n1 = jo1.queue().peek(); 42 | if (n1.isOnComplete()) { 43 | onCompleted.run(); 44 | } else { 45 | dequeue(); 46 | onNext.accept(n1.getValue()); 47 | } 48 | } 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/joins/JoinObserver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.joins; 18 | 19 | import io.reactivex.rxjava3.disposables.Disposable; 20 | 21 | /** 22 | * Base interface to manage joined observations. 23 | */ 24 | interface JoinObserver extends Disposable { 25 | void subscribe(Object gate); 26 | 27 | void dequeue(); 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/joins/Pattern1.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.joins; 18 | 19 | import io.reactivex.rxjava3.core.Observable; 20 | import io.reactivex.rxjava3.functions.Function; 21 | 22 | /** 23 | * Represents a join pattern over Observable sequences. 24 | * @param the first value type 25 | */ 26 | public final class Pattern1 { 27 | private final Observable o1; 28 | 29 | public Pattern1(Observable o1) { 30 | this.o1 = o1; 31 | } 32 | 33 | Observable o1() { 34 | return o1; 35 | } 36 | 37 | /** 38 | * Matches when all observable sequences have an available 39 | * element and projects the elements by invoking the selector function. 40 | * 41 | * @param the result type 42 | * @param selector 43 | * the function that will be invoked for elements in the source sequences. 44 | * @return the plan for the matching 45 | * @throws NullPointerException 46 | * if selector is null 47 | */ 48 | public Plan then(Function selector) { 49 | if (selector == null) { 50 | throw new NullPointerException(); 51 | } 52 | return new Plan1<>(this, selector); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/joins/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Utility methods for join patterns (more generic way than {@code combineLatest}) via 19 | * {@link hu.akarnokd.rxjava3.joins.JoinObservable JoinObservable} wrapper and the {@code and/then/when} 20 | * vocabulary; 21 | * a port of the 22 | * RxJavaJoins 23 | * library. 24 | */ 25 | package hu.akarnokd.rxjava3.joins; -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/math/FlowableSource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.math; 18 | 19 | import org.reactivestreams.Publisher; 20 | 21 | import io.reactivex.rxjava3.core.Flowable; 22 | 23 | abstract class FlowableSource extends Flowable { 24 | 25 | protected final Publisher source; 26 | 27 | FlowableSource(Publisher source) { 28 | this.source = source; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/math/FlowableSumDouble.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.math; 18 | 19 | import org.reactivestreams.*; 20 | 21 | import io.reactivex.rxjava3.internal.subscribers.DeferredScalarSubscriber; 22 | 23 | final class FlowableSumDouble extends FlowableSource { 24 | 25 | FlowableSumDouble(Publisher source) { 26 | super(source); 27 | } 28 | 29 | @Override 30 | protected void subscribeActual(Subscriber subscriber) { 31 | source.subscribe(new SumDoubleSubscriber(subscriber)); 32 | } 33 | 34 | static final class SumDoubleSubscriber extends DeferredScalarSubscriber { 35 | 36 | private static final long serialVersionUID = 600979972678601618L; 37 | 38 | double accumulator; 39 | 40 | SumDoubleSubscriber(Subscriber downstream) { 41 | super(downstream); 42 | } 43 | 44 | @Override 45 | public void onNext(Double value) { 46 | if (!hasValue) { 47 | hasValue = true; 48 | } 49 | accumulator += value.doubleValue(); 50 | } 51 | 52 | @Override 53 | public void onComplete() { 54 | if (hasValue) { 55 | complete(accumulator); 56 | } else { 57 | downstream.onComplete(); 58 | } 59 | } 60 | 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/math/FlowableSumFloat.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.math; 18 | 19 | import org.reactivestreams.*; 20 | 21 | import io.reactivex.rxjava3.internal.subscribers.DeferredScalarSubscriber; 22 | 23 | final class FlowableSumFloat extends FlowableSource { 24 | 25 | FlowableSumFloat(Publisher source) { 26 | super(source); 27 | } 28 | 29 | @Override 30 | protected void subscribeActual(Subscriber subscriber) { 31 | source.subscribe(new SumFloatSubscriber(subscriber)); 32 | } 33 | 34 | static final class SumFloatSubscriber extends DeferredScalarSubscriber { 35 | 36 | private static final long serialVersionUID = 600979972678601618L; 37 | 38 | float accumulator; 39 | 40 | SumFloatSubscriber(Subscriber downstream) { 41 | super(downstream); 42 | } 43 | 44 | @Override 45 | public void onNext(Float value) { 46 | if (!hasValue) { 47 | hasValue = true; 48 | } 49 | accumulator += value.floatValue(); 50 | } 51 | 52 | @Override 53 | public void onComplete() { 54 | if (hasValue) { 55 | complete(accumulator); 56 | } else { 57 | downstream.onComplete(); 58 | } 59 | } 60 | 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/math/FlowableSumInt.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.math; 18 | 19 | import org.reactivestreams.*; 20 | 21 | import io.reactivex.rxjava3.internal.subscribers.DeferredScalarSubscriber; 22 | 23 | final class FlowableSumInt extends FlowableSource { 24 | 25 | FlowableSumInt(Publisher source) { 26 | super(source); 27 | } 28 | 29 | @Override 30 | protected void subscribeActual(Subscriber subscriber) { 31 | source.subscribe(new SumIntSubscriber(subscriber)); 32 | } 33 | 34 | static final class SumIntSubscriber extends DeferredScalarSubscriber { 35 | 36 | private static final long serialVersionUID = 600979972678601618L; 37 | 38 | int accumulator; 39 | 40 | SumIntSubscriber(Subscriber downstream) { 41 | super(downstream); 42 | } 43 | 44 | @Override 45 | public void onNext(Integer value) { 46 | if (!hasValue) { 47 | hasValue = true; 48 | } 49 | accumulator += value.intValue(); 50 | } 51 | 52 | @Override 53 | public void onComplete() { 54 | if (hasValue) { 55 | complete(accumulator); 56 | } else { 57 | downstream.onComplete(); 58 | } 59 | } 60 | 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/math/FlowableSumLong.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.math; 18 | 19 | import org.reactivestreams.*; 20 | 21 | import io.reactivex.rxjava3.internal.subscribers.DeferredScalarSubscriber; 22 | 23 | final class FlowableSumLong extends FlowableSource { 24 | 25 | FlowableSumLong(Publisher source) { 26 | super(source); 27 | } 28 | 29 | @Override 30 | protected void subscribeActual(Subscriber subscriber) { 31 | source.subscribe(new SumLongSubscriber(subscriber)); 32 | } 33 | 34 | static final class SumLongSubscriber extends DeferredScalarSubscriber { 35 | 36 | private static final long serialVersionUID = 600979972678601618L; 37 | 38 | long accumulator; 39 | 40 | SumLongSubscriber(Subscriber downstream) { 41 | super(downstream); 42 | } 43 | 44 | @Override 45 | public void onNext(Long value) { 46 | if (!hasValue) { 47 | hasValue = true; 48 | } 49 | accumulator += value.longValue(); 50 | } 51 | 52 | @Override 53 | public void onComplete() { 54 | if (hasValue) { 55 | complete(accumulator); 56 | } else { 57 | downstream.onComplete(); 58 | } 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/math/ObservableSource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.math; 18 | 19 | import io.reactivex.rxjava3.core.*; 20 | 21 | abstract class ObservableWithSource extends Observable { 22 | 23 | protected final ObservableSource source; 24 | 25 | ObservableWithSource(ObservableSource source) { 26 | this.source = source; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/math/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Utility methods for aggregating and reducing flows with numeric content via 19 | * {@link hu.akarnokd.rxjava3.math.MathFlowable MathFlowable} 20 | * and {@link hu.akarnokd.rxjava3.math.MathObservable MathObservable}; 21 | * a port of the 22 | * RxJavaMath 23 | * library. 24 | */ 25 | package hu.akarnokd.rxjava3.math; -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/operators/BasicEmitter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.operators; 18 | 19 | /** 20 | * Abstraction over a Subscriber. 21 | * 22 | * @param the value type 23 | */ 24 | public interface BasicEmitter { 25 | 26 | void doNext(T t); 27 | 28 | void doError(Throwable t); 29 | 30 | void doComplete(); 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/operators/ExpandStrategy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.operators; 18 | 19 | /** 20 | * Represents the strategies for recursive expansion with the {@code expand()} operator. 21 | * @since 0.16.1 22 | */ 23 | public enum ExpandStrategy { 24 | 25 | /** 26 | * Expands the first item recursively before expanding the second. 27 | */ 28 | DEPTH_FIRST, 29 | /** 30 | * Walk the first level of items, then walk the second level items recursively. 31 | */ 32 | BREADTH_FIRST 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/operators/FlowableCacheLast.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.operators; 18 | 19 | import java.util.concurrent.atomic.AtomicBoolean; 20 | 21 | import org.reactivestreams.*; 22 | 23 | import io.reactivex.rxjava3.core.*; 24 | import io.reactivex.rxjava3.processors.AsyncProcessor; 25 | 26 | /** 27 | * Cache only the very last value and relay/replay it to Subscribers. 28 | * 29 | * @param the value type 30 | * @since 0.15.0 31 | */ 32 | final class FlowableCacheLast extends Flowable 33 | implements FlowableTransformer { 34 | 35 | final Publisher source; 36 | 37 | final AsyncProcessor processor; 38 | 39 | final AtomicBoolean once; 40 | 41 | FlowableCacheLast(Publisher source) { 42 | this.source = source; 43 | this.processor = AsyncProcessor.create(); 44 | this.once = new AtomicBoolean(); 45 | } 46 | 47 | @Override 48 | public Publisher apply(Flowable upstream) { 49 | return new FlowableCacheLast<>(upstream); 50 | } 51 | 52 | @Override 53 | protected void subscribeActual(Subscriber s) { 54 | processor.subscribe(s); 55 | AtomicBoolean o = once; 56 | if (!o.get() && o.compareAndSet(false, true)) { 57 | source.subscribe(processor); 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/operators/Observables.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.operators; 18 | 19 | /** 20 | * Utility class to create Observable sources. 21 | * 22 | * @see ObservableTransformers 23 | * @since 0.18.2 24 | */ 25 | public final class Observables { 26 | 27 | /** 28 | * Utility class. 29 | */ 30 | private Observables() { 31 | throw new IllegalStateException("No instances!"); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/operators/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Utility methods for uncommon, custom, special and exotic operators for RxJava flows 19 | * in the form of transformers and converters. 20 | *
    21 | *
  • {@link hu.akarnokd.rxjava3.operators.FlowableTransformers FlowableTransformers}, 22 | * {@link hu.akarnokd.rxjava3.operators.Flowables Flowables},
  • 23 | *
  • {@link hu.akarnokd.rxjava3.operators.ObservableTransformers ObservableTransformers}, 24 | * {@link hu.akarnokd.rxjava3.operators.Observables Observables},
  • 25 | *
  • {@link hu.akarnokd.rxjava3.operators.MaybeTransformers MaybeTransformers}, 26 | * {@link hu.akarnokd.rxjava3.operators.Maybes Maybes},
  • 27 | *
  • {@link hu.akarnokd.rxjava3.operators.SingleTransformers SingleTransformers}, 28 | * {@link hu.akarnokd.rxjava3.operators.Singles Singles},
  • 29 | *
  • {@link hu.akarnokd.rxjava3.operators.CompletableTransformers CompletableTransformers} and 30 | * {@link hu.akarnokd.rxjava3.operators.Completables Completables}.
  • 31 | *
32 | */ 33 | package hu.akarnokd.rxjava3.operators; -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/parallel/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Utility methods for parallel aggregation and reduction for {@link io.reactivex.rxjava3.parallel.ParallelFlowable ParallelFlowable}s via 19 | * {@link hu.akarnokd.rxjava3.parallel.ParallelTransformers ParallelTransformers}. 20 | */ 21 | package hu.akarnokd.rxjava3.parallel; -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/processors/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Special processors such as 19 | * {@link hu.akarnokd.rxjava3.processors.DispatchWorkProcessor DispatchWorkProcessor} 20 | * and generic utilities for {@link io.reactivex.rxjava3.processors.FlowableProcessor FlowableProcessor}s 21 | * via {@link hu.akarnokd.rxjava3.processors.FlowableProcessors} methods. 22 | */ 23 | package hu.akarnokd.rxjava3.processors; -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/schedulers/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Special scheduler implementations, such as 19 | * {@link hu.akarnokd.rxjava3.schedulers.BlockingScheduler BlockingScheduler}, 20 | * {@link hu.akarnokd.rxjava3.schedulers.ParallelScheduler ParallelScheduler} and 21 | * {@link hu.akarnokd.rxjava3.schedulers.SharedScheduler SharedScheduler}. 22 | */ 23 | package hu.akarnokd.rxjava3.schedulers; -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/string/StringObservable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.string; 18 | 19 | import io.reactivex.rxjava3.core.Observable; 20 | import io.reactivex.rxjava3.plugins.RxJavaPlugins; 21 | 22 | /** 23 | * Utility class for String operations with {@link Observable}s. 24 | */ 25 | public final class StringObservable { 26 | /** Utility class. */ 27 | private StringObservable() { 28 | throw new IllegalStateException("No instances!"); 29 | } 30 | 31 | /** 32 | * Signals each character of the given string CharSequence as Integers. 33 | * @param string the source of characters 34 | * @return the new Observable instance 35 | */ 36 | public static Observable characters(CharSequence string) { 37 | return RxJavaPlugins.onAssembly(new ObservableCharSequence(string)); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/string/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Utility methods working with strings and character sequences via 19 | * {@link hu.akarnokd.rxjava3.string.StringFlowable} and 20 | * {@link hu.akarnokd.rxjava3.string.StringObservable StringObservable}; 21 | * a partial port of the 22 | * RxJavaString 23 | * library. 24 | */ 25 | package hu.akarnokd.rxjava3.string; -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/subjects/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Special subjects such as 19 | * {@link hu.akarnokd.rxjava3.subjects.UnicastWorkSubject UnicastWorkSubject}, 20 | * {@link hu.akarnokd.rxjava3.subjects.DispatchWorkSubject DispatchWorkSubject} 21 | * and generic utilities for {@link io.reactivex.rxjava3.subjects.Subject Subject}s 22 | * via {@link hu.akarnokd.rxjava3.subjects.Subjects} methods. 23 | */ 24 | package hu.akarnokd.rxjava3.subjects; -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/util/AlwaysFalseBooleanSupplier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.util; 18 | 19 | import io.reactivex.rxjava3.functions.BooleanSupplier; 20 | 21 | /** 22 | * A {@link BooleanSupplier} implementation that is always false. 23 | */ 24 | public enum AlwaysFalseBooleanSupplier implements BooleanSupplier { 25 | INSTANCE; 26 | 27 | @Override 28 | public boolean getAsBoolean() throws Exception { 29 | return false; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/util/AlwaysTrueBooleanSupplier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.util; 18 | 19 | import io.reactivex.rxjava3.functions.BooleanSupplier; 20 | 21 | /** 22 | * A {@link BooleanSupplier} implementation that is always true. 23 | */ 24 | public enum AlwaysTrueBooleanSupplier implements BooleanSupplier { 25 | INSTANCE; 26 | 27 | @Override 28 | public boolean getAsBoolean() throws Exception { 29 | return true; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/util/BiFunctionSecondIdentity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.util; 18 | 19 | import io.reactivex.rxjava3.functions.BiFunction; 20 | 21 | /** 22 | * A BiFunction that returns its second parameter; use {@link #instance()} to 23 | * get a correctly typed (shared) instance. 24 | * 25 | * @since 0.16.2 26 | */ 27 | public enum BiFunctionSecondIdentity implements BiFunction { 28 | /** The singleton instance. */ 29 | INSTANCE; 30 | 31 | /** 32 | * Returns a correctly typed instance of the enum's singleton instance. 33 | * @param the first input value type. 34 | * @param the second input and result type 35 | * @return the typed BiFunction (shared) instance. 36 | */ 37 | @SuppressWarnings({ "unchecked", "rawtypes" }) 38 | public static BiFunction instance() { 39 | return (BiFunction)INSTANCE; 40 | } 41 | 42 | @Override 43 | public Object apply(Object t1, Object t2) throws Exception { 44 | return t2; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/util/SelfComparator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.util; 18 | 19 | import java.util.Comparator; 20 | 21 | /** 22 | * Comparator that compares Comparables. 23 | */ 24 | @SuppressWarnings({ "rawtypes", "unchecked" }) 25 | public enum SelfComparator implements Comparator { 26 | INSTANCE; 27 | 28 | public static > Comparator instance() { 29 | return (Comparator)INSTANCE; 30 | } 31 | 32 | @Override 33 | public int compare(Comparable o1, Comparable o2) { 34 | return o1.compareTo(o2); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/util/SneakyThrows.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.util; 18 | 19 | /** 20 | * Utility class to throw arbitrary Throwables. 21 | */ 22 | public final class SneakyThrows { 23 | 24 | private SneakyThrows() { 25 | throw new IllegalStateException("No instances!"); 26 | } 27 | 28 | @SuppressWarnings("unchecked") 29 | public static E justThrowX(Throwable error) throws E { 30 | throw (E)error; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/util/SpscOneQueue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.util; 18 | 19 | import java.util.Objects; 20 | import java.util.concurrent.atomic.AtomicReference; 21 | 22 | import io.reactivex.rxjava3.operators.SimplePlainQueue; 23 | 24 | /** 25 | * A single-producer single-consumer queue with exactly one slot of value. 26 | * 27 | * @param the value type 28 | */ 29 | public final class SpscOneQueue extends AtomicReference 30 | implements SimplePlainQueue { 31 | 32 | private static final long serialVersionUID = -8766520133280966316L; 33 | 34 | @Override 35 | public boolean offer(T value) { 36 | Objects.requireNonNull(value, "value is null"); 37 | if (get() == null) { 38 | lazySet(value); 39 | return true; 40 | } 41 | return false; 42 | } 43 | 44 | @Override 45 | public boolean offer(T v1, T v2) { 46 | throw new UnsupportedOperationException(); 47 | } 48 | 49 | @Override 50 | public boolean isEmpty() { 51 | return get() == null; 52 | } 53 | 54 | @Override 55 | public void clear() { 56 | lazySet(null); 57 | } 58 | 59 | @Override 60 | public T poll() { 61 | T v = get(); 62 | if (v != null) { 63 | lazySet(null); 64 | } 65 | return v; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/main/java/hu/akarnokd/rxjava3/util/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Utility classes and methods supporting the other utilities in this library. 19 | */ 20 | package hu.akarnokd.rxjava3.util; -------------------------------------------------------------------------------- /src/test/java/hu/akarnokd/rxjava3/operators/CompletableTransformersTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.operators; 18 | 19 | import org.junit.Test; 20 | 21 | import hu.akarnokd.rxjava3.test.TestHelper; 22 | 23 | public class CompletableTransformersTest { 24 | 25 | @Test 26 | public void utilityClass() { 27 | TestHelper.checkUtilityClass(CompletableTransformers.class); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/test/java/hu/akarnokd/rxjava3/operators/CompletablesTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.operators; 18 | 19 | import org.junit.Test; 20 | 21 | import hu.akarnokd.rxjava3.test.TestHelper; 22 | 23 | public class CompletablesTest { 24 | 25 | @Test 26 | public void utilityClass() { 27 | TestHelper.checkUtilityClass(Completables.class); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/test/java/hu/akarnokd/rxjava3/operators/FlowableTransformersTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.operators; 18 | 19 | import org.junit.Test; 20 | 21 | import hu.akarnokd.rxjava3.test.TestHelper; 22 | 23 | public class FlowableTransformersTest { 24 | 25 | @Test 26 | public void utilityClass() { 27 | TestHelper.checkUtilityClass(FlowableTransformers.class); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/test/java/hu/akarnokd/rxjava3/operators/ObservableTransformersTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.operators; 18 | 19 | import org.junit.Test; 20 | 21 | import hu.akarnokd.rxjava3.test.TestHelper; 22 | 23 | public class ObservableTransformersTest { 24 | 25 | @Test 26 | public void utilityClass() { 27 | TestHelper.checkUtilityClass(ObservableTransformers.class); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/test/java/hu/akarnokd/rxjava3/operators/ObservablesTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.operators; 18 | 19 | import org.junit.Test; 20 | 21 | import hu.akarnokd.rxjava3.test.TestHelper; 22 | 23 | public class ObservablesTest { 24 | 25 | @Test 26 | public void utilityClass() { 27 | TestHelper.checkUtilityClass(Observables.class); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/test/java/hu/akarnokd/rxjava3/operators/SingleTransformersTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.operators; 18 | 19 | import org.junit.Test; 20 | 21 | import hu.akarnokd.rxjava3.test.TestHelper; 22 | 23 | public class SingleTransformersTest { 24 | 25 | @Test 26 | public void utilityClass() { 27 | TestHelper.checkUtilityClass(SingleTransformers.class); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/test/java/hu/akarnokd/rxjava3/operators/SinglesTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.operators; 18 | 19 | import org.junit.Test; 20 | 21 | import hu.akarnokd.rxjava3.test.TestHelper; 22 | 23 | public class SinglesTest { 24 | 25 | @Test 26 | public void utilityClass() { 27 | TestHelper.checkUtilityClass(Singles.class); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/test/java/hu/akarnokd/rxjava3/parallel/ParallelOrderedMergeTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.parallel; 18 | 19 | import java.util.Random; 20 | 21 | import org.junit.Test; 22 | 23 | import io.reactivex.rxjava3.core.Flowable; 24 | import io.reactivex.rxjava3.functions.Function; 25 | import io.reactivex.rxjava3.schedulers.Schedulers; 26 | 27 | public class ParallelOrderedMergeTest { 28 | @Test 29 | public void testBasicOrder() throws InterruptedException { 30 | final Random rnd = new Random(); 31 | ParallelTransformers.orderedMerge(Flowable.range(1, 5).parallel(4).runOn(Schedulers.computation()).map(new Function() { 32 | @Override 33 | public Integer apply(Integer t) throws Exception { 34 | Thread.sleep(0, 50 + rnd.nextInt(1000)); 35 | return t; 36 | } 37 | })).test().await().assertResult(1, 2, 3, 4, 5); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/test/java/hu/akarnokd/rxjava3/string/StringObservableTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.string; 18 | 19 | import org.junit.Test; 20 | 21 | import hu.akarnokd.rxjava3.test.BaseTest; 22 | 23 | public class StringObservableTest extends BaseTest { 24 | 25 | @Test 26 | public void characters() { 27 | assertResult(StringObservable.characters("abcdef"), 97, 98, 99, 100, 101, 102); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/test/java/hu/akarnokd/rxjava3/subjects/SubjectsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.subjects; 18 | 19 | import org.junit.Test; 20 | 21 | import hu.akarnokd.rxjava3.test.TestHelper; 22 | 23 | public class SubjectsTest { 24 | 25 | @Test 26 | public void utilityClass() { 27 | TestHelper.checkUtilityClass(Subjects.class); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/test/java/hu/akarnokd/rxjava3/test/BaseTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.test; 18 | 19 | import org.reactivestreams.Publisher; 20 | 21 | import io.reactivex.rxjava3.core.*; 22 | import io.reactivex.rxjava3.observers.TestObserver; 23 | import io.reactivex.rxjava3.subscribers.TestSubscriber; 24 | 25 | public abstract class BaseTest { 26 | 27 | @SafeVarargs 28 | public static void assertResult(ObservableSource source, T... array) { 29 | TestObserver to = new TestObserver<>(); 30 | 31 | source.subscribe(to); 32 | 33 | to.assertValues(array); 34 | to.assertNoErrors(); 35 | to.assertComplete(); 36 | } 37 | 38 | @SafeVarargs 39 | public static void assertResult(Publisher source, T... array) { 40 | TestSubscriber ts = new TestSubscriber<>(); 41 | 42 | source.subscribe(ts); 43 | 44 | ts.assertValues(array) 45 | .assertNoErrors() 46 | .assertComplete(); 47 | } 48 | 49 | @SafeVarargs 50 | public static Observable observe(T... array) { 51 | return Observable.fromArray(array); 52 | } 53 | 54 | @SafeVarargs 55 | public static Flowable flow(T... array) { 56 | return Flowable.fromArray(array); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/test/java/hu/akarnokd/rxjava3/test/TestException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-present David Karnok 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hu.akarnokd.rxjava3.test; 18 | 19 | /** 20 | * Exception for testing if unchecked expections propagate as-is without confusing with 21 | * other type of common exceptions. 22 | */ 23 | public final class TestException extends RuntimeException { 24 | 25 | private static final long serialVersionUID = -1438148770465406172L; 26 | 27 | /** 28 | * Constructs a TestException without message or cause. 29 | */ 30 | public TestException() { 31 | super(); 32 | } 33 | 34 | /** 35 | * Counstructs a TestException with message and cause. 36 | * @param message the message 37 | * @param cause the cause 38 | */ 39 | public TestException(String message, Throwable cause) { 40 | super(message, cause); 41 | } 42 | 43 | /** 44 | * Constructs a TestException with a message only. 45 | * @param message the message 46 | */ 47 | public TestException(String message) { 48 | super(message); 49 | } 50 | 51 | /** 52 | * Constructs a TestException with a cause only. 53 | * @param cause the cause 54 | */ 55 | public TestException(Throwable cause) { 56 | super(cause); 57 | } 58 | } 59 | --------------------------------------------------------------------------------