Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
CheckItem |
|
| 1.1333333333333333;1.133 |
1 | /* $Id: CheckItem.java 17814 2010-01-12 18:33:50Z linus $ | |
2 | ***************************************************************************** | |
3 | * Copyright (c) 2009 Contributors - see below | |
4 | * All rights reserved. This program and the accompanying materials | |
5 | * are made available under the terms of the Eclipse Public License v1.0 | |
6 | * which accompanies this distribution, and is available at | |
7 | * http://www.eclipse.org/legal/epl-v10.html | |
8 | * | |
9 | * Contributors: | |
10 | * linus | |
11 | ***************************************************************************** | |
12 | * | |
13 | * Some portions of this file was previously release using the BSD License: | |
14 | */ | |
15 | ||
16 | // Copyright (c) 1996-2006 The Regents of the University of California. All | |
17 | // Rights Reserved. Permission to use, copy, modify, and distribute this | |
18 | // software and its documentation without fee, and without a written | |
19 | // agreement is hereby granted, provided that the above copyright notice | |
20 | // and this paragraph appear in all copies. This software program and | |
21 | // documentation are copyrighted by The Regents of the University of | |
22 | // California. The software program and documentation are supplied "AS | |
23 | // IS", without any accompanying services from The Regents. The Regents | |
24 | // does not warrant that the operation of the program will be | |
25 | // uninterrupted or error-free. The end-user understands that the program | |
26 | // was developed for research purposes and is advised not to rely | |
27 | // exclusively on the program for any reason. IN NO EVENT SHALL THE | |
28 | // UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, | |
29 | // SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, | |
30 | // ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF | |
31 | // THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF | |
32 | // SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY | |
33 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | |
34 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE | |
35 | // PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF | |
36 | // CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT, | |
37 | // UPDATES, ENHANCEMENTS, OR MODIFICATIONS. | |
38 | ||
39 | package org.argouml.cognitive.checklist; | |
40 | ||
41 | import java.io.Serializable; | |
42 | ||
43 | import org.argouml.util.Predicate; | |
44 | import org.argouml.util.PredicateTrue; | |
45 | ||
46 | ||
47 | /** | |
48 | * This class defines an item that can be placed on a Checklist. | |
49 | * This is a short piece of text to prompt the designer to think of a | |
50 | * specific design issue. CheckItems are similar to critics in that | |
51 | * they are categorized to be relevant to issues the designer is | |
52 | * interested in, they have a guarding condition that returns true if | |
53 | * the CheckItem should be presented, and they have a piece of text | |
54 | * as design feedback. They are different in that their predicate is | |
55 | * almost always the constant 'true', and the feedback they provide | |
56 | * is much simpler. | |
57 | * | |
58 | * CheckItems are part of Checklists. And Checklists are registered | |
59 | * with the CheckManager. | |
60 | * | |
61 | * If you have a piece of advice you would like to give a designer, | |
62 | * you can implement it as a CheckItem _very_ easily. If you can | |
63 | * formalize the advice more, you can implement it as a Critic. | |
64 | * | |
65 | * @see Checklist | |
66 | * @see CheckManager | |
67 | * @author jrobbins | |
68 | */ | |
69 | public class CheckItem implements Serializable { | |
70 | ||
71 | private String category; | |
72 | ||
73 | /** | |
74 | * One sentence description of the issue. usually in the form of a | |
75 | * question. | |
76 | */ | |
77 | private String description; | |
78 | ||
79 | /** | |
80 | * URL for background (textbook?) knowledge about the domain. | |
81 | */ | |
82 | 180000 | private String moreInfoURL = "http://argouml.tigris.org/"; |
83 | ||
84 | /** | |
85 | * The predicate is the condition under which | |
86 | * the checkitem should be listed. | |
87 | */ | |
88 | 180000 | private Predicate predicate = PredicateTrue.getInstance(); |
89 | ||
90 | ||
91 | /** | |
92 | * The constructor. | |
93 | * | |
94 | * @param c the category | |
95 | * @param d the description | |
96 | */ | |
97 | 180000 | public CheckItem(String c, String d) { |
98 | 180000 | setCategory(c); |
99 | 180000 | setDescription(d); |
100 | 180000 | } |
101 | ||
102 | /** | |
103 | * The constructor. | |
104 | * | |
105 | * @param c the category | |
106 | * @param d the description | |
107 | * @param m the more-info-url | |
108 | * @param p the predicate | |
109 | */ | |
110 | public CheckItem(String c, String d, String m, | |
111 | Predicate p) { | |
112 | 0 | this(c, d); |
113 | 0 | setMoreInfoURL(m); |
114 | 0 | predicate = p; |
115 | 0 | } |
116 | ||
117 | /** | |
118 | * @return the category | |
119 | */ | |
120 | 0 | public String getCategory() { return category; } |
121 | ||
122 | /** | |
123 | * @param c the category | |
124 | */ | |
125 | 180000 | public void setCategory(String c) { category = c; } |
126 | ||
127 | /** | |
128 | * @return the description | |
129 | */ | |
130 | 0 | public String getDescription() { return description; } |
131 | ||
132 | /** | |
133 | * @param dm the design material | |
134 | * @return the description | |
135 | */ | |
136 | public String getDescription(Object dm) { | |
137 | 0 | return expand(description, dm); |
138 | } | |
139 | /** | |
140 | * @param d the description | |
141 | */ | |
142 | 180000 | public void setDescription(String d) { description = d; } |
143 | ||
144 | /** | |
145 | * @return the more-info-url | |
146 | */ | |
147 | 0 | public String getMoreInfoURL() { return moreInfoURL; } |
148 | ||
149 | /** | |
150 | * @param m the more-info-url | |
151 | */ | |
152 | 0 | public void setMoreInfoURL(String m) { moreInfoURL = m; } |
153 | ||
154 | /** | |
155 | * @return the predicate | |
156 | */ | |
157 | public Predicate getPredicate2() { | |
158 | 0 | return predicate; |
159 | } | |
160 | ||
161 | /** | |
162 | * @param p the predicate | |
163 | */ | |
164 | public void setPredicate(Predicate p) { | |
165 | 0 | predicate = p; |
166 | 0 | } |
167 | ||
168 | /* | |
169 | * @see java.lang.Object#hashCode() | |
170 | */ | |
171 | @Override | |
172 | public int hashCode() { | |
173 | 0 | return getDescription().hashCode(); |
174 | } | |
175 | ||
176 | /* | |
177 | * @see java.lang.Object#equals(java.lang.Object) | |
178 | */ | |
179 | @Override | |
180 | public boolean equals(Object o) { | |
181 | 0 | if (!(o instanceof CheckItem)) { |
182 | 0 | return false; |
183 | } | |
184 | 0 | CheckItem i = (CheckItem) o; |
185 | 0 | return getDescription().equals(i.getDescription()); |
186 | } | |
187 | ||
188 | /* | |
189 | * @see java.lang.Object#toString() | |
190 | */ | |
191 | @Override | |
192 | 0 | public String toString() { return getDescription(); } |
193 | ||
194 | /** | |
195 | * Customize/expand the description string just before it is displayed. | |
196 | * I.e. add offender specific information to the description string | |
197 | * (e.g. its name). | |
198 | * | |
199 | * @param desc the description | |
200 | * @param dm the design material | |
201 | * @return the description | |
202 | */ | |
203 | 0 | public String expand(String desc, Object dm) { return desc; } |
204 | ||
205 | } |