Package yakworks.api
Interface Result
-
- All Superinterfaces:
yakworks.message.MsgKey,yakworks.message.MsgKeyDecorator
- All Known Subinterfaces:
IProblem,IProblem.Fluent<E>,Result.Fluent<E>
public interface Result extends yakworks.message.MsgKeyDecoratorThis is the base result trait for problems and results follows https://datatracker.ietf.org/doc/html/rfc7807 for status and title fields In many cases for parallel processing and batch processing we are spinning through chunks of data. Especially when doing gpars and concurrent processing. Java of course does not allow multi-value returns. On errors and exceptions we don't want to stop or halt the processing. So many methods can catch an exception and return this to contain basic status and a message of what went wrong so we can be report on it, log it, etc and move on to try the next item.- Since:
- 7.0.8
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceResult.Fluent<E extends Result.Fluent>
-
Method Summary
All Methods Static Methods Instance Methods Default Methods Modifier and Type Method Description default java.lang.Objectget()get the value of the payload, keeps api similiar to Optional.default java.lang.StringgetDefaultCode()default java.lang.BooleangetOk()success or fail? if ok is true then it still may mean that there are warnings and needs to be looked intodefault java.lang.ObjectgetPayload()the response object value or result of the method/function or process Implementations might choose to ignore this in favor of concrete, typed fields.default ApiStatusgetStatus()status code, normally an HttpStatus.value()default java.lang.StringgetTitle()A short, human-readable summary of the result type.default java.lang.ObjectgetValue()alias to payloadstatic yakworks.api.OkResultof(java.lang.Object value)java.util.Optional api consitency.static yakworks.api.OkResultof(java.lang.String code, java.lang.Object args)static yakworks.api.OkResultofCode(java.lang.String code)static yakworks.api.OkResultOK()default voidsetPayload(java.lang.Object v)default voidsetStatus(ApiStatus v)default voidsetTitle(java.lang.String title)
-
-
-
Method Detail
-
getDefaultCode
default java.lang.String getDefaultCode()
-
getTitle
default java.lang.String getTitle()
A short, human-readable summary of the result type. It SHOULD NOT change from occurrence to occurrence of the result, except for purposes of localization (e.g., using proactive content negotiation; see [RFC7231], Section 3.4). in which case code can be used for lookup and the localization with message.properties
-
setTitle
default void setTitle(java.lang.String title)
-
getStatus
default ApiStatus getStatus()
status code, normally an HttpStatus.value()
-
setStatus
default void setStatus(ApiStatus v)
-
getPayload
default java.lang.Object getPayload()
the response object value or result of the method/function or process Implementations might choose to ignore this in favor of concrete, typed fields. Or this is generated from the target
-
setPayload
default void setPayload(java.lang.Object v)
-
getValue
default java.lang.Object getValue()
alias to payload
-
getOk
default java.lang.Boolean getOk()
success or fail? if ok is true then it still may mean that there are warnings and needs to be looked into
-
get
default java.lang.Object get()
get the value of the payload, keeps api similiar to Optional.
-
OK
static yakworks.api.OkResult OK()
-
ofCode
static yakworks.api.OkResult ofCode(java.lang.String code)
-
of
static yakworks.api.OkResult of(java.lang.String code, java.lang.Object args)
-
of
static yakworks.api.OkResult of(java.lang.Object value)
java.util.Optional api consitency. Creates a result with the value as the payload
-
-