1package autotest.afe.models; 2 3import autotest.common.Utils; 4 5import com.google.gwt.json.client.JSONObject; 6 7public class Host extends JSONObject { 8 public static Host fromJsonObject(JSONObject object) { 9 assert object.containsKey("hostname"); 10 Host host = new Host(); 11 Utils.updateObject(host, object); 12 return host; 13 } 14 15 @Override 16 public boolean equals(Object other) { 17 if (!(other instanceof Host)) { 18 return false; 19 } 20 21 Host otherHost = (Host) other; 22 return otherHost.getHostname().equals(getHostname()); 23 } 24 25 @Override 26 public int hashCode() { 27 return getHostname().hashCode(); 28 } 29 30 public String getHostname() { 31 return Utils.jsonToString(get("hostname")); 32 } 33} 34