comparison src/org/tmatesoft/hg/util/Outcome.java @ 454:36fd1fd06492

oth.util.Status renamed to Outcome as the noun is too overloaded, especially in scm
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Wed, 13 Jun 2012 21:07:39 +0200
parents src/org/tmatesoft/hg/util/Status.java@150500515714
children 909306e412e2
comparison
equal deleted inserted replaced
453:7b883bf03b14 454:36fd1fd06492
1 /*
2 * Copyright (c) 2011-2012 TMate Software Ltd
3 *
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; version 2 of the License.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * For information on how to redistribute this software under
14 * the terms of a license other than GNU General Public License
15 * contact TMate Software at support@hg4j.com
16 */
17 package org.tmatesoft.hg.util;
18
19 /**
20 * Success/failure descriptor. When exception is too much.
21 *
22 * @author Artem Tikhomirov
23 * @author TMate Software Ltd.
24 */
25 public class Outcome {
26 // XXX perhaps private enum and factory method createError() and createOk()?
27 public enum Kind {
28 Success, Failure;
29 }
30
31 private final Kind kind;
32 private final String message;
33 private final Exception error;
34
35 public Outcome(Kind k, String msg) {
36 this(k, msg, null);
37 }
38
39 public Outcome(Kind k, String msg, Exception err) {
40 kind = k;
41 message = msg;
42 error = err;
43 }
44
45 public boolean isOk() {
46 return kind == Kind.Success;
47 }
48
49 public Kind getKind() {
50 return kind;
51 }
52
53 public String getMessage() {
54 return message;
55 }
56
57 public Exception getException() {
58 return error;
59 }
60 }