Allow exception-free conversion from String to PresenceType

This commit is contained in:
catbref 2020-12-21 12:25:11 +00:00
parent 4e89b8fbac
commit 7cbdbbcc8d

View File

@ -69,6 +69,15 @@ public class PresenceTransaction extends Transaction {
public static PresenceType valueOf(int value) {
return map.get(value);
}
/** Returns PresenceType with matching <tt>name</tt> or <tt>null</tt> (instead of throwing IllegalArgumentException). */
public static PresenceType fromString(String name) {
try {
return PresenceType.valueOf(name);
} catch (IllegalArgumentException e) {
return null;
}
}
}
// Constructors