Debian Codegraph @

jna-rinchi-core/src/main/java/io/github/dan2097/jnarinchi/ReactionDirection.java

raw
1 /**
2 * JNA-RInChI - Library for calling RInChI from Java
3 * Copyright © 2022 Nikolay Kochev
4 * <p>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 * <p>
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
14 * <p>
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 package io.github.dan2097.jnarinchi;
19
20 /**
21 * Enum to indicate the direction of the reaction.
22 * <br>
23 * Each constant is associated with a short designation as used by RInChI.
24 * For a given enum the short designation can be returned with {@link #getShortRinchiDesignation()}.
25 * For a given short designation, the enum can be returned with {@link #getDirectionFromShortDesignation(String)}.
26 */
27 public enum ReactionDirection {
28 FORWARD("+"),
29 BACKWARD("-"),
30 EQUILIBRIUM("=");
31
32 private final String shortRinchiDesignation;
33
34 ReactionDirection(String shortRinchiDesignation) {
35 this.shortRinchiDesignation = shortRinchiDesignation;
36 }
37
38 /**
39 * Returns the short designation of this reaction direction as used by RInChI.
40 * @return the short designation
41 */
42 public String getShortRinchiDesignation() {
43 return shortRinchiDesignation;
44 }
45
46 /**
47 * Returns the enum associated with the provided short designation as used by RInChI.
48 * @param shortDesignation short designation the enum is returned for
49 * @return enum associated with <code>shortDesignation</code> or <code>null</code> if there is no enum whose short RInChI designation matches <code>shortResignation</code>
50 */
51 public static ReactionDirection getDirectionFromShortDesignation(String shortDesignation) {
52 for (ReactionDirection dir : ReactionDirection.values())
53 if (dir.getShortRinchiDesignation().equals(shortDesignation))
54 return dir;
55
56 return null;
57 }
58
59 }