source: josm/trunk/src/org/openstreetmap/josm/gui/mappaint/StyleElementList.java@ 11921

Last change on this file since 11921 was 9669, checked in by bastiK, 8 years ago

add missing svn:eol-style=native (see #12410)

  • Property svn:eol-style set to native
File size: 1.6 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.mappaint;
3
4import java.util.ArrayList;
5import java.util.Arrays;
6import java.util.Collection;
7import java.util.Iterator;
8import java.util.List;
9import java.util.Objects;
10
11import org.openstreetmap.josm.gui.mappaint.styleelement.StyleElement;
12
13/**
14 * List of {@link StyleElement}s, immutable.
15 */
16public class StyleElementList implements Iterable<StyleElement> {
17 private final List<StyleElement> lst;
18
19 /**
20 * Constructs a new {@code StyleList}.
21 */
22 public StyleElementList() {
23 lst = new ArrayList<>();
24 }
25
26 public StyleElementList(StyleElement... init) {
27 lst = new ArrayList<>(Arrays.asList(init));
28 }
29
30 public StyleElementList(Collection<StyleElement> sl) {
31 lst = new ArrayList<>(sl);
32 }
33
34 public StyleElementList(StyleElementList sl, StyleElement s) {
35 lst = new ArrayList<>(sl.lst);
36 lst.add(s);
37 }
38
39 @Override
40 public Iterator<StyleElement> iterator() {
41 return lst.iterator();
42 }
43
44 public boolean isEmpty() {
45 return lst.isEmpty();
46 }
47
48 public int size() {
49 return lst.size();
50 }
51
52 @Override
53 public String toString() {
54 return lst.toString();
55 }
56
57 @Override
58 public boolean equals(Object obj) {
59 if (this == obj) return true;
60 if (obj == null || getClass() != obj.getClass()) return false;
61 StyleElementList that = (StyleElementList) obj;
62 return Objects.equals(lst, that.lst);
63 }
64
65 @Override
66 public int hashCode() {
67 return Objects.hash(lst);
68 }
69}
Note: See TracBrowser for help on using the repository browser.