1 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 ; 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, int vmCount, int executionCount, List jvmOpts) { 23 if (hostname == null) throw new AssertionError (); 24 if (testHome == null) throw new AssertionError (); 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 getHostName() { 35 return hostname; 36 } 37 38 public String 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 getJvmOpts() { 51 return new ArrayList (jvmOpts); 52 } 53 54 public boolean equals(Object 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 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 (jvmOpts)); 73 } 74 } 75
| Popular Tags
|