| 1 |
package org.apache.commons.jcs3.auxiliary.disk; |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
import java.util.Objects; |
| 23 |
|
| 24 |
import org.apache.commons.jcs3.engine.CacheElement; |
| 25 |
import org.apache.commons.jcs3.engine.behavior.ICacheElement; |
| 26 |
import org.apache.commons.jcs3.engine.behavior.IElementAttributes; |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
public class PurgatoryElement<K, V> |
| 35 |
extends CacheElement<K, V> |
| 36 |
|
| 37 |
{ |
| 38 |
|
| 39 |
private static final long serialVersionUID = -8152034342684135628L; |
| 40 |
|
| 41 |
|
| 42 |
private boolean spoolable; |
| 43 |
|
| 44 |
|
| 45 |
private final ICacheElement<K, V> cacheElement; |
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
public PurgatoryElement( final ICacheElement<K, V> cacheElement ) |
| 53 |
{ |
| 54 |
super(cacheElement.getCacheName(), cacheElement.getKey(), cacheElement.getVal()); |
| 55 |
this.cacheElement = cacheElement; |
| 56 |
} |
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
public boolean isSpoolable() |
| 64 |
{ |
| 65 |
return spoolable; |
| 66 |
} |
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
public void setSpoolable( final boolean spoolable ) |
| 74 |
{ |
| 75 |
this.spoolable = spoolable; |
| 76 |
} |
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
public ICacheElement<K, V> getCacheElement() |
| 84 |
{ |
| 85 |
return cacheElement; |
| 86 |
} |
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
@Override |
| 95 |
public String getCacheName() |
| 96 |
{ |
| 97 |
return cacheElement.getCacheName(); |
| 98 |
} |
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
@Override |
| 105 |
public K getKey() |
| 106 |
{ |
| 107 |
return cacheElement.getKey(); |
| 108 |
} |
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
@Override |
| 115 |
public V getVal() |
| 116 |
{ |
| 117 |
return cacheElement.getVal(); |
| 118 |
} |
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
@Override |
| 125 |
public IElementAttributes getElementAttributes() |
| 126 |
{ |
| 127 |
return cacheElement.getElementAttributes(); |
| 128 |
} |
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
@Override |
| 135 |
public void setElementAttributes( final IElementAttributes attr ) |
| 136 |
{ |
| 137 |
cacheElement.setElementAttributes( attr ); |
| 138 |
} |
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
@Override |
| 145 |
public boolean equals(final Object obj) |
| 146 |
{ |
| 147 |
if (this == obj) |
| 148 |
{ |
| 149 |
return true; |
| 150 |
} |
| 151 |
if (!(obj instanceof PurgatoryElement)) |
| 152 |
{ |
| 153 |
return false; |
| 154 |
} |
| 155 |
final PurgatoryElement<?,?> other = (PurgatoryElement<?,?>) obj; |
| 156 |
return Objects.equals(getKey(), other.getKey()); |
| 157 |
} |
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
@Override |
| 163 |
public int hashCode() |
| 164 |
{ |
| 165 |
return getKey().hashCode(); |
| 166 |
} |
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
@Override |
| 172 |
public String toString() |
| 173 |
{ |
| 174 |
final StringBuilder buf = new StringBuilder(); |
| 175 |
buf.append( "[PurgatoryElement: " ); |
| 176 |
buf.append( " isSpoolable = " + isSpoolable() ); |
| 177 |
buf.append( " CacheElement = " + getCacheElement() ); |
| 178 |
buf.append( " CacheName = " + getCacheName() ); |
| 179 |
buf.append( " Key = " + getKey() ); |
| 180 |
buf.append( " Value = " + getVal() ); |
| 181 |
buf.append( " ElementAttributes = " + getElementAttributes() ); |
| 182 |
buf.append( "]" ); |
| 183 |
return buf.toString(); |
| 184 |
} |
| 185 |
} |