View Javadoc

1   package org.kuali.common.util.xml.jaxb;
2   
3   import java.util.List;
4   
5   import javax.xml.bind.annotation.XmlAttribute;
6   import javax.xml.bind.annotation.XmlElement;
7   import javax.xml.bind.annotation.XmlRootElement;
8   import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
9   
10  import org.kuali.common.util.Assert;
11  import org.kuali.common.util.xml.jaxb.adapter.ImmutableListAdapter;
12  import org.kuali.common.util.xml.jaxb.adapter.TrimmingCSVStringAdapter;
13  
14  import com.google.common.collect.ImmutableList;
15  
16  @XmlRootElement
17  @XmlClassBindings(classes = Sport.class)
18  public class University {
19  
20  	@XmlAttribute
21  	private final String name;
22  	@XmlElement
23  	@XmlJavaTypeAdapter(ImmutableListAdapter.class)
24  	private final List<Sport> sports;
25  	@XmlElement
26  	@XmlJavaTypeAdapter(TrimmingCSVStringAdapter.class)
27  	private final List<String> colors;
28  
29  	public List<Sport> getSports() {
30  		return sports;
31  	}
32  
33  	public List<String> getColors() {
34  		return colors;
35  	}
36  
37  	public String getName() {
38  		return name;
39  	}
40  
41  	University() {
42  		this.name = null;
43  		this.sports = ImmutableList.of();
44  		this.colors = ImmutableList.of();
45  	}
46  
47  	public University(String name, List<Sport> sports, List<String> colors) {
48  		Assert.noBlanks(name);
49  		Assert.noNulls(sports, colors);
50  		this.name = name;
51  		this.sports = ImmutableList.copyOf(sports);
52  		this.colors = ImmutableList.copyOf(colors);
53  	}
54  
55  }