KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > dozer > util > mapping > cache > CacheEntry


1 /*
2  * Copyright 2005-2007 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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  * @author tierney.matt
24  */

25 public class CacheEntry {
26   private final Object JavaDoc key;
27   private final Object JavaDoc value;
28   private final long creationTime;
29
30   public CacheEntry(Object JavaDoc key, Object JavaDoc value) {
31     this.key = key;
32     this.value = value;
33     this.creationTime = System.currentTimeMillis();
34   }
35
36   public Object JavaDoc getKey() {
37     return key;
38   }
39
40   public Object JavaDoc getValue() {
41     return value;
42   }
43
44   public long getCreationTime() {
45     return creationTime;
46   }
47
48   public int hashCode() {
49     return key.hashCode();
50   }
51   
52   public boolean equals(Object JavaDoc object) {
53     if ( (this == object ) ) { return true; }
54     if ( !(object instanceof CacheEntry) ) { return false; }
55     CacheEntry entry = (CacheEntry) object;
56     return new EqualsBuilder().append(this.getKey(), entry.getKey()).isEquals();
57   }
58   
59   public String JavaDoc toString() {
60     return ReflectionToStringBuilder.toString(this, ToStringStyle.MULTI_LINE_STYLE);
61   }
62 }
63
Popular Tags