Coverage Report - org.dozer.cache.CacheEntry
 
Classes in this File Line Coverage Branch Coverage Complexity
CacheEntry
78%
11/14
50%
2/4
1.667
 
 1  
 /**
 2  
  * Copyright 2005-2013 Dozer Project
 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 org.dozer.cache;
 17  
 
 18  
 import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
 19  
 import org.apache.commons.lang3.builder.ToStringStyle;
 20  
 
 21  
 /**
 22  
  * Internal class that represents one entry in the cache. Holds the cache value, unique key for lookup, and creation
 23  
  * time. Only intended for internal use.
 24  
  * 
 25  
  * @author tierney.matt
 26  
  * @author dmitry.buzdin
 27  
  */
 28  
 public class CacheEntry<KeyType, ValueType> {
 29  
 
 30  
   private final KeyType key;
 31  
   private final ValueType value;
 32  
 
 33  3911
   public CacheEntry(KeyType key, ValueType value) {
 34  3911
     this.key = key;
 35  3911
     this.value = value;
 36  3911
   }
 37  
 
 38  
   public KeyType getKey() {
 39  3913
     return key;
 40  
   }
 41  
 
 42  
   public ValueType getValue() {
 43  300423
     return value;
 44  
   }
 45  
 
 46  
   @Override
 47  
   public int hashCode() {
 48  2
     return key.hashCode();
 49  
   }
 50  
 
 51  
   @Override
 52  
   public boolean equals(Object object) {
 53  1
     if ((this == object)) {
 54  0
       return true;
 55  
     }
 56  1
     if (!(object instanceof CacheEntry)) {
 57  0
       return false;
 58  
     }
 59  1
     CacheEntry entry = (CacheEntry) object;
 60  1
     return this.getKey().equals(entry.getKey());
 61  
   }
 62  
 
 63  
   @Override
 64  
   public String toString() {
 65  0
     return ReflectionToStringBuilder.toString(this, ToStringStyle.MULTI_LINE_STYLE);
 66  
   }
 67  
 
 68  
 }