Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
*/
package io.github.dan2097.jnainchi;

import java.util.HashMap;
import java.util.Locale;

public enum InchiFlag {

/** Both ends of wedge point to stereocenters [compatible with standard InChI]*/
Expand Down Expand Up @@ -113,8 +116,30 @@ public String toString() {
//Java doesn't allow enums to start with digits
return "15T";
}
else {
return super.toString();
return super.toString();
}

private static HashMap<String, InchiFlag> map;

/**
* Get a flag from a string, case insensitive.
* Cache the names for better performance.
*
* @param name
* @return the matching InchiFlag or null
* @author Bob Hanson
*/
public static InchiFlag getFlagFromName(String name) {
if (name == null) {
return null;
}
if (map == null) {
map = new HashMap<>();
for (InchiFlag item : values()) {
map.put(item.toString().toLowerCase(Locale.ROOT), item);
}
}
return map.get(name.toLowerCase(Locale.ROOT));
}

}