001// License: GPL. For details, see LICENSE file.
002package org.openstreetmap.josm.data.preferences;
003
004import java.util.Collection;
005
006import org.openstreetmap.josm.Main;
007
008/**
009 * A property containing a {@code Collection} of {@code String} as value.
010 */
011public class CollectionProperty extends AbstractProperty<Collection<String>> {
012
013    /**
014     * Constructs a new {@code CollectionProperty}.
015     * @param key The property key
016     * @param defaultValue The default value
017     */
018    public CollectionProperty(String key, Collection<String> defaultValue) {
019        super(key, defaultValue);
020        if (Main.pref != null) {
021            get();
022        }
023    }
024
025    @Override
026    public Collection<String> get() {
027        return getPreferences().getCollection(getKey(), getDefaultValue());
028    }
029
030    @Override
031    public boolean put(Collection<String> value) {
032        return getPreferences().putCollection(getKey(), value);
033    }
034}