Add DataForm.addFields()

This commit is contained in:
Florian Schmaus 2018-06-03 21:19:04 +02:00
parent d26baeb66f
commit 8aa7029b38
1 changed files with 21 additions and 0 deletions

View File

@ -18,6 +18,7 @@
package org.jivesoftware.smackx.xdata.packet;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
@ -234,6 +235,26 @@ public class DataForm implements ExtensionElement {
}
}
/**
* Add the given fields to this form.
*
* @param fieldsToAdd
* @return true if a field was overridden.
* @since 4.3.0
*/
public boolean addFields(Collection<FormField> fieldsToAdd) {
boolean fieldOverridden = false;
synchronized (fields) {
for (FormField field : fieldsToAdd) {
FormField previousField = fields.put(field.getVariable(), field);
if (previousField != null) {
fieldOverridden = true;
}
}
}
return fieldOverridden;
}
/**
* Adds a new instruction to the list of instructions that explain how to fill out the form
* and what the form is about. The dataform could include multiple instructions since each