source: josm/trunk/src/org/openstreetmap/josm/spi/preferences/ListSetting.java@ 13466

Last change on this file since 13466 was 12987, checked in by bastiK, 7 years ago

see #15410 - change preferences scheme for named colors - makes runtime color name registry obsolete

  • Property svn:eol-style set to native
File size: 1.4 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.spi.preferences;
3
4import java.util.ArrayList;
5import java.util.Collection;
6import java.util.Collections;
7import java.util.List;
8
9/**
10 * Setting containing a {@link List} of {@link String} values.
11 * @since 12881 (moved from package {@code org.openstreetmap.josm.data.preferences})
12 */
13public class ListSetting extends AbstractSetting<List<String>> {
14 /**
15 * Constructs a new {@code ListSetting} with the given value
16 * @param value The setting value
17 */
18 public ListSetting(List<String> value) {
19 super(value);
20 consistencyTest();
21 }
22
23 /**
24 * Convenience factory method.
25 * @param value the value
26 * @return a corresponding ListSetting object
27 */
28 public static ListSetting create(Collection<String> value) {
29 return new ListSetting(value == null ? null : Collections.unmodifiableList(new ArrayList<>(value)));
30 }
31
32 @Override
33 public ListSetting copy() {
34 return ListSetting.create(value);
35 }
36
37 private void consistencyTest() {
38 if (value != null && value.contains(null))
39 throw new IllegalArgumentException("Error: Null as list element in preference setting: " + value);
40 }
41
42 @Override
43 public void visit(SettingVisitor visitor) {
44 visitor.visit(this);
45 }
46
47 @Override
48 public ListSetting getNullInstance() {
49 return new ListSetting(null);
50 }
51}
Note: See TracBrowser for help on using the repository browser.