View Javadoc
1   /*
2    * Copyright 2014 The Netty Project
3    *
4    * The Netty Project licenses this file to you under the Apache License,
5    * version 2.0 (the "License"); you may not use this file except in compliance
6    * with the License. You may obtain a copy of the License at:
7    *
8    *   http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13   * License for the specific language governing permissions and limitations
14   * under the License.
15   */
16  package io.netty.handler.codec.xml;
17  
18  
19  /**
20   * XML attributes, it is part of {@link XmlElement}
21   */
22  public class XmlAttribute {
23  
24      private final String type;
25      private final String name;
26      private final String prefix;
27      private final String namespace;
28      private final String value;
29  
30      public XmlAttribute(String type, String name, String prefix, String namespace, String value) {
31          this.type = type;
32          this.name = name;
33          this.prefix = prefix;
34          this.namespace = namespace;
35          this.value = value;
36      }
37  
38      public String type() {
39          return type;
40      }
41  
42      public String name() {
43          return name;
44      }
45  
46      public String prefix() {
47          return prefix;
48      }
49  
50      public String namespace() {
51          return namespace;
52      }
53  
54      public String value() {
55          return value;
56      }
57  
58      @Override
59      public boolean equals(Object o) {
60          if (this == o) { return true; }
61          if (o == null || getClass() != o.getClass()) { return false; }
62  
63          XmlAttribute that = (XmlAttribute) o;
64  
65          if (!name.equals(that.name)) { return false; }
66          if (namespace != null ? !namespace.equals(that.namespace) : that.namespace != null) { return false; }
67          if (prefix != null ? !prefix.equals(that.prefix) : that.prefix != null) { return false; }
68          if (type != null ? !type.equals(that.type) : that.type != null) { return false; }
69          if (value != null ? !value.equals(that.value) : that.value != null) { return false; }
70  
71          return true;
72      }
73  
74      @Override
75      public int hashCode() {
76          int result = type != null ? type.hashCode() : 0;
77          result = 31 * result + name.hashCode();
78          result = 31 * result + (prefix != null ? prefix.hashCode() : 0);
79          result = 31 * result + (namespace != null ? namespace.hashCode() : 0);
80          result = 31 * result + (value != null ? value.hashCode() : 0);
81          return result;
82      }
83  
84      @Override
85      public String toString() {
86          return "XmlAttribute{" +
87                  "type='" + type + '\'' +
88                  ", name='" + name + '\'' +
89                  ", prefix='" + prefix + '\'' +
90                  ", namespace='" + namespace + '\'' +
91                  ", value='" + value + '\'' +
92                  '}';
93      }
94  }