skadistats.clarity.io.s2.field.ArrayField 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.field;
import skadistats.clarity.io.Util;
import skadistats.clarity.io.s2.Field;
import skadistats.clarity.io.s2.FieldType;
import skadistats.clarity.model.state.ArrayEntityState;
public class ArrayField extends Field {
private final Field elementField;
private final int length;
public ArrayField(FieldType fieldType, Field elementField, int length) {
super(fieldType);
this.elementField = elementField;
this.length = length;
}
@Override
public Field getChild(int idx) {
return elementField;
}
@Override
public Integer getChildIndex(String nameSegment) {
return Util.stringToArrayIdx(nameSegment);
}
@Override
public String getChildNameSegment(int idx) {
return Util.arrayIdxToString(idx);
}
@Override
public void ensureArrayEntityStateCapacity(ArrayEntityState state, int capacity) {
state.capacity(length);
}
@Override
public Object getArrayEntityState(ArrayEntityState state, int idx) {
return state.sub(idx).length();
}
}