From d96c0d90abc4a85f77b0c567d915195c173b50ea Mon Sep 17 00:00:00 2001 From: tanghanzheng Date: Mon, 9 Oct 2023 14:57:37 +0800 Subject: [PATCH] reactive --- .../reactive/core/concept/ReactiveCollection.java | 3 ++- .../reactive/reactor/concept/ReactorCollection.java | 12 ++++++++++-- .../reactive/reactor/concept/ReactorObject.java | 6 +++--- .../reactive/rxjava3/concept/RxJava3Collection.java | 12 ++++++++++-- .../reactive/rxjava3/concept/RxJava3Object.java | 6 +++--- 5 files changed, 28 insertions(+), 11 deletions(-) diff --git a/concept-reactive/concept-reactive-core/src/main/java/com/github/linyuzai/reactive/core/concept/ReactiveCollection.java b/concept-reactive/concept-reactive-core/src/main/java/com/github/linyuzai/reactive/core/concept/ReactiveCollection.java index 3245368f..0a8601c1 100644 --- a/concept-reactive/concept-reactive-core/src/main/java/com/github/linyuzai/reactive/core/concept/ReactiveCollection.java +++ b/concept-reactive/concept-reactive-core/src/main/java/com/github/linyuzai/reactive/core/concept/ReactiveCollection.java @@ -1,8 +1,9 @@ package com.github.linyuzai.reactive.core.concept; -public interface ReactiveCollection { +public interface ReactiveCollection { interface Factory { + ReactiveCollection empty(); } } diff --git a/concept-reactive/concept-reactive-reactor/src/main/java/com/github/linyuzai/reactive/reactor/concept/ReactorCollection.java b/concept-reactive/concept-reactive-reactor/src/main/java/com/github/linyuzai/reactive/reactor/concept/ReactorCollection.java index 60cea822..e2c194b6 100644 --- a/concept-reactive/concept-reactive-reactor/src/main/java/com/github/linyuzai/reactive/reactor/concept/ReactorCollection.java +++ b/concept-reactive/concept-reactive-reactor/src/main/java/com/github/linyuzai/reactive/reactor/concept/ReactorCollection.java @@ -1,13 +1,21 @@ package com.github.linyuzai.reactive.reactor.concept; import com.github.linyuzai.reactive.core.concept.ReactiveCollection; +import lombok.Getter; +import lombok.RequiredArgsConstructor; import reactor.core.publisher.Flux; -public class ReactorCollection implements ReactiveCollection { +@Getter +@RequiredArgsConstructor +public class ReactorCollection implements ReactiveCollection { - private Flux flux; + private final Flux flux; public static class FluxFactory implements Factory { + @Override + public ReactiveCollection empty() { + return new ReactorCollection<>(Flux.empty()); + } } } diff --git a/concept-reactive/concept-reactive-reactor/src/main/java/com/github/linyuzai/reactive/reactor/concept/ReactorObject.java b/concept-reactive/concept-reactive-reactor/src/main/java/com/github/linyuzai/reactive/reactor/concept/ReactorObject.java index 3c4d12e1..56e825da 100644 --- a/concept-reactive/concept-reactive-reactor/src/main/java/com/github/linyuzai/reactive/reactor/concept/ReactorObject.java +++ b/concept-reactive/concept-reactive-reactor/src/main/java/com/github/linyuzai/reactive/reactor/concept/ReactorObject.java @@ -1,8 +1,8 @@ package com.github.linyuzai.reactive.reactor.concept; import com.github.linyuzai.reactive.core.concept.ReactiveObject; -import lombok.AllArgsConstructor; import lombok.Getter; +import lombok.RequiredArgsConstructor; import reactor.core.publisher.Mono; import java.util.concurrent.Callable; @@ -10,10 +10,10 @@ import java.util.function.Supplier; @Getter -@AllArgsConstructor +@RequiredArgsConstructor public class ReactorObject implements ReactiveObject { - private Mono mono; + private final Mono mono; public static class MonoFactory implements Factory { diff --git a/concept-reactive/concept-reactive-rxjava3/src/main/java/com/github/linyuzai/reactive/rxjava3/concept/RxJava3Collection.java b/concept-reactive/concept-reactive-rxjava3/src/main/java/com/github/linyuzai/reactive/rxjava3/concept/RxJava3Collection.java index 21e53c5b..70e9e765 100644 --- a/concept-reactive/concept-reactive-rxjava3/src/main/java/com/github/linyuzai/reactive/rxjava3/concept/RxJava3Collection.java +++ b/concept-reactive/concept-reactive-rxjava3/src/main/java/com/github/linyuzai/reactive/rxjava3/concept/RxJava3Collection.java @@ -2,12 +2,20 @@ import com.github.linyuzai.reactive.core.concept.ReactiveCollection; import io.reactivex.rxjava3.core.Flowable; +import lombok.Getter; +import lombok.RequiredArgsConstructor; -public class RxJava3Collection implements ReactiveCollection { +@Getter +@RequiredArgsConstructor +public class RxJava3Collection implements ReactiveCollection { - private Flowable flowable; + private final Flowable flowable; public static class FlowableFactory implements Factory { + @Override + public ReactiveCollection empty() { + return new RxJava3Collection<>(Flowable.empty()); + } } } diff --git a/concept-reactive/concept-reactive-rxjava3/src/main/java/com/github/linyuzai/reactive/rxjava3/concept/RxJava3Object.java b/concept-reactive/concept-reactive-rxjava3/src/main/java/com/github/linyuzai/reactive/rxjava3/concept/RxJava3Object.java index e314d56e..152044b3 100644 --- a/concept-reactive/concept-reactive-rxjava3/src/main/java/com/github/linyuzai/reactive/rxjava3/concept/RxJava3Object.java +++ b/concept-reactive/concept-reactive-rxjava3/src/main/java/com/github/linyuzai/reactive/rxjava3/concept/RxJava3Object.java @@ -2,18 +2,18 @@ import com.github.linyuzai.reactive.core.concept.ReactiveObject; import io.reactivex.rxjava3.core.Maybe; -import lombok.AllArgsConstructor; import lombok.Getter; +import lombok.RequiredArgsConstructor; import java.util.concurrent.Callable; import java.util.concurrent.CompletableFuture; import java.util.function.Supplier; @Getter -@AllArgsConstructor +@RequiredArgsConstructor public class RxJava3Object implements ReactiveObject { - private Maybe maybe; + private final Maybe maybe; public static class MaybeFactory implements Factory {