skadistats.clarity.model.state.EntityState Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of clarity Show documentation
Show all versions of clarity Show documentation
Clarity is an open source replay parser for Dota 2, CSGO, CS2 and Deadlock written in Java.
package skadistats.clarity.model.state;
import skadistats.clarity.model.FieldPath;
import skadistats.clarity.util.TextTable;
import java.util.Iterator;
import java.util.function.Function;
public interface EntityState {
EntityState copy();
// returns true if capacity has changed
boolean setValueForFieldPath(FieldPath fp, Object value);
T getValueForFieldPath(FieldPath fp);
Iterator fieldPathIterator();
default String dump(String title, Function nameResolver) {
final var table = new TextTable.Builder()
.setFrame(TextTable.FRAME_COMPAT)
.addColumn("FP")
.addColumn("Property")
.addColumn("Value")
.setTitle(title)
.build();
var i = 0;
final var iter = fieldPathIterator();
while (iter.hasNext()) {
var fp = iter.next();
table.setData(i, 0, fp);
table.setData(i, 1, nameResolver.apply(fp));
table.setData(i, 2, getValueForFieldPath(fp));
i++;
}
return table.toString();
}
}