01: /*
02: * Copyright 2005-2007 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package net.sf.dozer.util.mapping.cache;
17:
18: import org.apache.commons.lang.builder.EqualsBuilder;
19: import org.apache.commons.lang.builder.ReflectionToStringBuilder;
20: import org.apache.commons.lang.builder.ToStringStyle;
21:
22: /**
23: * Internal class that represents one entry in the cache. Holds the cache value, unique key for lookup, and creation
24: * time. Only intended for internal use.
25: *
26: * @author tierney.matt
27: */
28: public class CacheEntry {
29: private final Object key;
30: private final Object value;
31: private final long creationTime;
32:
33: public CacheEntry(Object key, Object value) {
34: this .key = key;
35: this .value = value;
36: this .creationTime = System.currentTimeMillis();
37: }
38:
39: public Object getKey() {
40: return key;
41: }
42:
43: public Object getValue() {
44: return value;
45: }
46:
47: public long getCreationTime() {
48: return creationTime;
49: }
50:
51: public int hashCode() {
52: return key.hashCode();
53: }
54:
55: public boolean equals(Object object) {
56: if ((this == object)) {
57: return true;
58: }
59: if (!(object instanceof CacheEntry)) {
60: return false;
61: }
62: CacheEntry entry = (CacheEntry) object;
63: return new EqualsBuilder()
64: .append(this .getKey(), entry.getKey()).isEquals();
65: }
66:
67: public String toString() {
68: return ReflectionToStringBuilder.toString(this,
69: ToStringStyle.MULTI_LINE_STYLE);
70: }
71: }
|