This repository has been archived by the owner on Nov 9, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Resource.java
85 lines (73 loc) · 2.38 KB
/
Resource.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package org.zanata.rest.dto.resource;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.annotate.JsonProperty;
import org.codehaus.jackson.annotate.JsonPropertyOrder;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import org.zanata.common.Namespaces;
import org.zanata.rest.dto.DTOUtil;
@XmlType(name = "resourceType", propOrder = { "textFlows" })
@XmlRootElement(name = "resource")
@JsonPropertyOrder({ "name", "contentType", "lang", "extensions", "textFlows" })
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
public class Resource extends AbstractResourceMeta {
private static final long serialVersionUID = 1L;
private List<TextFlow> textFlows;
public Resource() {
}
public Resource(String name) {
super(name);
}
@XmlElementWrapper(name = "text-flows", required = false,
namespace = Namespaces.ZANATA_OLD)
@XmlElement(name = "text-flow",
namespace = org.zanata.common.Namespaces.ZANATA_API)
@JsonProperty("textFlows")
public List<TextFlow> getTextFlows() {
if (textFlows == null) {
textFlows = new ArrayList<TextFlow>();
}
return textFlows;
}
// @Override
// public String toString()
// {
// return DTOUtil.toXML(this);
// }
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCodeHelper();
result =
prime * result
+ ((textFlows == null) ? 0 : textFlows.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof Resource)) {
return false;
}
Resource other = (Resource) obj;
if (!super.equalsHelper(other)) {
return false;
}
if (textFlows == null) {
if (other.textFlows != null) {
return false;
}
} else if (!textFlows.equals(other.textFlows)) {
return false;
}
return true;
}
}