All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.albertus82.jface.preference.StaticLabelsAndValues Maven / Gradle / Ivy

Go to download

Java SWT/JFace Utility Library including a Preferences Framework, Lightweight HTTP Server and macOS support.

There is a newer version: 20.1.0
Show newest version
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