1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-19 02:22:05 +01:00

[xdata] Adjust behavior of BooleanFormField.getValueAsBoolean()

According to XEP-0004 § 3.3, the default value of a boolean form field
is 'false'. And since users are typically interested in getting the
value, and not potentially 'null' as result, we adjust the behavior of
the getValueAsBoolean() method consider the default value.
This commit is contained in:
Florian Schmaus 2021-12-27 21:17:57 +01:00
parent 178e82a3aa
commit 940d7bf02a

View file

@ -35,7 +35,17 @@ public class BooleanFormField extends SingleValueFormField {
return value.toString();
}
public Boolean getValueAsBoolean() {
/**
* Get the value of the booelan field. Note that, if no explicit boolean value is provided, in the form of "true",
* "false", "0", or "1", then the default value of a boolean field is <code>false</code>, according to
* XEP-0004 § 3.3.
*
* @return the boolean value of this form field.
*/
public boolean getValueAsBoolean() {
if (value == null) {
return false;
}
return value;
}