skadistats.clarity.io.s2.Serializer 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.io.s2;
public class Serializer {
private final SerializerId id;
private final Field[] fields;
private final String[] fieldNames;
public Serializer(SerializerId id, Field[] fields, String[] fieldNames) {
this.id = id;
this.fields = fields;
this.fieldNames = fieldNames;
}
public SerializerId getId() {
return id;
}
public int getFieldCount() {
return fields.length;
}
public Field getField(int idx) {
return fields[idx];
}
public String getFieldName(int idx) {
return fieldNames[idx];
}
public Integer getFieldIndex(String name) {
var searchHash = name.hashCode();
for (var i = 0; i < fields.length; i++) {
var fieldName = fieldNames[i];
if (searchHash != fieldName.hashCode()) continue;
if (name.equals(fieldName)) return i;
}
return null;
}
}