* @param <T> Target identifier type
* @param <C> Message type
*/
-public abstract class Message<T extends WritableIdentifier, C extends Message<T, C>>
- implements Immutable, Serializable {
+public abstract sealed class Message<T extends WritableIdentifier, C extends Message<T, C>>
+ implements Immutable, Serializable permits Request, Response {
/**
* Externalizable proxy for use with {@link Message} subclasses.
*
* @param <T> Target identifier type
* @param <C> Message type
*/
-public abstract class Request<T extends WritableIdentifier, C extends Request<T, C>> extends Message<T, C> {
+public abstract non-sealed class Request<T extends WritableIdentifier, C extends Request<T, C>> extends Message<T, C> {
protected interface SerialForm<T extends WritableIdentifier, C extends Request<T, C>>
extends Message.SerialForm<T, C> {
@Override
protected Request(final @NonNull C request, final @NonNull ABIVersion version) {
super(request, version);
- this.replyTo = requireNonNull(request.getReplyTo());
+ replyTo = requireNonNull(request.getReplyTo());
}
/**
* @param <T> Target identifier type
* @param <C> Message class
*/
-public abstract class RequestFailure<T extends WritableIdentifier, C extends RequestFailure<T, C>>
+public abstract non-sealed class RequestFailure<T extends WritableIdentifier, C extends RequestFailure<T, C>>
extends Response<T, C> {
/**
* Externalizable proxy for use with {@link RequestFailure} subclasses.
protected RequestFailure(final @NonNull C failure, final @NonNull ABIVersion version) {
super(failure, version);
- this.cause = requireNonNull(failure.getCause());
+ cause = requireNonNull(failure.getCause());
}
protected RequestFailure(final @NonNull T target, final long sequence, final @NonNull RequestException cause) {
*
* @param <T> Target identifier type
*/
-public abstract class RequestSuccess<T extends WritableIdentifier, C extends RequestSuccess<T, C>>
+public abstract non-sealed class RequestSuccess<T extends WritableIdentifier, C extends RequestSuccess<T, C>>
extends Response<T, C> {
protected interface SerialForm<T extends WritableIdentifier, C extends RequestSuccess<T, C>>
extends Response.SerialForm<T, C> {
* @param <T> Target identifier type
* @param <C> Message type
*/
-public abstract class Response<T extends WritableIdentifier, C extends Response<T, C>> extends Message<T, C> {
+public abstract sealed class Response<T extends WritableIdentifier, C extends Response<T, C>> extends Message<T, C>
+ permits RequestFailure, RequestSuccess {
protected interface SerialForm<T extends WritableIdentifier, C extends Response<T, C>>
extends Message.SerialForm<T, C> {