1 //$Id: HintTypes.java 206 2005-12-11 17:45:24Z jg_hamburg $
2 /********************************************************************************
3 * DDTUnit, a Datadriven Approach to Unit- and Moduletesting
4 * Copyright (c) 2004, Joerg and Kai Gellien
5 * All rights reserved.
6 *
7 * The Software is provided under the terms of the Common Public License 1.0
8 * as provided with the distribution of DDTUnit in the file cpl-v10.html.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 *
13 * + Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 *
16 * + Redistributions in binary form must reproduce the above
17 * copyright notice, this list of conditions and the following
18 * disclaimer in the documentation and/or other materials provided
19 * with the distribution.
20 *
21 * + Neither the name of the authors or DDTUnit, nor the
22 * names of its contributors may be used to endorse or promote
23 * products derived from this software without specific prior
24 * written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
29 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
30 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 ********************************************************************************/
38 package junitx.ddtunit.data.processing;
39
40 /**
41 * Typesafe enumeration class containing all supported hint values used in xml
42 * data resource by xml attribute hint.
43 *
44 * @author jg
45 */
46 class HintTypes {
47 /**
48 * FIELDS hint specifies all classes that can be created by using
49 * reflection.
50 */
51 public final static HintTypes FIELDS = new HintTypes("fields");
52
53 /**
54 * Collection hint specifies all classes that can are implementations of
55 * <code>java.util.Collection</code> interface and have an appropriate
56 * list or set character.
57 */
58 public final static HintTypes COLLECTION = new HintTypes("collection");
59
60 /**
61 * Collection hint specifies all classes that can are implementations of
62 * <code>java.util.Collection</code> interface and have an appropriate
63 * list or set character.
64 */
65 public final static HintTypes MAP = new HintTypes("map");
66
67 /**
68 * Signature hint specifies a <code>java.util.List</code> that will be
69 * used for method invokation
70 */
71 public final static HintTypes ATTRLIST = new HintTypes("attrlist");
72
73 /**
74 * Constructor hint specifies the creation of objects.
75 */
76 public final static HintTypes CONSTRUCTOR = new HintTypes("constructor");
77
78 /**
79 * Constant hint specifies the use of a static field of specified class.
80 */
81 public static final HintTypes CONSTANT = new HintTypes("constant");
82
83 /**
84 * Date hint specifies the use of a static field of specified class.
85 */
86 public static final HintTypes DATE = new HintTypes("date");
87
88 /**
89 * Bean hint specifies the use of java bean based setter methods to populate
90 * fields
91 */
92 public static final HintTypes BEAN = new HintTypes("bean");
93
94 /**
95 * Array hint specifies the use of Object[] arrays
96 */
97 public static final HintTypes ARRAY = new HintTypes("array");
98
99 public static final HintTypes INTERNAL_MAPENTRY = new HintTypes("mapentry");
100
101 public static final HintTypes CONTENT = new HintTypes("content");
102
103 public static final HintTypes CALL = new HintTypes("call");
104
105 private String hint;
106
107 private HintTypes(String hint) {
108 this.hint = hint;
109 }
110
111 /**
112 * Returns <code>true</code> if this <code>HintTypes</code> is the same
113 * as the oobj argument.
114 *
115 * @return <code>true</code> if this <code>HintTypes</code> is the same
116 * as the obj argument.
117 */
118 public boolean equals(Object obj) {
119 boolean checked = false;
120 if (this == obj) {
121 checked = true;
122 } else if (obj == null) {
123 checked = false;
124 } else if (this.toString().equals(obj)) {
125 checked = true;
126 } else if (obj.getClass() != getClass()) {
127 checked = false;
128 } else {
129 HintTypes castedObj = (HintTypes) obj;
130 checked = ((this.hint == null ? castedObj.hint == null : this.hint
131 .equals(castedObj.hint)));
132 }
133 return checked;
134 }
135
136 public String toString() {
137 return this.hint;
138 }
139
140 /**
141 * Override hashCode.
142 *
143 * @return the Objects hashcode.
144 */
145 public int hashCode() {
146 int hashCode = 1;
147 hashCode = 31 * hashCode + (hint == null ? 0 : hint.hashCode());
148 return hashCode;
149 }
150 }