Interface Request<R>
- Type Parameters:
R- the expected response type of the request
public interface Request<R>
Marker interface for request messages (e.g., commands or queries) that expect a response of a specific type.
Implementing this interface allows the Fluxzero client to infer the return type of a request, enabling:
- Type-safe request invocations (e.g.
Fluxzero.queryAndWait(Request<T>)returnsT) - Compile-time verification that handler methods return a value compatible with the expected response
Example
@Value
public class GetUser implements Request<UserProfile> {
String userId;
@HandleQuery
UserProfile handle(GetUser query) {
return Fluxzero.search(UserProfile.class).match(query.getUserId()).fetchFirstOrNull();
}
}
The responseType() method provides runtime introspection for the expected return type. This is primarily
used for generic resolution and handler validation, and relies on reflection to inspect the generic type parameter
R declared in Request<R>.
-
Method Summary
Modifier and TypeMethodDescriptiondefault TypeReturns the expected response type associated with this request instance.
-
Method Details
-
responseType
Returns the expected response type associated with this request instance.This is resolved via reflective analysis of the request's declared generic type (i.e.,
RinRequest<R>). If no concrete type is available,Object.classis returned as a fallback.- Returns:
- the
Typerepresenting the expected response type, orObject.classif unknown
-