本文整理汇总了Java中com.esotericsoftware.kryo.Kryo.getRegistration方法的典型用法代码示例。如果您正苦于以下问题:Java Kryo.getRegistration方法的具体用法?Java Kryo.getRegistration怎么用?Java Kryo.getRegistration使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.esotericsoftware.kryo.Kryo
的用法示例。
在下文中一共展示了Kryo.getRegistration方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: register
import com.esotericsoftware.kryo.Kryo; //导入方法依赖的package包/类
/**
* Register {@code type} and {@code serializer} to {@code kryo} instance.
*
* @param kryo Kryo instance
* @param type type to register
* @param serializer Specific serializer to register or null to use default.
* @param id type registration id to use
*/
private void register(Kryo kryo, Class<?> type, Serializer<?> serializer, int id) {
Registration existing = kryo.getRegistration(id);
if (existing != null) {
if (existing.getType() != type) {
log.error("{}: Failed to register {} as {}, {} was already registered.",
friendlyName(), type, id, existing.getType());
throw new IllegalStateException(String.format(
"Failed to register %s as %s, %s was already registered.",
type, id, existing.getType()));
}
// falling through to register call for now.
// Consider skipping, if there's reasonable
// way to compare serializer equivalence.
}
Registration r;
if (serializer == null) {
r = kryo.register(type, id);
} else {
r = kryo.register(type, serializer, id);
}
if (r.getId() != id) {
log.warn("{}: {} already registed as {}. Skipping {}.",
friendlyName(), r.getType(), r.getId(), id);
}
log.trace("{} registered as {}", r.getType(), r.getId());
}