mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-12-22 20:47:57 +01:00
Add DataForm.addFields()
This commit is contained in:
parent
d26baeb66f
commit
8aa7029b38
1 changed files with 21 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue