org.hibernate.cache.infinispan.util.FutureUpdate Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hibernate-infinispan
Show all versions of hibernate-infinispan
A module of the Hibernate Core project
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or .
*/
package org.hibernate.cache.infinispan.util;
import org.infinispan.commons.marshall.AdvancedExternalizer;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.util.Collections;
import java.util.Set;
import java.util.UUID;
/**
* Request to update the tombstone, coming from insert/update/remove operation.
*
* This object should *not* be stored in cache.
*
* @author Radim Vansa <[email protected]>
*/
public class FutureUpdate {
private final UUID uuid;
private final long timestamp;
private final Object value;
public FutureUpdate(UUID uuid, long timestamp, Object value) {
this.uuid = uuid;
this.timestamp = timestamp;
this.value = value;
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder("FutureUpdate{");
sb.append("uuid=").append(uuid);
sb.append(", timestamp=").append(timestamp);
sb.append(", value=").append(value);
sb.append('}');
return sb.toString();
}
public UUID getUuid() {
return uuid;
}
public Object getValue() {
return value;
}
public long getTimestamp() {
return timestamp;
}
public static class Externalizer implements AdvancedExternalizer {
@Override
public void writeObject(ObjectOutput output, FutureUpdate object) throws IOException {
output.writeLong(object.uuid.getMostSignificantBits());
output.writeLong(object.uuid.getLeastSignificantBits());
output.writeLong(object.timestamp);
output.writeObject(object.value);
}
@Override
public FutureUpdate readObject(ObjectInput input) throws IOException, ClassNotFoundException {
long msb = input.readLong();
long lsb = input.readLong();
long timestamp = input.readLong();
Object value = input.readObject();
return new FutureUpdate(new UUID(msb, lsb), timestamp, value);
}
@Override
public Set> getTypeClasses() {
return Collections.>singleton(FutureUpdate.class);
}
@Override
public Integer getId() {
return Externalizers.FUTURE_UPDATE;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy