-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(api)!: Rename
JsonMessage
interface to JsonRecord
BREAKING-CHANGE: Rename `JsonMessage` interface to `JsonRecord`. Co-authored-by: pklaschka <[email protected]>
- Loading branch information
Showing
9 changed files
with
228 additions
and
230 deletions.
There are no files selected for viewing
138 changes: 69 additions & 69 deletions
138
...ce/telestion/api/message/JsonMessage.java → ...ace/telestion/api/message/JsonRecord.java
Large diffs are not rendered by default.
Oops, something went wrong.
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
6 changes: 3 additions & 3 deletions
6
telestion-api/src/main/java/de/wuespace/telestion/api/verticle/TelestionConfiguration.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 |
---|---|---|
@@ -1,13 +1,13 @@ | ||
package de.wuespace.telestion.api.verticle; | ||
|
||
import de.wuespace.telestion.api.message.JsonMessage; | ||
import de.wuespace.telestion.api.message.JsonRecord; | ||
|
||
/** | ||
* The base class for all Telestion Verticle configurations. | ||
* It extends {@link JsonMessage} so all configurations are also valid json classes. | ||
* It extends {@link JsonRecord} so all configurations are also valid json classes. | ||
* | ||
* @author Cedric Bös (@cb0s), Pablo Klaschka (@pklaschka), Jan von Pichowski (@jvpichowski), | ||
* Ludwig Richter (@fussel178) | ||
*/ | ||
public interface TelestionConfiguration extends JsonMessage { | ||
public interface TelestionConfiguration extends JsonRecord { | ||
} |
40 changes: 20 additions & 20 deletions
40
telestion-api/src/main/java/de/wuespace/telestion/api/verticle/trait/DecodedMessage.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 |
---|---|---|
@@ -1,59 +1,59 @@ | ||
package de.wuespace.telestion.api.verticle.trait; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import de.wuespace.telestion.api.message.JsonMessage; | ||
import de.wuespace.telestion.api.message.JsonRecord; | ||
import io.vertx.core.Future; | ||
import io.vertx.core.eventbus.Message; | ||
import io.vertx.core.json.JsonObject; | ||
|
||
/** | ||
* A wrapper for a {@link Message Vert.x message} and its body as {@link JsonMessage}. | ||
* A wrapper for a {@link Message Vert.x message} and its body as {@link JsonRecord}. | ||
* | ||
* @param message the {@link Message Vert.x message} | ||
* @param body the decoded body of the {@link Message Vert.x message} | ||
* @param <V> the type of {@link JsonMessage} to map to | ||
* @param <V> the type of {@link JsonRecord} to map to | ||
* @param <T> the type of the body of the {@link Message Vert.x message} | ||
* @see JsonMessage#on(Class, Message) | ||
* @see JsonRecord#on(Class, Message) | ||
* | ||
* @author Ludwig Richter (@fussel178) | ||
*/ | ||
public record DecodedMessage<V extends JsonMessage, T extends JsonObject>( | ||
public record DecodedMessage<V extends JsonRecord, T extends JsonObject>( | ||
@JsonProperty V body, | ||
@JsonProperty Message<T> message | ||
) implements JsonMessage { | ||
) implements JsonRecord { | ||
|
||
/** | ||
* Returns a {@link Future} which succeeds with the {@code messageFuture}'s body as {@link JsonMessage}. | ||
* Fails if the {@code messageFuture}'s body cannot be mapped to the {@link JsonMessage} type | ||
* Returns a {@link Future} which succeeds with the {@code messageFuture}'s body as {@link JsonRecord}. | ||
* Fails if the {@code messageFuture}'s body cannot be mapped to the {@link JsonRecord} type | ||
* or the {@code messageFuture} fails. | ||
* | ||
* @param clazz the class type of the {@link JsonMessage} to map to | ||
* @param clazz the class type of the {@link JsonRecord} to map to | ||
* @param messageFuture the future that returns the received message | ||
* @param <V> the type of {@link JsonMessage} to map to | ||
* @param <V> the type of {@link JsonRecord} to map to | ||
* @param <T> the type of the body of the {@link Message Vert.x message} | ||
* @return a new {@link Future} which succeeds with the {@code messageFuture}'s body as {@link JsonMessage} | ||
* @see JsonMessage#on(Class, Message) | ||
* @return a new {@link Future} which succeeds with the {@code messageFuture}'s body as {@link JsonRecord} | ||
* @see JsonRecord#on(Class, Message) | ||
*/ | ||
public static <V extends JsonMessage, T extends JsonObject> Future<DecodedMessage<V, T>> compose( | ||
public static <V extends JsonRecord, T extends JsonObject> Future<DecodedMessage<V, T>> compose( | ||
Class<V> clazz, | ||
Future<Message<T>> messageFuture) { | ||
return messageFuture.compose(message -> on(clazz, message)); | ||
} | ||
|
||
/** | ||
* Return a {@link Future} which succeeds with the {@link Message Vert.x message}'s body as {@link JsonMessage}. | ||
* Fails if the {@link Message Vert.x message}'s body cannot be mapped to the {@link JsonMessage} type. | ||
* Returns a {@link Future} which succeeds with the {@link Message Vert.x message}'s body as {@link JsonRecord}. | ||
* Fails if the {@link Message Vert.x message}'s body cannot be mapped to the {@link JsonRecord} type. | ||
* | ||
* @param clazz the class type of the {@link JsonMessage} to map to | ||
* @param clazz the class type of the {@link JsonRecord} to map to | ||
* @param message the {@link Message Vert.x message} | ||
* @param <V> the type of {@link JsonMessage} to map to | ||
* @param <V> the type of {@link JsonRecord} to map to | ||
* @param <T> the type of the body of the {@link Message Vert.x message} | ||
* @return a new {@link Future} which returns a {@link DecodedMessage} with the message's contents | ||
* @see JsonMessage#on(Class, Message) | ||
* @see JsonRecord#on(Class, Message) | ||
*/ | ||
public static <V extends JsonMessage, T extends JsonObject> Future<DecodedMessage<V, T>> on( | ||
public static <V extends JsonRecord, T extends JsonObject> Future<DecodedMessage<V, T>> on( | ||
Class<V> clazz, | ||
Message<T> message) { | ||
return JsonMessage.on(clazz, message).map(decoded -> new DecodedMessage<>(decoded, message)); | ||
return JsonRecord.on(clazz, message).map(decoded -> new DecodedMessage<>(decoded, message)); | ||
} | ||
} |
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
Oops, something went wrong.