io.github.albertus82.jface.preference.StaticLabelsAndValues Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jface-utils Show documentation
Show all versions of jface-utils Show documentation
Java SWT/JFace Utility Library including a Preferences Framework, Lightweight HTTP Server and macOS support.
package io.github.albertus82.jface.preference;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
import io.github.albertus82.util.MapUtils;
public class StaticLabelsAndValues implements LabelsAndValues {
private final Map entries;
public StaticLabelsAndValues() {
entries = new LinkedHashMap<>();
}
public StaticLabelsAndValues(final int expectedSize) {
entries = MapUtils.newLinkedHashMapWithExpectedSize(expectedSize);
}
public StaticLabelsAndValues(final String name, final Object value) {
this(1);
put(name, value);
}
public StaticLabelsAndValues put(final String name, final Object value) {
entries.put(name, String.valueOf(value));
return this;
}
@Override
public String[][] toArray() {
final String[][] options = new String[entries.size()][2];
int index = 0;
for (final Entry entry : entries.entrySet()) {
options[index][0] = entry.getKey();
options[index][1] = entry.getValue();
index++;
}
return options;
}
@Override
public String toString() {
return entries.toString();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy