123456789101112131415161718192021222324252627282930313233343536373839 |
-
-
- /**
- * @author ZipCodeWilmington
- */
- public class ActionResult<T> {
-
- private T data;
- private String errorMessage;
-
- private ActionResult(T data) {
- this.data = data;
- }
-
- private ActionResult(String errorMessage) {
- this.errorMessage = errorMessage;
- }
-
- public T getData() {
- return data;
- }
-
- public String getErrorMessage() {
- return errorMessage;
- }
-
- public boolean isSuccess() {
- return data != null;
- }
-
- public static <E> ActionResult<E> success(E data) {
- return new ActionResult<E>(data);
- }
-
- public static <E> ActionResult<E> fail(String errorMessage) {
- return new ActionResult<E>(errorMessage);
- }
- }
|