From 5c46451cd204f932fc48fced90a6b9bdb8847339 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Mon, 27 Dec 2021 21:19:05 +0100 Subject: [PATCH] [xdata] Add BooleanFormField.getValueAsBooleanOrNull() This method is meant to provide 'raw' access to what has been sent over the wire. It is assumed to be not of much use in the typically case, but provided for completeness. --- .../smackx/xdata/BooleanFormField.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/xdata/BooleanFormField.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/xdata/BooleanFormField.java index 6208e4979..6681e6408 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/xdata/BooleanFormField.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/xdata/BooleanFormField.java @@ -49,6 +49,20 @@ public class BooleanFormField extends SingleValueFormField { return value; } + /** + * Get the value of the boolean field or maybe null. Note that you usually want to use + * {@link #getValueAsBoolean()} instead of this method, as {@link #getValueAsBoolean()} considers the default value + * of boolean fields. That is, boolean form fields have the value false if not explicitly set to + * something else. + * + * @return the boolean value of this form field or null if no value was explicitly provided. + * @see #getValueAsBoolean() + * @since 4.4.5 + */ + public Boolean getValueAsBooleanOrNull() { + return value; + } + public Builder asBuilder() { return new Builder(this); }