1
18 package org.torweg.pulse.util.entity;
19
20 import java.util.ArrayList;
21 import java.util.Collections;
22 import java.util.List;
23
24 import javax.xml.bind.annotation.XmlAccessOrder;
25 import javax.xml.bind.annotation.XmlAccessType;
26 import javax.xml.bind.annotation.XmlAccessorOrder;
27 import javax.xml.bind.annotation.XmlAccessorType;
28 import javax.xml.bind.annotation.XmlAttribute;
29 import javax.xml.bind.annotation.XmlElement;
30 import javax.xml.bind.annotation.XmlElementWrapper;
31 import javax.xml.bind.annotation.XmlRootElement;
32
33 import org.jdom.Element;
34 import org.torweg.pulse.configuration.Configuration;
35
36
45 @XmlRootElement(name = "abstract-image-group-configuration")
46 @XmlAccessorOrder(XmlAccessOrder.UNDEFINED)
47 @XmlAccessorType(XmlAccessType.FIELD)
48 public abstract class AbstractImageGroupConfiguration extends Configuration {
49
50
53 private static final long serialVersionUID = 3728475342837920452L;
54
55
58 @XmlElementWrapper(name = "versions")
59 @XmlElement(name = "version")
60 private final List<Version> versions = new ArrayList<Version>();
61
62
68 public final List<Version> getVersions() {
69 return Collections.unmodifiableList(this.versions);
70 }
71
72
79 @XmlRootElement(name = "version")
80 @XmlAccessorOrder(XmlAccessOrder.UNDEFINED)
81 @XmlAccessorType(XmlAccessType.FIELD)
82 public static final class Version {
83
84
87 @XmlAttribute(name = "name")
88 private String name;
89
90
93 @XmlAttribute(name = "x")
94 private Integer x = null;
95
96
99 @XmlAttribute(name = "y")
100 private Integer y = null;
101
102
106 @XmlAttribute(name = "required")
107 private boolean required = true;
108
109
112 @Deprecated
113 protected Version() {
114 super();
115 }
116
117
124 public Version(final String n) {
125 super();
126 this.name = n;
127 }
128
129
140 public Version(final Element el) {
141 super();
142 if (el.getAttribute("name") == null
143 || el.getAttributeValue("name").equals("")) {
144 throw new IllegalArgumentException(
145 "Given el/@name must not be null aor empty string.");
146 }
147 this.name = el.getAttributeValue("name");
148 if (el.getAttribute("x") == null
149 || el.getAttributeValue("x").equals("")) {
150 this.x = Integer.parseInt(el.getAttributeValue("x"));
151 }
152 if (el.getAttribute("y") == null
153 || el.getAttributeValue("y").equals("")) {
154 this.y = Integer.parseInt(el.getAttributeValue("y"));
155 }
156 if (el.getAttribute("required") == null
157 || el.getAttributeValue("required").equals("")) {
158 this.required = Boolean.parseBoolean(el
159 .getAttributeValue("required"));
160 }
161 }
162
163
166 public String getName() {
167 return this.name;
168 }
169
170
173 public Integer getX() {
174 return this.x;
175 }
176
177
180 public Integer getY() {
181 return this.y;
182 }
183
184
187 public boolean isRequired() {
188 return this.required;
189 }
190
191 }
192
193 }
194