1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package org.kuali.mobility.computerlabs.entity;
16
17 import java.io.Serializable;
18 import java.util.ArrayList;
19 import java.util.List;
20
21 import javax.xml.bind.annotation.XmlElement;
22 import javax.xml.bind.annotation.XmlRootElement;
23 import org.apache.commons.collections.CollectionUtils;
24 import org.kuali.mobility.computerlabs.util.LabTransform;
25 import org.kuali.mobility.computerlabs.util.LocationTransform;
26
27
28
29
30
31
32
33
34
35 @XmlRootElement(name = "location")
36 public class LocationImpl implements Serializable, Comparable<Location>, Location {
37
38 private static final long serialVersionUID = -4991494626566555287L;
39 private String name;
40 @XmlElement(name = "labs")
41 private List<LabImpl> labs;
42
43 private static final LabTransform LAB_TRANSFORM = new LabTransform();
44
45 public LocationImpl() {
46 super();
47 this.labs = new ArrayList<LabImpl>();
48 }
49
50 public LocationImpl(String name) {
51 this.name = name;
52 this.labs = new ArrayList<LabImpl>();
53 }
54
55 @Override
56 public List<LabImpl> getLabs() {
57 return labs;
58 }
59
60 @Override
61 public void setLabs(List<? extends Lab> labs) {
62 CollectionUtils.collect(labs, LAB_TRANSFORM, this.labs);
63 }
64
65 @Override
66 public void addLab( Lab lab ) {
67 this.labs.add( LAB_TRANSFORM.transform(lab) );
68 }
69
70 @Override
71 public String getName() {
72 return name;
73 }
74
75 @Override
76 public void setName(String name) {
77 this.name = name;
78 }
79
80 @Override
81 public int compareTo(Location that) {
82 if (this == null || that == null) {
83 return -1;
84 }
85 if (this.getName() == that.getName()) {
86 return 0;
87 }
88 return this.getName().compareTo(that.getName());
89 }
90 }