com.esotericsoftware.kryo.Kryo.newInstantiator()方法的使用及代码示例

x33g5p2x  于2022-01-23 转载在 其他  
字(2.7k)|赞(0)|评价(0)|浏览(146)

本文整理了Java中com.esotericsoftware.kryo.Kryo.newInstantiator()方法的一些代码示例,展示了Kryo.newInstantiator()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Kryo.newInstantiator()方法的具体详情如下:
包路径:com.esotericsoftware.kryo.Kryo
类名称:Kryo
方法名:newInstantiator

Kryo.newInstantiator介绍

[英]Returns a new instantiator for creating new instances of the specified type. By default, an instantiator is returned that uses reflection if the class has a zero argument constructor, an exception is thrown. If a #setInstantiatorStrategy(InstantiatorStrategy) is set, it will be used instead of throwing an exception.
[中]返回用于创建指定类型的新实例的新实例化器。默认情况下,返回使用反射的实例化器。如果类具有零参数构造函数,则引发异常。如果设置了#setInstanceorStrategy(InstanceorStrategy),则将使用它而不是引发异常。

代码示例

代码示例来源:origin: com.esotericsoftware.kryo/kryo

/** Creates a new instance of a class using {@link Registration#getInstantiator()}. If the registration's instantiator is null,
 * a new one is set using {@link #newInstantiator(Class)}. */
public <T> T newInstance (Class<T> type) {
  Registration registration = getRegistration(type);
  ObjectInstantiator instantiator = registration.getInstantiator();
  if (instantiator == null) {
      instantiator = newInstantiator(type);
    registration.setInstantiator(instantiator);
  }
  return (T)instantiator.newInstance();
}

代码示例来源:origin: com.esotericsoftware/kryo-shaded

/** Creates a new instance of a class using {@link Registration#getInstantiator()}. If the registration's instantiator is null,
 * a new one is set using {@link #newInstantiator(Class)}. */
public <T> T newInstance (Class<T> type) {
  Registration registration = getRegistration(type);
  ObjectInstantiator instantiator = registration.getInstantiator();
  if (instantiator == null) {
    instantiator = newInstantiator(type);
    registration.setInstantiator(instantiator);
  }
  return (T)instantiator.newInstance();
}

代码示例来源:origin: com.esotericsoftware/kryo

/** Creates a new instance of a class using {@link Registration#getInstantiator()}. If the registration's instantiator is null,
 * a new one is set using {@link #newInstantiator(Class)}. */
public <T> T newInstance (Class<T> type) {
  Registration registration = getRegistration(type);
  ObjectInstantiator instantiator = registration.getInstantiator();
  if (instantiator == null) {
    instantiator = newInstantiator(type);
    registration.setInstantiator(instantiator);
  }
  return (T)instantiator.newInstance();
}

代码示例来源:origin: svn2github/kryo

/** Creates a new instance of a class using {@link Registration#getInstantiator()}. If the registration's instantiator is null,
 * a new one is set using {@link #newInstantiator(Class)}. */
public <T> T newInstance (Class<T> type) {
  Registration registration = getRegistration(type);
  ObjectInstantiator instantiator = registration.getInstantiator();
  if (instantiator == null) {
    instantiator = newInstantiator(type);
    registration.setInstantiator(instantiator);
  }
  return (T)instantiator.newInstance();
}

相关文章