comparison CodeGeneration/JavaEnumeration.mustache @ 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 {{#has_documentation}}
28 /**
29 {{#documentation}}
30 * {{line}}
31 {{/documentation}}
32 **/
33 {{/has_documentation}}
34 public enum {{short_name}} {
35 {{#values}}
36 {{#has_documentation}}
37 /**
38 {{#documentation}}
39 * {{line}}
40 {{/documentation}}
41 **/
42 {{/has_documentation}}
43 {{key}}({{value}}){{^last}},{{/last}}{{#last}};{{/last}}
44 {{/values}}
45
46 private int value;
47
48 private {{short_name}}(int value) {
49 this.value = value;
50 }
51
52 /**
53 * Return the enumeration value that corresponds to an integer value of interest.
54 * @param value The integer value.
55 * @return The enumeration value.
56 **/
57 protected static {{short_name}} getInstance(int value) {
58 {{#values}}
59 if (value == {{value}}) {
60 return {{key}};
61 }
62 {{/values}}
63
64 throw new IllegalArgumentException("Value out of range for enumeration {{short_name}}: " + value);
65 }
66
67 /**
68 * Get the integer value corresponding to this enumeration value.
69 * @return The integer value.
70 **/
71 public int getValue() {
72 return value;
73 }
74 }