1 // $Id: SimilarTypeListModelEntry.java 167 2009-05-29 17:43:07Z agony $
2 /*
3 * xsAnalyzer - XML schema analyzing tool. Copyright (C) 2008 Michael Engelhardt
4 *
5 * This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public
6 * License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later
7 * version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
10 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License along with this program; if not, write to the Free
13 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
14 */
15 /**
16 *
17 */
18 package de.mindcrimeilab.xsanalyzer.model;
19
20 import org.apache.commons.lang.builder.EqualsBuilder;
21 import org.apache.commons.lang.builder.HashCodeBuilder;
22 import org.apache.xerces.xs.XSObject;
23 import org.apache.xerces.xs.XSObjectList;
24
25 /**
26 * Represents an entry of the {@code SimilarTypesListModelAdapter}.
27 *
28 * @author Michael Engelhardt<me@mindcrime-ilab.de>
29 * @author $Author: agony $
30 * @version $Revision: 167 $
31 *
32 */
33 public class SimilarTypeListModelEntry {
34
35 /** Type */
36 private final XSObject type;
37
38 /** type signature as md5 hash */
39 private final String typeSignature;
40
41 /** list of types which are similar to the value of the {@code type} property. */
42 private final XSObjectList similarTypes;
43
44 /**
45 * ctor()
46 *
47 * @param type
48 * Type
49 * @param typeSignature
50 * signature of type
51 * @param similarTypes
52 * list of types which are similar to the type.
53 */
54 public SimilarTypeListModelEntry(XSObject type, String typeDescription, XSObjectList similarTypes) {
55 super();
56 this.type = type;
57 this.typeSignature = typeDescription;
58 this.similarTypes = similarTypes;
59 }
60
61 /*
62 * (non-Javadoc)
63 *
64 * @see java.lang.Object#equals(java.lang.Object)
65 */
66
67 /**
68 * Returns type.
69 *
70 * @return the type
71 */
72 public XSObject getType() {
73 return type;
74 }
75
76 /**
77 * Returns signature of type
78 *
79 * @return the typeSignature
80 */
81 public String getTypeSignature() {
82 return typeSignature;
83 }
84
85 /**
86 * Returns list of types which are similar to type
87 *
88 * @return the similarTypes
89 */
90 public XSObjectList getSimilarTypes() {
91 return similarTypes;
92 }
93
94 /*
95 * (non-Javadoc)
96 *
97 * @see java.lang.Object#equals(java.lang.Object)
98 */
99 @Override
100 public boolean equals(Object object) {
101 if (null == object) return false;
102 if (!(object instanceof SimilarTypeListModelEntry)) return false;
103 SimilarTypeListModelEntry other = (SimilarTypeListModelEntry) object;
104 return new EqualsBuilder().append(this.similarTypes, other.getSimilarTypes()).append(this.type, other.getType()).append(this.typeSignature, other.getTypeSignature()).isEquals();
105 }
106
107 /*
108 * (non-Javadoc)
109 *
110 * @see java.lang.Object#hashCode()
111 */
112 @Override
113 public int hashCode() {
114 return new HashCodeBuilder().append(this.similarTypes).append(this.type).append(this.typeSignature).toHashCode();
115 }
116
117 }