1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.student.contract.model.test.source;
17
18 import java.io.Serializable;
19 import java.util.ArrayList;
20 import java.util.List;
21
22 import javax.xml.bind.annotation.XmlElement;
23 import javax.xml.bind.annotation.XmlTransient;
24
25 import org.kuali.student.contract.model.test.source.Attribute;
26 import org.kuali.student.contract.model.test.source.HasAttributes;
27
28 @SuppressWarnings("serial")
29 @XmlTransient
30 public abstract class HasAttributesInfo implements HasAttributes, Serializable {
31
32 @XmlElement
33 protected final List<AttributeInfo> attributes;
34
35 protected HasAttributesInfo() {
36 attributes = null;
37 }
38
39 protected HasAttributesInfo(HasAttributes builder) {
40 attributes = new ArrayList<AttributeInfo>();
41
42 AttributeInfo.Builder attBuilder = new AttributeInfo.Builder();
43 for (Attribute att : builder.getAttributes()) {
44 attBuilder.setKey(att.getKey());
45 attBuilder.setValue(att.getValue());
46 attBuilder.setId(att.getId());
47 attributes.add(attBuilder.build());
48 }
49 }
50
51
52
53
54 @Override
55 public List<AttributeInfo> getAttributes() {
56 return attributes;
57 }
58
59 public static class Builder implements HasAttributes {
60 private List<? extends Attribute> attributes = new ArrayList<AttributeInfo>();
61
62 public Builder() {}
63
64 public Builder(HasAttributes hasAtts) {
65 this.attributes = hasAtts.getAttributes();
66 }
67
68 @Override
69 public List<? extends Attribute> getAttributes() {
70 return attributes;
71 }
72
73 public void setAttributes(List<? extends Attribute> attributes) {
74 this.attributes = attributes;
75 }
76 }
77 }