| 1 |
/** |
| 2 |
* JNA-InChI - Library for calling InChI from Java |
| 3 |
* Copyright © 2018 Daniel Lowe |
| 4 |
* |
| 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 |
* |
| 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 |
* |
| 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.jnainchi; |
| 19 |
|
| 20 |
import java.util.HashMap; |
| 21 |
import java.util.Map; |
| 22 |
|
| 23 |
import io.github.dan2097.jnainchi.inchi.InchiLibrary; |
| 24 |
|
| 25 |
public enum InchiKeyStatus { |
| 26 |
|
| 27 |
/** Success; no errors or warnings*/ |
| 28 |
OK(InchiLibrary.INCHIKEY_OK), |
| 29 |
|
| 30 |
/** Unknown program error*/ |
| 31 |
UNKNOWN_ERROR(InchiLibrary.INCHIKEY_UNKNOWN_ERROR), |
| 32 |
|
| 33 |
/** Source string is empty*/ |
| 34 |
EMPTY_INPUT(InchiLibrary.INCHIKEY_EMPTY_INPUT), |
| 35 |
|
| 36 |
/** Invalid InChI prefix or invalid version (not 1)*/ |
| 37 |
INVALID_INCHI_PREFIX(InchiLibrary.INCHIKEY_INVALID_INCHI_PREFIX), |
| 38 |
|
| 39 |
/** Not enough memory*/ |
| 40 |
NOT_ENOUGH_MEMORY(InchiLibrary.INCHIKEY_NOT_ENOUGH_MEMORY), |
| 41 |
|
| 42 |
/** Source InChI has invalid layout*/ |
| 43 |
INVALID_INCHI(InchiLibrary.INCHIKEY_INVALID_INCHI), |
| 44 |
|
| 45 |
/** Source standard InChI has invalid layout*/ |
| 46 |
INVALID_STD_INCHI(InchiLibrary.INCHIKEY_INVALID_STD_INCHI); |
| 47 |
|
| 48 |
private final int code; |
| 49 |
|
| 50 |
private InchiKeyStatus(int code){ |
| 51 |
this.code = code; |
| 52 |
} |
| 53 |
|
| 54 |
private static final Map<Integer, InchiKeyStatus> map = new HashMap<>(); |
| 55 |
|
| 56 |
static { |
| 57 |
for (InchiKeyStatus val : InchiKeyStatus.values()) { |
| 58 |
map.put(val.code, val); |
| 59 |
} |
| 60 |
} |
| 61 |
|
| 62 |
static InchiKeyStatus of(int code) { |
| 63 |
return map.get(code); |
| 64 |
} |
| 65 |
|
| 66 |
} |