webit.script.util.keyvalues.KeyValuesGroup Maven / Gradle / Ivy
// Copyright (c) 2013, Webit Team. All Rights Reserved.
package webit.script.util.keyvalues;
import java.util.ArrayList;
import java.util.Map;
/**
*
* @author Zqq
*/
public class KeyValuesGroup implements KeyValues {
private static final int DEFAULT_CAPACITY = 8;
private ArrayList list;
public KeyValuesGroup() {
this(DEFAULT_CAPACITY);
}
public KeyValuesGroup(int capacity) {
this.list = new ArrayList(capacity);
}
public KeyValuesGroup(KeyValues... keyValueses) {
this();
this.add(keyValueses);
}
public final KeyValuesGroup add(Map map) {
if (map != null) {
this.list.add(KeyValuesUtil.wrap(map));
}
return this;
}
public final KeyValuesGroup add(String key, Object value) {
this.list.add(KeyValuesUtil.wrap(key, value));
return this;
}
public final KeyValuesGroup add(String[] keys, Object[] values) {
this.list.add(KeyValuesUtil.wrap(keys, values));
return this;
}
public final KeyValuesGroup add(KeyValues keyValues) {
if (keyValues != null) {
this.list.add(keyValues);
}
return this;
}
public final KeyValuesGroup add(KeyValues... keyValueses) {
if (keyValueses != null) {
final ArrayList myList = this.list;
KeyValues keyValues;
for (int i = 0, len = keyValueses.length; i < len; i++) {
if ((keyValues = keyValueses[i]) != null) {
myList.add(keyValues);
}
}
}
return this;
}
public void exportTo(KeyValueAccepter accepter) {
final ArrayList myList = this.list;
for (int i = 0, len = myList.size(); i < len; i++) {
myList.get(i).exportTo(accepter);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy