comparison JavaSDK/be/uclouvain/orthanc/JobStopReason.java @ 0:3ecef5782f2c

initial commit
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 18 Oct 2023 17:59:44 +0200
parents
children 26c08ff926a3
comparison
equal deleted inserted replaced
-1:000000000000 0:3ecef5782f2c
1 package be.uclouvain.orthanc;
2
3 /**
4 * SPDX-FileCopyrightText: 2023 Sebastien Jodogne, UCLouvain, Belgium
5 * SPDX-License-Identifier: GPL-3.0-or-later
6 */
7
8 /**
9 * Java plugin for Orthanc
10 * Copyright (C) 2023 Sebastien Jodogne, UCLouvain, Belgium
11 *
12 * This program is free software: you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License as
14 * published by the Free Software Foundation, either version 3 of the
15 * License, or (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program. If not, see http://www.gnu.org/licenses/.
24 **/
25
26
27 /**
28 * Explains why the job should stop and release the resources it has allocated.
29 * This is especially important to disambiguate between the "paused" condition and
30 * the "final" conditions (success, failure, or canceled).
31 **/
32 public enum JobStopReason {
33 /**
34 * The job has succeeded
35 **/
36 SUCCESS(1),
37 /**
38 * The job was paused, and will be resumed later
39 **/
40 PAUSED(2),
41 /**
42 * The job has failed, and might be resubmitted later
43 **/
44 FAILURE(3),
45 /**
46 * The job was canceled, and might be resubmitted later
47 **/
48 CANCELED(4);
49
50 private int value;
51
52 private JobStopReason(int value) {
53 this.value = value;
54 }
55
56 /**
57 * Return the enumeration value that corresponds to an integer value of interest.
58 * @param value The integer value.
59 * @return The enumeration value.
60 **/
61 protected static JobStopReason getInstance(int value) {
62 if (value == 1) {
63 return SUCCESS;
64 }
65 if (value == 2) {
66 return PAUSED;
67 }
68 if (value == 3) {
69 return FAILURE;
70 }
71 if (value == 4) {
72 return CANCELED;
73 }
74
75 throw new IllegalArgumentException("Value out of range for enumeration JobStopReason: " + value);
76 }
77
78 /**
79 * Get the integer value corresponding to this enumeration value.
80 * @return The integer value.
81 **/
82 public int getValue() {
83 return value;
84 }
85 }