1 18 package org.osgi.util.measurement; 19 20 32 public class State { 33 final int value; 34 final long time; 35 final String name; 36 37 45 public State(int value, String name, long time) { 46 this.value = value; 47 this.name = name; 48 this.time = time; 49 } 50 51 57 public State(int value, String name) { 58 this(value, name, 0); 59 } 60 61 66 public final int getValue() { 67 return value; 68 } 69 70 76 public final long getTime() { 77 return time; 78 } 79 80 85 public final String getName() { 86 return name; 87 } 88 89 94 public String toString() { 95 StringBuffer sb = new StringBuffer (); 96 sb.append(value); 97 if (name != null) { 98 sb.append(" \""); 99 sb.append(name); 100 sb.append("\""); 101 } 102 return (sb.toString()); 103 } 104 105 110 public int hashCode() { 111 int hash = value; 112 if (name != null) { 113 hash ^= name.hashCode(); 114 } 115 return hash; 116 } 117 118 126 public boolean equals(Object obj) { 127 if (this == obj) { 128 return true; 129 } 130 if (!(obj instanceof State)) { 131 return false; 132 } 133 State that = (State) obj; 134 if (value != that.value) { 135 return false; 136 } 137 if (name == that.name) { 138 return true; 139 } 140 if (name == null) { 141 return false; 142 } 143 return name.equals(that.name); 144 } 145 } 146 | Popular Tags |