Skip to content

Package: ProcessorResult$Status

ProcessorResult$Status

nameinstructionbranchcomplexitylinemethod
static {...}
M: 74 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*
2: * Copyright (c) 2008, 2020 Oracle and/or its affiliates. All rights reserved.
3: *
4: * This program and the accompanying materials are made available under the
5: * terms of the Eclipse Public License v. 2.0, which is available at
6: * http://www.eclipse.org/legal/epl-2.0.
7: *
8: * This Source Code may also be made available under the following Secondary
9: * Licenses when the conditions for such availability set forth in the
10: * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
11: * version 2 with the GNU Classpath Exception, which is available at
12: * https://www.gnu.org/software/classpath/license.html.
13: *
14: * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15: */
16:
17: package org.glassfish.grizzly;
18:
19: /**
20: * The interface represents the result of {@link Processor} execution.
21: *
22: * @author Alexey Stashok
23: */
24: public class ProcessorResult {
25:
26: private static final ProcessorResult NOT_RUN_RESULT = new ProcessorResult(Status.NOT_RUN, null);
27: private static final ProcessorResult COMPLETE_RESULT = new ProcessorResult(Status.COMPLETE, null);
28: private static final ProcessorResult LEAVE_RESULT = new ProcessorResult(Status.LEAVE, null);
29: private static final ProcessorResult REREGISTER_RESULT = new ProcessorResult(Status.REREGISTER, null);
30: private static final ProcessorResult ERROR_RESULT = new ProcessorResult(Status.ERROR, null);
31: private static final ProcessorResult TERMINATE_RESULT = new ProcessorResult(Status.TERMINATE, null);
32:
33: private static ProcessorResult create() {
34: return new ProcessorResult();
35: }
36:
37: /**
38: * Enumeration represents the status/code of {@link ProcessorResult}.
39: */
40: public enum Status {
41: COMPLETE, LEAVE, REREGISTER, RERUN, ERROR, TERMINATE, NOT_RUN
42: }
43:
44: /**
45: * Result status
46: */
47: private Status status;
48: /**
49: * Result description
50: */
51: private Object data;
52:
53: public static ProcessorResult createComplete() {
54: return COMPLETE_RESULT;
55: }
56:
57: public static ProcessorResult createComplete(final Object data) {
58: return create().setStatus(Status.COMPLETE).setData(data);
59: }
60:
61: public static ProcessorResult createLeave() {
62: return LEAVE_RESULT;
63: }
64:
65: public static ProcessorResult createReregister(final Context context) {
66: return create().setStatus(Status.REREGISTER).setData(context);
67: }
68:
69: public static ProcessorResult createError() {
70: return ERROR_RESULT;
71: }
72:
73: public static ProcessorResult createError(final Object description) {
74: return create().setStatus(Status.ERROR).setData(description);
75: }
76:
77: public static ProcessorResult createRerun(final Context context) {
78: return create().setStatus(Status.RERUN).setData(context);
79: }
80:
81: public static ProcessorResult createTerminate() {
82: return TERMINATE_RESULT;
83: }
84:
85: public static ProcessorResult createNotRun() {
86: return NOT_RUN_RESULT;
87: }
88:
89: private ProcessorResult() {
90: this(null, null);
91: }
92:
93: private ProcessorResult(final Status status) {
94: this(status, null);
95: }
96:
97: private ProcessorResult(final Status status, final Object context) {
98: this.status = status;
99: this.data = context;
100: }
101:
102: /**
103: * Get the result status.
104: *
105: * @return the result status.
106: */
107: public Status getStatus() {
108: return status;
109: }
110:
111: protected ProcessorResult setStatus(Status status) {
112: this.status = status;
113: return this;
114: }
115:
116: /**
117: * Get the {@link ProcessorResult} extra data.
118: *
119: * @return the {@link ProcessorResult} extra data.
120: */
121: public Object getData() {
122: return data;
123: }
124:
125: protected ProcessorResult setData(Object context) {
126: this.data = context;
127: return this;
128: }
129: }