Changeset 3161 for trunk/openmole/misc/org.openmole.misc.tools/src/main/java/org/openmole/misc/tools/structure/Counter.java
- Timestamp:
- 03/06/10 15:42:39 (2 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/openmole/misc/org.openmole.misc.tools/src/main/java/org/openmole/misc/tools/structure/Counter.java
r3149 r3161 22 22 * @author Romain Reuillon <romain.reuillon at openmole.org> 23 23 */ 24 public class Counter {24 public class Counter implements Comparable<Counter> { 25 25 26 intvalue;26 Integer value; 27 27 28 28 public Counter() { … … 42 42 } 43 43 44 public intgetValue() {44 public Integer getValue() { 45 45 return value; 46 46 } 47 47 48 public void increment( intval) {48 public void increment(Integer val) { 49 49 value+=val; 50 50 } … … 54 54 } 55 55 56 @Override 57 public String toString() { 58 return getValue().toString(); 59 } 60 61 @Override 62 public boolean equals(Object obj) { 63 if (obj == null) { 64 return false; 65 } 66 if (getClass() != obj.getClass()) { 67 return false; 68 } 69 final Counter other = (Counter) obj; 70 if (this.getValue() != other.getValue() && (this.getValue() == null || !this.getValue().equals(other.getValue()))) { 71 return false; 72 } 73 return true; 74 } 75 76 @Override 77 public int hashCode() { 78 int hash = this.getValue().hashCode(); 79 return hash; 80 } 81 82 83 84 public int compareTo(Counter intgr) { 85 return getValue().compareTo(intgr.getValue()); 86 } 87 88 89 90 91 56 92 }





