001// License: GPL. For details, see LICENSE file.
002package org.openstreetmap.josm.data.preferences;
003
004/**
005 * A property containing an {@code Long} value.
006 * @since 10087
007 *
008 */
009public class LongProperty extends AbstractToStringProperty<Long> {
010
011    /**
012     * Constructs a new {@code LongProperty}
013     * @param key property key
014     * @param defaultValue default value
015     */
016    public LongProperty(String key, long defaultValue) {
017        super(key, defaultValue);
018    }
019
020    @Override
021    public Long get() {
022        // Removing this implementation breaks binary compatibility
023        return super.get();
024    }
025
026    @Override
027    public boolean put(Long value) {
028        // Removing this implementation breaks binary compatibility
029        return super.put(value);
030    }
031
032    @Override
033    protected Long fromString(String string) {
034        try {
035            return Long.valueOf(string);
036        } catch (NumberFormatException e) {
037            throw new InvalidPreferenceValueException(e);
038        }
039    }
040
041    @Override
042    protected String toString(Long t) {
043        return t.toString();
044    }
045}