mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-09-09 17:19:39 +02:00
Introduce FormFieldChildElement and make FormField immutable
This commit is contained in:
parent
1a99801501
commit
4d36e3b521
36 changed files with 1191 additions and 490 deletions
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2015-2018 Florian Schmaus
|
||||
* Copyright 2015-2019 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -49,4 +49,10 @@ public class CollectionUtil {
|
|||
public interface Predicate<T> {
|
||||
boolean test(T t);
|
||||
}
|
||||
|
||||
public static <T> ArrayList<T> newListWith(Collection<? extends T> collection) {
|
||||
ArrayList<T> arrayList = new ArrayList<>(collection.size());
|
||||
arrayList.addAll(collection);
|
||||
return arrayList;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.util.LinkedHashMap;
|
|||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
|
@ -57,7 +58,11 @@ public class MultiMap<K, V> {
|
|||
* @param size the initial capacity.
|
||||
*/
|
||||
public MultiMap(int size) {
|
||||
map = new LinkedHashMap<>(size);
|
||||
this(new LinkedHashMap<>(size));
|
||||
}
|
||||
|
||||
private MultiMap(Map<K, List<V>> map) {
|
||||
this.map = map;
|
||||
}
|
||||
|
||||
public int size() {
|
||||
|
@ -235,6 +240,18 @@ public class MultiMap<K, V> {
|
|||
return entrySet;
|
||||
}
|
||||
|
||||
public MultiMap<K, V> asUnmodifiableMultiMap() {
|
||||
LinkedHashMap<K, List<V>> mapCopy = new LinkedHashMap<>(map.size());
|
||||
for (Entry<K, List<V>> entry : map.entrySet()) {
|
||||
K key = entry.getKey();
|
||||
List<V> values = entry.getValue();
|
||||
|
||||
mapCopy.put(key, Collections.unmodifiableList(values));
|
||||
}
|
||||
|
||||
return new MultiMap<K, V>(Collections.unmodifiableMap(mapCopy));
|
||||
}
|
||||
|
||||
private static final class SimpleMapEntry<K, V> implements Map.Entry<K, V> {
|
||||
|
||||
private final K key;
|
||||
|
|
|
@ -273,6 +273,15 @@ public class XmlStringBuilder implements Appendable, CharSequence, Element {
|
|||
return this;
|
||||
}
|
||||
|
||||
public <E extends Enum<?>> XmlStringBuilder attribute(String name, E value, E implicitDefault) {
|
||||
if (value == null || value == implicitDefault) {
|
||||
return this;
|
||||
}
|
||||
|
||||
attribute(name, value.toString());
|
||||
return this;
|
||||
}
|
||||
|
||||
public XmlStringBuilder attribute(String name, int value) {
|
||||
assert name != null;
|
||||
return attribute(name, String.valueOf(value));
|
||||
|
|
|
@ -18,6 +18,7 @@ package org.jivesoftware.smack.test.util;
|
|||
|
||||
import java.util.Base64;
|
||||
|
||||
import org.jivesoftware.smack.SmackConfiguration;
|
||||
import org.jivesoftware.smack.util.stringencoder.Base64.Encoder;
|
||||
|
||||
/**
|
||||
|
@ -27,6 +28,7 @@ import org.jivesoftware.smack.util.stringencoder.Base64.Encoder;
|
|||
public class SmackTestSuite {
|
||||
|
||||
static {
|
||||
SmackConfiguration.getVersion();
|
||||
org.jivesoftware.smack.util.stringencoder.Base64.setEncoder(new Encoder() {
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue