1 4 package com.tcsimulator.distrunner; 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 ServerSpecImpl implements ServerSpec { 14 15 private final String hostname; 16 private final String testHome; 17 private final int hashCode; 18 private final List jvmOpts; 19 private final int cache; 20 private final int jmxPort; 21 private final int dsoPort; 22 private final int type; 23 24 public ServerSpecImpl(String hostname, String testHome, int cache, int jmxPort, int dsoPort, List jvmOpts, int type) { 25 if (hostname == null) throw new AssertionError (); 26 if (testHome == null) throw new AssertionError (); 27 this.hostname = hostname; 28 this.testHome = testHome; 29 this.cache = cache; 30 this.jmxPort = jmxPort; 31 this.dsoPort = dsoPort; 32 this.jvmOpts = jvmOpts; 33 this.type = type; 34 this.hashCode = new HashCodeBuilder(17, 37).append(hostname).append(testHome).append(cache).append(jmxPort) 35 .append(dsoPort).append(jvmOpts).append(type).toHashCode(); 36 } 37 38 public boolean isNull() { 39 return false; 40 } 41 42 public String getHostName() { 43 return this.hostname; 44 } 45 46 public String getTestHome() { 47 return this.testHome; 48 } 49 50 public boolean equals(Object o) { 51 if (o instanceof ServerSpecImpl) { 52 ServerSpecImpl cmp = (ServerSpecImpl) o; 53 return hostname.equals(cmp.hostname) && testHome.equals(cmp.testHome) && cache == cmp.cache 54 && jmxPort == cmp.jmxPort && dsoPort == cmp.dsoPort && jvmOpts.equals(cmp.jvmOpts); 55 } 56 return false; 57 } 58 59 public int hashCode() { 60 return this.hashCode; 61 } 62 63 public String toString() { 64 return ArgParser.getArgumentForServerSpec(this); 65 } 66 67 public List getJvmOpts() { 68 return new ArrayList (jvmOpts); 69 } 70 71 public int getCache() { 72 return cache; 73 } 74 75 public int getJmxPort() { 76 return jmxPort; 77 } 78 79 public int getDsoPort() { 80 return dsoPort; 81 } 82 83 public ServerSpec copy() { 84 return new ServerSpecImpl(hostname, testHome, cache, jmxPort, dsoPort, new ArrayList (jvmOpts), type); 85 } 86 87 public int getType() { 88 return type; 89 } 90 91 } 92 | Popular Tags |