All Downloads are FREE. Search and download functionalities are using the official Maven repository.

skadistats.clarity.wire.KindToClassMessageRegistry Maven / Gradle / Ivy

Go to download

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.

There is a newer version: 5.3
Show 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 clazz) {
        map.put(kind, clazz);
    }

    public boolean containsKind(int kind) {
        return map.containsKey(kind);
    }

    public Class 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);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy