1 16 package cintoo.messages.context; 17 18 import api.cintoo.messages.context.Context; 19 20 30 public class IdContext implements Context { 31 32 private String id; 33 34 40 public static Context id(String id) { 41 return new IdContext(id); 42 } 43 44 49 public IdContext(String id) { 50 this.id = id; 51 } 52 53 59 public boolean matches(Context otherContext) { 60 if (!(otherContext instanceof IdContext)) return false; 61 return id.equals(((IdContext) otherContext).id); 62 } 63 64 72 public int compareTo(Object o) { 73 return 0; 74 } 75 76 public boolean equals(Object o) { 77 if (this == o) return true; 78 if (!(o instanceof IdContext)) return false; 79 80 final IdContext idContext = (IdContext) o; 81 82 if (id != null ? !id.equals(idContext.id) : idContext.id != null) return false; 83 84 return true; 85 } 86 87 public int hashCode() { 88 return id != null ? id.hashCode() : 0; 89 } 90 91 public String toString() { 92 return "<id:" + id + ">"; 93 } 94 } 95 | Popular Tags |