From 7cbdbbcc8d874d68c8c405fce98017acf18891e1 Mon Sep 17 00:00:00 2001 From: catbref Date: Mon, 21 Dec 2020 12:25:11 +0000 Subject: [PATCH] Allow exception-free conversion from String to PresenceType --- .../java/org/qortal/transaction/PresenceTransaction.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/org/qortal/transaction/PresenceTransaction.java b/src/main/java/org/qortal/transaction/PresenceTransaction.java index 5e976511..e5b96661 100644 --- a/src/main/java/org/qortal/transaction/PresenceTransaction.java +++ b/src/main/java/org/qortal/transaction/PresenceTransaction.java @@ -69,6 +69,15 @@ public class PresenceTransaction extends Transaction { public static PresenceType valueOf(int value) { return map.get(value); } + + /** Returns PresenceType with matching name or null (instead of throwing IllegalArgumentException). */ + public static PresenceType fromString(String name) { + try { + return PresenceType.valueOf(name); + } catch (IllegalArgumentException e) { + return null; + } + } } // Constructors