Debian Codegraph @

jna-rinchi-core/src/main/java/io/github/dan2097/jnarinchi/RinchiInput.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 import java.util.ArrayList;
21 import java.util.Collections;
22 import java.util.List;
23
24 /**
25 * This data class is used as an input to the native RInChI library.
26 * It contains a list of {@link RinchiInputComponent RinchiInputComponents} and
27 * a {@link ReactionDirection}.
28 *
29 * @author Nikolay Kochev
30 */
31 public class RinchiInput {
32 private final List<RinchiInputComponent> components = new ArrayList<>();
33 private ReactionDirection direction = ReactionDirection.FORWARD;
34
35 public void addComponent(RinchiInputComponent component) {
36 this.components.add(component);
37 }
38
39 public RinchiInputComponent getComponent(int i) {
40 return components.get(i);
41 }
42
43 public List<RinchiInputComponent> getComponents() {
44 return Collections.unmodifiableList(components);
45 }
46
47 public ReactionDirection getDirection() {
48 return direction;
49 }
50
51 public void setDirection(ReactionDirection direction) {
52 this.direction = direction;
53 }
54
55 @Override
56 public String toString() {
57 StringBuilder sb = new StringBuilder();
58 sb.append("Reaction direction: ").append(direction).append("\n");
59 for (int i = 0; i < components.size(); i++) {
60 sb.append("Component ").append(i + 1);
61 sb.append(" ").append(components.get(i).getRole()).append("\n");
62 sb.append(components.get(i).toString());
63 }
64 return sb.toString();
65 }
66
67 }