mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-24 07:07:43 +01:00
Don't return null if name is null by try to use UNDEFINED. Only if that is not present we return null
This commit is contained in:
parent
527f1537a9
commit
2b747cc323
1 changed files with 3 additions and 6 deletions
|
@ -69,13 +69,10 @@ public class ProtoUtil {
|
|||
*/
|
||||
@Nullable
|
||||
public static <E extends Enum<E>> E enumFromProto(Class<E> enumType, String name) {
|
||||
if (name == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
E result = Enums.getIfPresent(enumType, name).orNull();
|
||||
String enumName = name != null ? name : "UNDEFINED";
|
||||
E result = Enums.getIfPresent(enumType, enumName).orNull();
|
||||
if (result == null) {
|
||||
log.debug("Invalid value for enum " + enumType.getSimpleName() + ": " + name);
|
||||
log.debug("Invalid value for enum " + enumType.getSimpleName() + ": " + enumName);
|
||||
result = Enums.getIfPresent(enumType, "UNDEFINED").orNull();
|
||||
log.debug("We try to lookup for an enum entry with name 'UNDEFINED' and use that if available, " +
|
||||
"otherwise the enum is null. enum={}", result);
|
||||
|
|
Loading…
Add table
Reference in a new issue