1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-26 00:02:06 +01:00

[formtypes] Introduce LOOKASIDE_FIELD_REGISTRY

Some field's like stream-method of XEP-0096, which is of type
list-single, need to be pre-registered.
This commit is contained in:
Florian Schmaus 2021-03-14 17:58:13 +01:00
parent 73941629f3
commit adc159186c

View file

@ -36,6 +36,8 @@ public class FormFieldRegistry {
private static final Map<String, FormField.Type> CLARK_NOTATION_FIELD_REGISTRY = new ConcurrentHashMap<>(); private static final Map<String, FormField.Type> CLARK_NOTATION_FIELD_REGISTRY = new ConcurrentHashMap<>();
private static final Map<String, FormField.Type> LOOKASIDE_FIELD_REGISTRY = new ConcurrentHashMap<>();
@SuppressWarnings("ReferenceEquality") @SuppressWarnings("ReferenceEquality")
public static void register(DataForm dataForm) { public static void register(DataForm dataForm) {
// TODO: Also allow forms of type 'result'? // TODO: Also allow forms of type 'result'?
@ -98,11 +100,11 @@ public class FormFieldRegistry {
public static FormField.Type lookup(String formType, String fieldName) { public static FormField.Type lookup(String formType, String fieldName) {
if (formType == null) { if (formType == null) {
if (!XmlUtil.isClarkNotation(fieldName)) { if (XmlUtil.isClarkNotation(fieldName)) {
return null; return CLARK_NOTATION_FIELD_REGISTRY.get(fieldName);
} }
return CLARK_NOTATION_FIELD_REGISTRY.get(fieldName); return LOOKASIDE_FIELD_REGISTRY.get(fieldName);
} }
synchronized (REGISTRY) { synchronized (REGISTRY) {
@ -122,4 +124,7 @@ public class FormFieldRegistry {
return lookup(null, fieldName); return lookup(null, fieldName);
} }
public static void addLookasideFieldRegistryEntry(String fieldName, FormField.Type formFieldType) {
LOOKASIDE_FIELD_REGISTRY.put(fieldName, formFieldType);
}
} }