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:
parent
178e82a3aa
commit
940d7bf02a
1 changed files with 11 additions and 1 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue