io.ebeaninternal.server.transaction.RemoteTableMod Maven / Gradle / Ivy
package io.ebeaninternal.server.transaction;
import io.ebeaninternal.api.BinaryReadContext;
import io.ebeaninternal.api.BinaryWritable;
import io.ebeaninternal.api.BinaryWriteContext;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.LinkedHashSet;
import java.util.Set;
public final class RemoteTableMod implements BinaryWritable {
private final long timestamp;
private final Set tables;
public RemoteTableMod(Set tables) {
this.tables = tables;
this.timestamp = System.currentTimeMillis();
}
private RemoteTableMod(long timestamp, Set tables) {
this.timestamp = timestamp;
this.tables = tables;
}
@Override
public String toString() {
return "TableMod " + timestamp + "; " + tables;
}
public long getTimestamp() {
return timestamp;
}
public Set getTables() {
return tables;
}
public static RemoteTableMod readBinaryMessage(BinaryReadContext dataInput) throws IOException {
long timestamp = dataInput.readLong();
int count = dataInput.readInt();
Set tables = new LinkedHashSet<>();
for (int i = 0; i < count; i++) {
tables.add(dataInput.readUTF());
}
return new RemoteTableMod(timestamp, tables);
}
@Override
public void writeBinary(BinaryWriteContext out) throws IOException {
DataOutputStream os = out.start(TYPE_TABLEMOD);
os.writeLong(timestamp);
os.writeInt(tables.size());
for (String table : tables) {
os.writeUTF(table);
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy