| 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 role of the component of a reaction. |
| 22 |
* <br> |
| 23 |
* Each constant is associated with a short designation used by RInChI to refer to this role. |
| 24 |
* <p> |
| 25 |
* For a given enum the short designation can be returned with {@link #getShortRinchiDesignation()}. |
| 26 |
* <br> |
| 27 |
* For a given short designation, the enum can be returned with {@link #getRoleFromShortDesignation(String)}. |
| 28 |
* </p> |
| 29 |
*/ |
| 30 |
public enum ReactionComponentRole { |
| 31 |
REAGENT("R"), |
| 32 |
PRODUCT("P"), |
| 33 |
AGENT("A"); |
| 34 |
|
| 35 |
private final String shortRinchiDesignation; |
| 36 |
|
| 37 |
ReactionComponentRole(String shortRinchiDesignation) { |
| 38 |
this.shortRinchiDesignation = shortRinchiDesignation; |
| 39 |
} |
| 40 |
|
| 41 |
/** |
| 42 |
* Returns the short designation of this component role as used by RInChI. |
| 43 |
* @return the short designation |
| 44 |
*/ |
| 45 |
public String getShortRinchiDesignation() { |
| 46 |
return shortRinchiDesignation; |
| 47 |
} |
| 48 |
|
| 49 |
/** |
| 50 |
* Returns the enum associated with the provided short designation of this component role as used by RInChI. |
| 51 |
* @param shortDesignation short designation the enum is returned for |
| 52 |
* @return enum associated with <code>shortDesignation</code> or <code>null</code> if there is no enum whose short RInChI designation matches <code>shortResignation</code> |
| 53 |
*/ |
| 54 |
public static ReactionComponentRole getRoleFromShortDesignation(String shortDesignation) { |
| 55 |
for (ReactionComponentRole role : ReactionComponentRole.values()) |
| 56 |
if (role.getShortRinchiDesignation().equals(shortDesignation)) |
| 57 |
return role; |
| 58 |
|
| 59 |
return null; |
| 60 |
} |
| 61 |
} |