我有一个名为enum
的{{1}}如下,表示服务的http请求状态:
Status
其中:
public enum Status {
UNKNOWN,
COMPLETED,
FAILED,
CANCELLED;
}
是初始状态; UNKNOWN
,COMPLETED
和FAILED
代表FutureCallback的三个分支,例如:https://hc.apache.org/httpcomponents-asyncclient-dev/quickstart.html 但是,CANCELLED
并不意味着响应代码肯定是200;而COMPLETED
并不意味着错误的响应代码。相反,像500,404这样的回复都会转到FAILED
的分支。
因此,我希望状态为COMPLETED
和SUCCESS
。它们都是ERROR
,但也是COMPLETED
。类似于下面的东西(但它不正确,Java不允许):
Status
类似于类的多态性的东西:
public enum Status {
UNKNOWN,
SUCCESS,
ERROR,
FAILED,
CANCELLED;
public enum COMPLETED extends Status {
SUCCESS, ERROR;
}
}
UNKNOWN
Status
FAILED
Status
CANCELLED
Status
COMPLETED
Status
SUCCESS
Status
SUCCESS
COMPLETED
ERROR
Status
ERROR
任何人都知道如何实施这样的机制?