Skip to content

Commit 12a9538

Browse files
authored
Add DiscountType supporting Discounts LM
1 parent 2141fad commit 12a9538

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.labs64.netlicensing.domain.vo;
2+
3+
public enum DiscountType {
4+
FIX,
5+
6+
PERCENT;
7+
8+
public static DiscountType parseValue(final String discountType) {
9+
if (discountType != null) {
10+
for (final DiscountType type : DiscountType.values()) {
11+
if (discountType.equalsIgnoreCase(type.name())) {
12+
return type;
13+
}
14+
}
15+
}
16+
throw new IllegalArgumentException(discountType);
17+
}
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+
}
26+
}

0 commit comments

Comments
 (0)