-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #653 - Implement converters for RX Java 3
- Loading branch information
1 parent
a0ce81d
commit a17292b
Showing
33 changed files
with
1,639 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>io.smallrye.reactive</groupId> | ||
<artifactId>mutiny-project</artifactId> | ||
<version>999-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>mutiny-rxjava3</artifactId> | ||
<name>SmallRye Mutiny - Integration with RxJava 3</name> | ||
|
||
<properties> | ||
<revapi.skip>false</revapi.skip> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.smallrye.reactive</groupId> | ||
<artifactId>mutiny</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>io.reactivex.rxjava3</groupId> | ||
<artifactId>rxjava</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>io.smallrye.reactive</groupId> | ||
<artifactId>mutiny-test-utils</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-api</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-engine</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-javadoc-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>attach-javadocs</id> | ||
<goals> | ||
<goal>jar</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
[ | ||
{ | ||
"extension": "revapi.java", | ||
"id": "java", | ||
"configuration": { | ||
"missing-classes": { | ||
"behavior": "report", | ||
"ignoreMissingAnnotations": false | ||
}, | ||
"filter": { | ||
"packages": { | ||
"regex": true, | ||
"include": [ | ||
"io\\.smallrye\\.mutiny\\.converters\\.*", "io\\.smallrye\\.mutiny\\.converters\\..*" | ||
] | ||
} | ||
} | ||
} | ||
}, | ||
|
||
{ | ||
"extension": "revapi.differences", | ||
"id": "breaking-changes", | ||
"configuration": { | ||
"criticality": "highlight", | ||
"differences": [ | ||
|
||
] | ||
} | ||
}, | ||
|
||
{ | ||
"extension": "revapi.reporter.json", | ||
"configuration": { | ||
"minSeverity": "POTENTIALLY_BREAKING", | ||
"minCriticality": "documented", | ||
"output": "target/compatibility.json", | ||
"indent": true, | ||
"append": false, | ||
"keepEmptyFile": true | ||
} | ||
} | ||
] |
18 changes: 18 additions & 0 deletions
18
rxjava3/src/main/java/io/smallrye/mutiny/converters/multi/FromCompletable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package io.smallrye.mutiny.converters.multi; | ||
|
||
import io.reactivex.rxjava3.core.Completable; | ||
import io.smallrye.mutiny.Multi; | ||
import io.smallrye.mutiny.converters.MultiConverter; | ||
|
||
public class FromCompletable implements MultiConverter<Completable, Void> { | ||
public static final FromCompletable INSTANCE = new FromCompletable(); | ||
|
||
private FromCompletable() { | ||
// Avoid direct instantiation | ||
} | ||
|
||
@Override | ||
public Multi<Void> from(Completable instance) { | ||
return Multi.createFrom().publisher(instance.toFlowable()); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
rxjava3/src/main/java/io/smallrye/mutiny/converters/multi/FromFlowable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package io.smallrye.mutiny.converters.multi; | ||
|
||
import io.reactivex.rxjava3.core.Flowable; | ||
import io.smallrye.mutiny.Multi; | ||
import io.smallrye.mutiny.converters.MultiConverter; | ||
|
||
@SuppressWarnings("rawtypes") | ||
public class FromFlowable<T> implements MultiConverter<Flowable<T>, T> { | ||
|
||
public static final FromFlowable INSTANCE = new FromFlowable(); | ||
|
||
private FromFlowable() { | ||
// Avoid direct instantiation | ||
} | ||
|
||
@Override | ||
public Multi<T> from(Flowable<T> instance) { | ||
return Multi.createFrom().publisher(instance); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
rxjava3/src/main/java/io/smallrye/mutiny/converters/multi/FromMaybe.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package io.smallrye.mutiny.converters.multi; | ||
|
||
import io.reactivex.rxjava3.core.Maybe; | ||
import io.reactivex.rxjava3.disposables.Disposable; | ||
import io.smallrye.mutiny.Multi; | ||
import io.smallrye.mutiny.converters.MultiConverter; | ||
|
||
public class FromMaybe<T> implements MultiConverter<Maybe<T>, T> { | ||
|
||
public static final FromMaybe INSTANCE = new FromMaybe(); | ||
|
||
private FromMaybe() { | ||
// Avoid direct instantiation | ||
} | ||
|
||
@Override | ||
public Multi<T> from(Maybe<T> instance) { | ||
return Multi.createFrom().emitter(sink -> { | ||
Disposable disposable = instance.subscribe( | ||
item -> { | ||
sink.emit(item); | ||
sink.complete(); | ||
}, | ||
sink::fail, | ||
sink::complete); | ||
|
||
sink.onTermination(() -> { | ||
if (!disposable.isDisposed()) { | ||
disposable.dispose(); | ||
} | ||
}); | ||
}); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
rxjava3/src/main/java/io/smallrye/mutiny/converters/multi/FromObservable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package io.smallrye.mutiny.converters.multi; | ||
|
||
import io.reactivex.rxjava3.core.BackpressureStrategy; | ||
import io.reactivex.rxjava3.core.Observable; | ||
import io.smallrye.mutiny.Multi; | ||
import io.smallrye.mutiny.converters.MultiConverter; | ||
|
||
@SuppressWarnings("rawtypes") | ||
public class FromObservable<T> implements MultiConverter<Observable<T>, T> { | ||
|
||
public static final FromObservable INSTANCE = new FromObservable(); | ||
|
||
private FromObservable() { | ||
// Avoid direct instantiation | ||
} | ||
|
||
@Override | ||
public Multi<T> from(Observable<T> instance) { | ||
return Multi.createFrom().publisher(instance.toFlowable(BackpressureStrategy.BUFFER)); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
rxjava3/src/main/java/io/smallrye/mutiny/converters/multi/FromSingle.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package io.smallrye.mutiny.converters.multi; | ||
|
||
import io.reactivex.rxjava3.core.Single; | ||
import io.smallrye.mutiny.Multi; | ||
import io.smallrye.mutiny.converters.MultiConverter; | ||
|
||
@SuppressWarnings("rawtypes") | ||
public class FromSingle<T> implements MultiConverter<Single<T>, T> { | ||
|
||
public static final FromSingle INSTANCE = new FromSingle(); | ||
|
||
private FromSingle() { | ||
// Avoid direct instantiation | ||
} | ||
|
||
@Override | ||
public Multi<T> from(Single<T> instance) { | ||
return Multi.createFrom().publisher(instance.toFlowable()); | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
rxjava3/src/main/java/io/smallrye/mutiny/converters/multi/MultiRx3Converters.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package io.smallrye.mutiny.converters.multi; | ||
|
||
public class MultiRx3Converters { | ||
|
||
private MultiRx3Converters() { | ||
// Avoid direct instantiation | ||
} | ||
|
||
public static FromCompletable fromCompletable() { | ||
return FromCompletable.INSTANCE; | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
public static <T> FromSingle<T> fromSingle() { | ||
return FromSingle.INSTANCE; | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
public static <T> FromMaybe<T> fromMaybe() { | ||
return FromMaybe.INSTANCE; | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
public static <T> FromFlowable<T> fromFlowable() { | ||
return FromFlowable.INSTANCE; | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
public static <T> FromObservable<T> fromObservable() { | ||
return FromObservable.INSTANCE; | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
public static <T> ToSingle<T> toSingle() { | ||
return ToSingle.INSTANCE; | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
public static <T> ToCompletable<T> toCompletable() { | ||
return ToCompletable.INSTANCE; | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
public static <T> ToMaybe<T> toMaybe() { | ||
return ToMaybe.INSTANCE; | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
public static <T> ToFlowable<T> toFlowable() { | ||
return ToFlowable.INSTANCE; | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
public static <T> ToObservable<T> toObservable() { | ||
return ToObservable.INSTANCE; | ||
} | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
rxjava3/src/main/java/io/smallrye/mutiny/converters/multi/ToCompletable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package io.smallrye.mutiny.converters.multi; | ||
|
||
import java.util.function.Function; | ||
|
||
import io.reactivex.rxjava3.core.Completable; | ||
import io.smallrye.mutiny.Multi; | ||
|
||
@SuppressWarnings("rawtypes") | ||
public class ToCompletable<T> implements Function<Multi<T>, Completable> { | ||
|
||
public static final ToCompletable INSTANCE = new ToCompletable(); | ||
|
||
private ToCompletable() { | ||
// Avoid direct instantiation | ||
} | ||
|
||
@Override | ||
public Completable apply(Multi<T> multi) { | ||
return Completable.fromPublisher(multi.onItem().ignore()); | ||
} | ||
} |
Oops, something went wrong.