mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 01:41:11 +01:00
Add null check for name
This commit is contained in:
parent
3e728c69f7
commit
008ae93b88
@ -66,6 +66,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();
|
||||
if (result == null) {
|
||||
log.error("Invalid value for enum " + enumType.getSimpleName() + ": " + name);
|
||||
@ -77,7 +81,8 @@ public class ProtoUtil {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static <T extends Message> Iterable<T> collectionToProto(Collection<? extends Proto> collection, Class<T> messageType) {
|
||||
public static <T extends Message> Iterable<T> collectionToProto(Collection<? extends Proto> collection,
|
||||
Class<T> messageType) {
|
||||
return collection.stream()
|
||||
.map(e -> {
|
||||
final Message message = e.toProtoMessage();
|
||||
@ -92,7 +97,8 @@ public class ProtoUtil {
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public static <T> Iterable<T> collectionToProto(Collection<? extends Proto> collection, Function<? super Message, T> extra) {
|
||||
public static <T> Iterable<T> collectionToProto(Collection<? extends Proto> collection,
|
||||
Function<? super Message, T> extra) {
|
||||
return collection.stream().map(o -> extra.apply(o.toProtoMessage())).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user