01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.tcsimulator;
05:
06: import org.apache.commons.lang.builder.HashCodeBuilder;
07:
08: import com.tc.simulator.distrunner.ArgParser;
09:
10: import java.util.ArrayList;
11: import java.util.List;
12:
13: public class ClientSpecImpl implements ClientSpec {
14:
15: private final int hashCode;
16: private final String hostname;
17: private final String testHome;
18: private final int vmCount;
19: private final int executionCount;
20: private final List jvmOpts;
21:
22: public ClientSpecImpl(String hostname, String testHome,
23: int vmCount, int executionCount, List jvmOpts) {
24: if (hostname == null)
25: throw new AssertionError();
26: if (testHome == null)
27: throw new AssertionError();
28: this .hostname = hostname;
29: this .testHome = testHome;
30: this .vmCount = vmCount;
31: this .executionCount = executionCount;
32: this .jvmOpts = jvmOpts;
33: this .hashCode = new HashCodeBuilder(17, 37).append(hostname)
34: .append(testHome).append(vmCount)
35: .append(executionCount).append(jvmOpts).toHashCode();
36: }
37:
38: public String getHostName() {
39: return hostname;
40: }
41:
42: public String getTestHome() {
43: return testHome;
44: }
45:
46: public int getVMCount() {
47: return vmCount;
48: }
49:
50: public int getExecutionCount() {
51: return executionCount;
52: }
53:
54: public List getJvmOpts() {
55: return new ArrayList(jvmOpts);
56: }
57:
58: public boolean equals(Object o) {
59: if (o instanceof ClientSpecImpl) {
60: ClientSpecImpl cmp = (ClientSpecImpl) o;
61: return hostname.equals(cmp.hostname)
62: && testHome.equals(cmp.testHome)
63: && vmCount == cmp.vmCount
64: && executionCount == cmp.executionCount
65: && jvmOpts.equals(cmp.jvmOpts);
66: }
67: return false;
68: }
69:
70: public int hashCode() {
71: return hashCode;
72: }
73:
74: public String toString() {
75: return ArgParser.getArgumentForClientSpec(this );
76: }
77:
78: public ClientSpec copy() {
79: return new ClientSpecImpl(this .hostname, this .testHome,
80: this .vmCount, this .executionCount, new ArrayList(
81: jvmOpts));
82: }
83: }
|