通过Java/Kotlin中的类中的静态值查找类

通过Java/Kotlin中的类中的静态值查找类,java,serialization,kotlin,reflection,Java,Serialization,Kotlin,Reflection,我有一个JSON序列化对象,如下所示 { "someData" : ... // data, structure of which varies based on the type of the serialized object "typeID" : 42 // integer constant that uniquely identifies type of the serialized object } 我还有一个Java库,如下所示: 抽象类GeneralClass{ 公共抽象

我有一个JSON序列化对象,如下所示

{
  "someData" : ... // data, structure of which varies based on the type of the serialized object
  "typeID" : 42 // integer constant that uniquely identifies type of the serialized object
}
我还有一个Java库,如下所示:

抽象类GeneralClass{
公共抽象int getTypeID();
}
类SomeDataClass1扩展了GeneralClass{
公共SomeDataClass1(/*参数取决于类型*/){/*具有参数的init数据字段*/}
/*公共数据字段*/
公共静态最终int-typeID=42
@凌驾
public int getTypeID(){
返回typeID;
}
}
每个
typeID
都以示例中的方式唯一地标识Java库中许多类中的一个。要使用库中的函数,我需要从序列化数据构造类的实例;为此,我将使用gson。为了让gson将JSON反序列化为一个对象,我需要向它传递一个Class对象的实例,该实例对应于
typeID

如果我有
typeID
,如何获得与类对应的类对象?

这看起来像是
Map
的一个很好的用例。这看起来像是
Map
的一个很好的用例。