2 * Reactor - AbstractState.java - Copyright © 2013 David Roden
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 package net.pterodactylus.reactor.states;
20 import net.pterodactylus.reactor.State;
23 * Abstract implementation of a {@link State} that knows about the basic
24 * attributes of a {@link State}.
26 * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
28 public abstract class AbstractState implements State {
30 /** Whether the state was successfully retrieved. */
31 private final boolean success;
33 /** The optional exception that occured while retrieving the state. */
34 private final Throwable exception;
37 * Creates a new successful state.
39 protected AbstractState() {
44 * Creates a new state.
47 * {@code true} if the state is successful, {@code false}
50 protected AbstractState(boolean success) {
55 * Creates a new non-successful state with the given exception.
58 * The exception that occured while retrieving the state
60 protected AbstractState(Throwable exception) {
61 this(false, exception);
65 * Creates a new state.
68 * {@code true} if the state is successful, {@code false}
71 * The exception that occured while retrieving the state
73 protected AbstractState(boolean success, Throwable exception) {
74 this.success = success;
75 this.exception = exception;
86 public boolean success() {
94 public Throwable exception() {