Mercurial > hg4j
annotate src/org/tmatesoft/hg/util/Outcome.java @ 597:c895b5556937
Wrap manifest revision map completion into single file access
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Fri, 03 May 2013 14:10:40 +0200 |
parents | 909306e412e2 |
children |
rev | line source |
---|---|
360
150500515714
Report non-critical errors during status operation to handler/inspector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
1 /* |
454
36fd1fd06492
oth.util.Status renamed to Outcome as the noun is too overloaded, especially in scm
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
360
diff
changeset
|
2 * Copyright (c) 2011-2012 TMate Software Ltd |
360
150500515714
Report non-critical errors during status operation to handler/inspector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
3 * |
150500515714
Report non-critical errors during status operation to handler/inspector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
4 * This program is free software; you can redistribute it and/or modify |
150500515714
Report non-critical errors during status operation to handler/inspector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
5 * it under the terms of the GNU General Public License as published by |
150500515714
Report non-critical errors during status operation to handler/inspector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
6 * the Free Software Foundation; version 2 of the License. |
150500515714
Report non-critical errors during status operation to handler/inspector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
7 * |
150500515714
Report non-critical errors during status operation to handler/inspector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
8 * This program is distributed in the hope that it will be useful, |
150500515714
Report non-critical errors during status operation to handler/inspector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
150500515714
Report non-critical errors during status operation to handler/inspector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
150500515714
Report non-critical errors during status operation to handler/inspector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
11 * GNU General Public License for more details. |
150500515714
Report non-critical errors during status operation to handler/inspector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
12 * |
150500515714
Report non-critical errors during status operation to handler/inspector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
13 * For information on how to redistribute this software under |
150500515714
Report non-critical errors during status operation to handler/inspector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
14 * the terms of a license other than GNU General Public License |
150500515714
Report non-critical errors during status operation to handler/inspector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
15 * contact TMate Software at support@hg4j.com |
150500515714
Report non-critical errors during status operation to handler/inspector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
16 */ |
150500515714
Report non-critical errors during status operation to handler/inspector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
17 package org.tmatesoft.hg.util; |
150500515714
Report non-critical errors during status operation to handler/inspector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
18 |
150500515714
Report non-critical errors during status operation to handler/inspector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
19 /** |
150500515714
Report non-critical errors during status operation to handler/inspector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
20 * Success/failure descriptor. When exception is too much. |
150500515714
Report non-critical errors during status operation to handler/inspector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
21 * |
150500515714
Report non-critical errors during status operation to handler/inspector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
22 * @author Artem Tikhomirov |
150500515714
Report non-critical errors during status operation to handler/inspector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
23 * @author TMate Software Ltd. |
150500515714
Report non-critical errors during status operation to handler/inspector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
24 */ |
456
909306e412e2
Refactor LogFacility and SessionContext, better API for both
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
454
diff
changeset
|
25 public final class Outcome { |
360
150500515714
Report non-critical errors during status operation to handler/inspector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
26 // XXX perhaps private enum and factory method createError() and createOk()? |
150500515714
Report non-critical errors during status operation to handler/inspector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
27 public enum Kind { |
454
36fd1fd06492
oth.util.Status renamed to Outcome as the noun is too overloaded, especially in scm
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
360
diff
changeset
|
28 Success, Failure; |
360
150500515714
Report non-critical errors during status operation to handler/inspector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
29 } |
150500515714
Report non-critical errors during status operation to handler/inspector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
30 |
150500515714
Report non-critical errors during status operation to handler/inspector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
31 private final Kind kind; |
150500515714
Report non-critical errors during status operation to handler/inspector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
32 private final String message; |
150500515714
Report non-critical errors during status operation to handler/inspector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
33 private final Exception error; |
150500515714
Report non-critical errors during status operation to handler/inspector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
34 |
454
36fd1fd06492
oth.util.Status renamed to Outcome as the noun is too overloaded, especially in scm
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
360
diff
changeset
|
35 public Outcome(Kind k, String msg) { |
360
150500515714
Report non-critical errors during status operation to handler/inspector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
36 this(k, msg, null); |
150500515714
Report non-critical errors during status operation to handler/inspector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
37 } |
150500515714
Report non-critical errors during status operation to handler/inspector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
38 |
454
36fd1fd06492
oth.util.Status renamed to Outcome as the noun is too overloaded, especially in scm
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
360
diff
changeset
|
39 public Outcome(Kind k, String msg, Exception err) { |
360
150500515714
Report non-critical errors during status operation to handler/inspector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
40 kind = k; |
150500515714
Report non-critical errors during status operation to handler/inspector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
41 message = msg; |
150500515714
Report non-critical errors during status operation to handler/inspector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
42 error = err; |
150500515714
Report non-critical errors during status operation to handler/inspector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
43 } |
150500515714
Report non-critical errors during status operation to handler/inspector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
44 |
150500515714
Report non-critical errors during status operation to handler/inspector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
45 public boolean isOk() { |
454
36fd1fd06492
oth.util.Status renamed to Outcome as the noun is too overloaded, especially in scm
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
360
diff
changeset
|
46 return kind == Kind.Success; |
360
150500515714
Report non-critical errors during status operation to handler/inspector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
47 } |
150500515714
Report non-critical errors during status operation to handler/inspector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
48 |
150500515714
Report non-critical errors during status operation to handler/inspector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
49 public Kind getKind() { |
150500515714
Report non-critical errors during status operation to handler/inspector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
50 return kind; |
150500515714
Report non-critical errors during status operation to handler/inspector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
51 } |
150500515714
Report non-critical errors during status operation to handler/inspector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
52 |
150500515714
Report non-critical errors during status operation to handler/inspector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
53 public String getMessage() { |
150500515714
Report non-critical errors during status operation to handler/inspector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
54 return message; |
150500515714
Report non-critical errors during status operation to handler/inspector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
55 } |
150500515714
Report non-critical errors during status operation to handler/inspector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
56 |
150500515714
Report non-critical errors during status operation to handler/inspector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
57 public Exception getException() { |
150500515714
Report non-critical errors during status operation to handler/inspector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
58 return error; |
150500515714
Report non-critical errors during status operation to handler/inspector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
59 } |
150500515714
Report non-critical errors during status operation to handler/inspector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
60 } |