private boolean writeData(CacheLine line, Persistable object) {
if (object.size() > maxItemSize)
throw new IllegalArgumentException("Object size is " + object.size() + " bytes and exceeds the limit of " + maxItemSize + " bytes: " + object);
if (compareBeforeWrite) {
final Checksum chksm = getChecksum();
if (line.data != null && object.size() == line.data.remaining()) {
final int n = line.data.remaining();
chksm.update(line.data);
line.data.rewind();
final byte[] hash = chksm.getChecksum();
object.write(line.data);
line.data.flip();
chksm.reset();
chksm.update(line.data);
line.data.rewind();
if (!Arrays.equals(hash, chksm.getChecksum()))
return true;
return false;
}
}