Interface CommonResponse
- All Known Subinterfaces:
CommunicationMessage, ExternalResponse, Response
- All Known Implementing Classes:
AbstractCommunicationMessage, BroadcastUserMessage, EmptyExternalResponseMessage, ExternalMessage, ExternalResponseMessage, ResponseMessage, UserResponseMessage
public interface CommonResponse
Common response contract providing error code and message accessors.
Implemented by all response types in the protocol layer. An error code of 0 indicates success; any non-zero value signals an error condition.
- Since:
- 25.1
- Author:
- 渔民小镇
- date:
- 2025-09-16
-
Method Summary
Modifier and TypeMethodDescriptionintGet the error code. 0 indicates success; any other value indicates an error.Get the human-readable error message.default booleanhasError()Check whether this response represents an error.default booleanCheck whether this response represents a successful outcome.default voidsetError(ErrorInformation error) Populate the error code and message from the givenErrorInformation.voidsetErrorCode(int errorCode) Set the error code. 0 indicates success; any other value indicates an error.voidsetErrorMessage(String errorMessage) Set the human-readable error message.
-
Method Details
-
getErrorCode
int getErrorCode()Get the error code. 0 indicates success; any other value indicates an error.- Returns:
- the error code
-
setErrorCode
void setErrorCode(int errorCode) Set the error code. 0 indicates success; any other value indicates an error.- Parameters:
errorCode- the error code
-
getErrorMessage
String getErrorMessage()Get the human-readable error message.- Returns:
- the error message, or
nullon success
-
setErrorMessage
Set the human-readable error message.- Parameters:
errorMessage- the error message
-
setError
Populate the error code and message from the givenErrorInformation.- Parameters:
error- the error information source
-
hasError
default boolean hasError()Check whether this response represents an error.- Returns:
trueif the error code is non-zero
-
isSuccess
default boolean isSuccess()Check whether this response represents a successful outcome.- Returns:
trueif the error code is 0
-