/
User.java
52 lines (43 loc) · 1.11 KB
/
User.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/**
* From object to XML via JAXB
* marshalling: http://bitingcode.blogspot.com/2012/10/from-object-to-xml.html
* unmarshalling: http://bitingcode.blogspot.com/2012/11/from-xml-to-object.html
*/
package jaxb;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlValue;
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class User {
@XmlValue
private String name;
@XmlAttribute
private int id;
@XmlAttribute
private float rating;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public float getRating() {
return rating;
}
public void setRating(float rating) {
this.rating = rating;
}
@Override
public String toString() {
return name + '(' + id + "): " + rating;
}
}