1 16 package net.sf.dozer.util.mapping.stats; 17 18 import java.io.Serializable ; 19 20 import org.apache.commons.lang.builder.EqualsBuilder; 21 import org.apache.commons.lang.builder.HashCodeBuilder; 22 import org.apache.commons.lang.builder.ReflectionToStringBuilder; 23 import org.apache.commons.lang.builder.ToStringStyle; 24 25 28 public class StatisticEntry implements Serializable { 29 private final Object key; 30 private long value = 0; 31 32 public StatisticEntry(Object key) { 33 this.key = key; 34 } 35 36 public Object getKey() { 37 return key; 38 } 39 40 public long getValue() { 41 return value; 42 } 43 44 public void increment() { 45 increment(1); 46 } 47 48 public synchronized void increment(long value) { 49 this.value += value; 50 } 51 52 public boolean equals(Object object) { 53 if ( (this == object ) ) { return true; } 54 if ( !(object instanceof StatisticEntry) ) { return false; } 55 StatisticEntry entry = (StatisticEntry) object; 56 return new EqualsBuilder().append(this.getKey(), entry.getKey()).isEquals(); 57 } 58 59 public int hashCode() { 60 return new HashCodeBuilder().append(getKey()).toHashCode(); 61 } 62 63 public String toString() { 64 return ReflectionToStringBuilder.toString(this, ToStringStyle.MULTI_LINE_STYLE); 65 } 66 } 67 | Popular Tags |