skadistats.clarity.wire.KindToClassMessageRegistry Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of clarity-protobuf Show documentation
Show all versions of clarity-protobuf Show documentation
Clarity is an open source replay parser for Dota 2 and CSGO 1 and 2 written in Java. This JAR contains the protobuf classes for clarity.
The newest version!
package skadistats.clarity.wire;
import com.google.protobuf.GeneratedMessage;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
public class KindToClassMessageRegistry {
private final Int2ObjectOpenHashMap> map;
public KindToClassMessageRegistry(int expected) {
map = new Int2ObjectOpenHashMap<>(expected, .5f);
}
private KindToClassMessageRegistry(KindToClassMessageRegistry other) {
map = new Int2ObjectOpenHashMap<>(other.map, 0.5f);
}
public void put(int kind, Class extends GeneratedMessage> clazz) {
map.put(kind, clazz);
}
public boolean containsKind(int kind) {
return map.containsKey(kind);
}
public Class extends GeneratedMessage> classForKind(int kind) {
return map.get(kind);
}
public ClassToKindMessageRegistry buildReverse() {
ClassToKindMessageRegistry result = new ClassToKindMessageRegistry(map.size());
map.forEach(result::put);
return result;
}
public KindToClassMessageRegistry copy() {
return new KindToClassMessageRegistry(this);
}
}