# Coverage details for edu.uci.ics.jung.graph.predicates.UserDatumEdgePredicate

Line | Hits | Source
--- | --- | ---
1 |  | `/*`
2 |  | `* Created on Mar 17, 2004`
3 |  | `*`
4 |  | `* Copyright (c) 2003, the JUNG Project and the Regents of the University`
5 |  | `* of California`
6 |  | `* All rights reserved.`
7 |  | `*`
8 |  | `* This software is open-source under the BSD license; see either`
9 |  | `* "license.txt" or`
10 |  | `* http://jung.sourceforge.net/license.txt for a description.`
11 |  | `*/`
12 |  | `package edu.uci.ics.jung.graph.predicates;`
13 |  | ``
14 |  | `import edu.uci.ics.jung.graph.ArchetypeEdge;`
15 |  | ``
16 |  | ``
17 |  | `/**`
18 |  | `* A predicate that checks to see whether an edge's user`
19 |  | `* data repository contains`
20 |  | `* the constructor-specified (key,datum) pair. This predicate`
21 |  | `* may be used as a constraint.`
22 |  | `*/`
23 |  | `public class UserDatumEdgePredicate extends EdgePredicate`
24 |  | `{`
25 |  | `public static final String message = "UserDatumEdgePredicate: ";`
26 |  | `private Object datum;`
27 |  | `private Object key;`
28 |  | ``
29 |  | `public UserDatumEdgePredicate(Object key, Object datum)`
30 | 3 | `{`
31 | 3 | `if (key == null)`
32 | 0 | `throw new IllegalArgumentException("UserDatumEdgePredicate " +`
33 |  | `"key must be non-null");`
34 | 3 | `this.datum = datum;`
35 | 3 | `this.key = key;`
36 | 3 | `}`
37 |  | ``
38 |  | `/**`
39 |  | `* Returns <code>true</code> if the datum stored by <code>e</code> with`
40 |  | `* key value <code>key</code> (in the user data repository) is`
41 |  | `* <code>datum</code>.`
42 |  | `*`
43 |  | `* @see edu.uci.ics.jung.utils.UserData`
44 |  | `*/`
45 |  | `public boolean evaluateEdge(ArchetypeEdge e)`
46 |  | `{`
47 | 23 | `Object value = e.getUserDatum(key);`
48 | 23 | `return ((datum == null && value == null) || datum.equals(value));`
49 |  | `// return (e.getUserDatum(key).equals(datum));`
50 |  | `}`
51 |  | ``
52 |  | `public String toString()`
53 |  | `{`
54 | 1 | `return message + "(" + key + ", " + datum + ")";`
55 |  | `}`
56 |  | ``
57 |  | `/**`
58 |  | `* Tests equality based on underlying objects`
59 |  | `*/`
60 |  | `public boolean equals( Object o ) {`
61 | 13 | `if (! (o instanceof UserDatumEdgePredicate))`
62 | 11 | `return false;`
63 | 2 | `UserDatumEdgePredicate udep = (UserDatumEdgePredicate) o;`
64 | 2 | `return ( udep.datum.equals( datum ) && udep.key.equals(key));`
65 |  | `}`
66 |  | ``
67 |  | `public int hashCode() {`
68 | 0 | `return datum.hashCode() + key.hashCode();`
69 |  | `}`
70 |  | ``
71 |  | `/**`
72 |  | `* Returns the user data key which partially defines this predicate.`
73 |  | `*/`
74 |  | `public Object getKey()`
75 |  | `{`
76 | 0 | `return key;`
77 |  | `}`
78 |  | ``
79 |  | `/**`
80 |  | `* Returns the user datum which partially defines this predicate.`
81 |  | `*/`
82 |  | `public Object getDatum()`
83 |  | `{`
84 | 0 | `return datum;`
85 |  | `}`
86 |  | `}`

this report was generated by version 1.0.5 of jcoverage. visit www.jcoverage.com for updates. | copyright © 2003, jcoverage ltd. all rights reserved. Java is a trademark of Sun Microsystems, Inc. in the United States and other countries.