mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-20 03:28:04 +01:00
Canonical discoverability writing.
This commit is contained in:
committed by
gram-signal
parent
92f035bc2a
commit
b4aabd799b
@@ -23,6 +23,8 @@ public class AttributeValues {
|
||||
return AttributeValue.builder().n(Long.toString(value)).build();
|
||||
}
|
||||
|
||||
public static AttributeValue fromBool(boolean value) { return AttributeValue.builder().bool(value).build(); }
|
||||
|
||||
public static AttributeValue fromInt(int value) {
|
||||
return AttributeValue.builder().n(Integer.toString(value)).build();
|
||||
}
|
||||
@@ -43,6 +45,10 @@ public class AttributeValues {
|
||||
return AttributeValue.builder().b(value).build();
|
||||
}
|
||||
|
||||
private static boolean toBool(AttributeValue av) {
|
||||
return av.bool();
|
||||
}
|
||||
|
||||
private static int toInt(AttributeValue av) {
|
||||
return Integer.parseInt(av.n());
|
||||
}
|
||||
@@ -67,6 +73,10 @@ public class AttributeValues {
|
||||
return Optional.ofNullable(item.get(key));
|
||||
}
|
||||
|
||||
public static boolean getBool(Map<String, AttributeValue> item, String key, boolean defaultValue) {
|
||||
return AttributeValues.get(item, key).map(AttributeValues::toBool).orElse(defaultValue);
|
||||
}
|
||||
|
||||
public static int getInt(Map<String, AttributeValue> item, String key, int defaultValue) {
|
||||
return AttributeValues.get(item, key).map(AttributeValues::toInt).orElse(defaultValue);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user