KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tcsimulator > ClientSpecImpl


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tcsimulator;
5
6 import org.apache.commons.lang.builder.HashCodeBuilder;
7
8 import com.tc.simulator.distrunner.ArgParser;
9
10 import java.util.ArrayList JavaDoc;
11 import java.util.List JavaDoc;
12
13 public class ClientSpecImpl implements ClientSpec {
14
15   private final int hashCode;
16   private final String JavaDoc hostname;
17   private final String JavaDoc testHome;
18   private final int vmCount;
19   private final int executionCount;
20   private final List JavaDoc jvmOpts;
21
22   public ClientSpecImpl(String JavaDoc hostname, String JavaDoc testHome, int vmCount, int executionCount, List JavaDoc jvmOpts) {
23     if (hostname == null) throw new AssertionError JavaDoc();
24     if (testHome == null) throw new AssertionError JavaDoc();
25     this.hostname = hostname;
26     this.testHome = testHome;
27     this.vmCount = vmCount;
28     this.executionCount = executionCount;
29     this.jvmOpts = jvmOpts;
30     this.hashCode = new HashCodeBuilder(17, 37).append(hostname).append(testHome).append(vmCount)
31         .append(executionCount).append(jvmOpts).toHashCode();
32   }
33
34   public String JavaDoc getHostName() {
35     return hostname;
36   }
37
38   public String JavaDoc getTestHome() {
39     return testHome;
40   }
41
42   public int getVMCount() {
43     return vmCount;
44   }
45
46   public int getExecutionCount() {
47     return executionCount;
48   }
49
50   public List JavaDoc getJvmOpts() {
51     return new ArrayList JavaDoc(jvmOpts);
52   }
53
54   public boolean equals(Object JavaDoc o) {
55     if (o instanceof ClientSpecImpl) {
56       ClientSpecImpl cmp = (ClientSpecImpl) o;
57       return hostname.equals(cmp.hostname) && testHome.equals(cmp.testHome) && vmCount == cmp.vmCount
58              && executionCount == cmp.executionCount && jvmOpts.equals(cmp.jvmOpts);
59     }
60     return false;
61   }
62
63   public int hashCode() {
64     return hashCode;
65   }
66
67   public String JavaDoc toString() {
68     return ArgParser.getArgumentForClientSpec(this);
69   }
70
71   public ClientSpec copy() {
72     return new ClientSpecImpl(this.hostname, this.testHome, this.vmCount, this.executionCount, new ArrayList JavaDoc(jvmOpts));
73   }
74 }
75
Popular Tags