1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package io.netty.handler.codec.xml;
17
18 import java.util.ArrayList;
19 import java.util.List;
20
21
22
23
24
25 public abstract class XmlElement {
26
27 private final String name;
28 private final String namespace;
29 private final String prefix;
30
31 private final List<XmlNamespace> namespaces = new ArrayList<XmlNamespace>();
32
33 protected XmlElement(String name, String namespace, String prefix) {
34 this.name = name;
35 this.namespace = namespace;
36 this.prefix = prefix;
37 }
38
39 public String name() {
40 return name;
41 }
42
43 public String namespace() {
44 return namespace;
45 }
46
47 public String prefix() {
48 return prefix;
49 }
50
51 public List<XmlNamespace> namespaces() {
52 return namespaces;
53 }
54
55 @Override
56 public boolean equals(Object o) {
57 if (this == o) {
58 return true;
59 }
60 if (o == null || getClass() != o.getClass()) {
61 return false;
62 }
63
64 XmlElement that = (XmlElement) o;
65
66 if (!name.equals(that.name)) {
67 return false;
68 }
69 if (namespace != null ? !namespace.equals(that.namespace) : that.namespace != null) {
70 return false;
71 }
72 if (!namespaces.equals(that.namespaces)) {
73 return false;
74 }
75 if (prefix != null ? !prefix.equals(that.prefix) : that.prefix != null) {
76 return false;
77 }
78
79 return true;
80 }
81
82 @Override
83 public int hashCode() {
84 int result = name.hashCode();
85 result = 31 * result + (namespace != null ? namespace.hashCode() : 0);
86 result = 31 * result + (prefix != null ? prefix.hashCode() : 0);
87 result = 31 * result + namespaces.hashCode();
88 return result;
89 }
90
91 @Override
92 public String toString() {
93 return ", name='" + name + '\'' +
94 ", namespace='" + namespace + '\'' +
95 ", prefix='" + prefix + '\'' +
96 ", namespaces=" + namespaces;
97 }
98
99 }