KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > apisupport > project > universe > TestModuleDependency


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.apisupport.project.universe;
21
22 import java.util.Comparator JavaDoc;
23
24 /**
25  * Represents one test dependency. I.e. <em>&lt;test-dependency&gt;</em>
26  * element in module's <em>project.xml</em>.
27  *
28  * @author pzajac
29  */

30 public class TestModuleDependency implements Comparable JavaDoc {
31     
32     public static final String JavaDoc UNIT = "unit"; // NOI18N
33
public static final String JavaDoc QA_FUNCTIONAL = "qa-functional"; // NOI18N
34

35     private final ModuleEntry module;
36     // depends also on tests of modules
37
private boolean test;
38     // depends on execution classpath of the modules
39
private boolean recursive;
40     // compilation dependency
41
private boolean compile;
42     
43     public static final Comparator JavaDoc CNB_COMPARATOR = new Comparator JavaDoc() {
44         public int compare(Object JavaDoc tmd1,Object JavaDoc tmd2) {
45             return ((TestModuleDependency)tmd1).module.getCodeNameBase().compareTo(((TestModuleDependency)tmd2).module.getCodeNameBase());
46         }
47     };
48     
49     /**
50      * Creates a new instance of TestModuleDependency
51      */

52     public TestModuleDependency(ModuleEntry me,boolean test,boolean recursive,boolean compile) {
53         this.module = me;
54         this.test = test;
55         this.recursive = recursive;
56         this.compile = compile;
57     }
58
59     public ModuleEntry getModule() {
60         return module;
61     }
62
63     public boolean isTest() {
64         return test;
65     }
66
67     public void setTest(boolean test) {
68         this.test = test;
69     }
70
71     public boolean isRecursive() {
72         return recursive;
73     }
74
75     public void setRecursive(boolean recursive) {
76         this.recursive = recursive;
77     }
78
79     public boolean isCompile() {
80         return compile;
81     }
82
83     public void setCompile(boolean compile) {
84         this.compile = compile;
85     }
86     
87     // td1 equals td2 iff cnb and all three boolean fileds of td are the same
88
public boolean equals(Object JavaDoc o){
89         if(o instanceof TestModuleDependency) {
90             TestModuleDependency tmd = (TestModuleDependency) o;
91             return tmd.isCompile() == this.isCompile()
92                     && tmd.isRecursive() == this.isRecursive()
93                     && tmd.isTest() == this.isTest()
94                     && tmd.getModule().getCodeNameBase().equals(this.getModule().getCodeNameBase());
95         } else {
96             return false;
97 }
98     }
99     
100     //compare only on cnb. ATTENTION, compareTo is not consistent with equals method!
101
//i.e. two instances of TestModuleDependency can be nonequal, and tmd1.compareTo(tmd2)
102
// can return 0
103
public int compareTo(Object JavaDoc o) {
104         TestModuleDependency tmd = (TestModuleDependency) o;
105         return this.module.getCodeNameBase().compareTo(tmd.module.getCodeNameBase());
106     }
107     
108     //hash from CNB only
109
public int hashCode(){
110         int hash = module.getCodeNameBase().hashCode();
111 // if(test) hash*=5;
112
// if(recursive) hash*=7;
113
// if(compile) hash*=11;
114
return hash;
115     }
116 }
117
Popular Tags