Skip to content

Commit 7a73f21

Browse files
committed
rename parseString to parseValue
add parseValueSafe
1 parent 28e3667 commit 7a73f21

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

NetLicensingClient/src/main/java/com/labs64/netlicensing/domain/vo/DiscountType.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ public enum DiscountType {
55

66
PERCENT;
77

8-
public static DiscountType parseString(final String discountType) {
8+
public static DiscountType parseValue(final String discountType) {
99
if (discountType != null) {
1010
for (final DiscountType type : DiscountType.values()) {
1111
if (discountType.equalsIgnoreCase(type.name())) {
@@ -15,4 +15,12 @@ public static DiscountType parseString(final String discountType) {
1515
}
1616
throw new IllegalArgumentException(discountType);
1717
}
18+
19+
public static DiscountType parseValueSafe(final String discountType) {
20+
try {
21+
return parseValue(discountType);
22+
} catch (final IllegalArgumentException e) {
23+
return null;
24+
}
25+
}
1826
}

0 commit comments

Comments
 (0)