source: josm/trunk/src/org/openstreetmap/josm/data/preferences/ListSetting.java@ 12825

Last change on this file since 12825 was 11394, checked in by Don-vip, 7 years ago

simplify preference settings equals handling (already performed by AbstractList.equals / AbstractMap.equals) - fixes squid:S1206 and findbugs HE_EQUALS_NO_HASHCODE warnings

  • 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.data.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 9759
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");
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.