Add methods for boolean values

This commit is contained in:
chimp1984 2021-01-08 16:38:58 -05:00
parent 73fcf52129
commit 764614d762
No known key found for this signature in database
GPG key ID: 9801B4EC591F90E3

View file

@ -45,6 +45,16 @@ public class Cookie extends HashMap<CookieKey, String> {
}
}
public void putAsBoolean(CookieKey key, boolean value) {
put(key, value ? "1" : "0");
}
public Optional<Boolean> getAsOptionalBoolean(CookieKey key) {
return containsKey(key) ?
Optional.of(get(key).equals("1")) :
Optional.empty();
}
public Map<String, String> toProtoMessage() {
Map<String, String> protoMap = new HashMap<>();
this.forEach((key, value) -> protoMap.put(key.name(), value));