| 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 |
public class InchiBond { |
| 21 |
|
| 22 |
private final InchiAtom start; |
| 23 |
private final InchiAtom end; |
| 24 |
private final InchiBondType type; |
| 25 |
private final InchiBondStereo stereo; |
| 26 |
|
| 27 |
public InchiBond(InchiAtom start, InchiAtom end, InchiBondType type) { |
| 28 |
this(start, end, type, InchiBondStereo.NONE); |
| 29 |
} |
| 30 |
|
| 31 |
public InchiBond(InchiAtom start, InchiAtom end, InchiBondType type, InchiBondStereo stereo) { |
| 32 |
if (start.equals(end)) { |
| 33 |
throw new IllegalArgumentException("start and end must be different atoms"); |
| 34 |
} |
| 35 |
if (type == null) { |
| 36 |
throw new IllegalArgumentException("type must not be null"); |
| 37 |
} |
| 38 |
if (stereo == null) { |
| 39 |
throw new IllegalArgumentException("stereo must not be null, use InchiBondStereo.NONE"); |
| 40 |
} |
| 41 |
this.start = start; |
| 42 |
this.end = end; |
| 43 |
this.type = type; |
| 44 |
this.stereo = stereo; |
| 45 |
} |
| 46 |
|
| 47 |
public InchiAtom getStart() { |
| 48 |
return start; |
| 49 |
} |
| 50 |
|
| 51 |
public InchiAtom getEnd() { |
| 52 |
return end; |
| 53 |
} |
| 54 |
|
| 55 |
public InchiBondType getType() { |
| 56 |
return type; |
| 57 |
} |
| 58 |
|
| 59 |
public InchiBondStereo getStereo() { |
| 60 |
return stereo; |
| 61 |
} |
| 62 |
|
| 63 |
public InchiAtom getOther(InchiAtom atom) { |
| 64 |
if (start == atom) { |
| 65 |
return end; |
| 66 |
} |
| 67 |
if (end == atom) { |
| 68 |
return start; |
| 69 |
} |
| 70 |
return null; |
| 71 |
} |
| 72 |
|
| 73 |
|
| 74 |
} |