View Javadoc
1   /*
2    * The MIT License
3    * Copyright © 2004-2014 Fabrizio Giustina
4    * Copyright © 2022-2022 Web-Legacy
5    *
6    * Permission is hereby granted, free of charge, to any person obtaining a copy
7    * of this software and associated documentation files (the "Software"), to deal
8    * in the Software without restriction, including without limitation the rights
9    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10   * copies of the Software, and to permit persons to whom the Software is
11   * furnished to do so, subject to the following conditions:
12   *
13   * The above copyright notice and this permission notice shall be included in
14   * all copies or substantial portions of the Software.
15   *
16   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22   * THE SOFTWARE.
23   */
24  package net.sf.maventaglib.checker;
25  
26  import org.apache.commons.lang3.builder.CompareToBuilder;
27  import org.apache.commons.lang3.builder.EqualsBuilder;
28  import org.apache.commons.lang3.builder.HashCodeBuilder;
29  
30  
31  /**
32   * @author fgiust
33   * @version $Id: TldItem.java 217 2014-08-15 20:50:32Z fgiust $
34   */
35  public class TldItem implements Comparable<TldItem>
36  {
37  
38      private String name;
39  
40      private String description;
41  
42      private String example;
43  
44      private boolean deprecated;
45  
46      public String getName()
47      {
48          return this.name;
49      }
50  
51      public void setName(String tagName)
52      {
53          this.name = tagName;
54      }
55  
56      public String getDescription()
57      {
58          return this.description;
59      }
60  
61      public void setDescription(String description)
62      {
63          this.description = description;
64      }
65  
66      public String getExample()
67      {
68          return this.example;
69      }
70  
71      public void setExample(String example)
72      {
73          this.example = example;
74      }
75  
76      public boolean isDeprecated()
77      {
78          return this.deprecated;
79      }
80  
81      public void setDeprecated(boolean deprecated)
82      {
83          this.deprecated = deprecated;
84      }
85  
86      /**
87       * @see java.lang.Comparable#compareTo(Object)
88       */
89      public int compareTo(TldItem object)
90      {
91          if(object == this)
92          {
93              return 0;
94          }
95  
96          if(object.getClass() != getClass())
97          {
98              throw new ClassCastException("compareTo with different classes: " +
99                  this.getClass().getName() +
100                 " <> " +
101                 object.getClass().getName());
102         }
103 
104         return new CompareToBuilder()
105             .append(this.deprecated, object.deprecated)
106             .append(this.name, object.name)
107             .toComparison();
108     }
109 
110     /**
111      * @see java.lang.Object#equals(Object)
112      */
113     @Override
114     public boolean equals(Object obj)
115     {
116         if(obj == null)
117         {
118             return false;
119         }
120 
121         if(obj == this)
122         {
123             return true;
124         }
125 
126         if(obj.getClass() != getClass())
127         {
128             return false;
129         }
130 
131         TldItem rhs = (TldItem) obj;
132         return new EqualsBuilder()
133                 .append(this.deprecated, rhs.deprecated)
134                 .append(this.name, rhs.name)
135                 .isEquals();
136       }
137 
138     /**
139      * @see java.lang.Object#hashCode()
140      */
141     @Override
142     public int hashCode() {
143         return new HashCodeBuilder()
144                 .append(this.deprecated)
145                 .append(this.name)
146                 .toHashCode();
147       }
148 }