当前位置: 首页>>代码示例>>Java>>正文


Java InstantiatorStrategy类代码示例

本文整理汇总了Java中org.objenesis.strategy.InstantiatorStrategy的典型用法代码示例。如果您正苦于以下问题:Java InstantiatorStrategy类的具体用法?Java InstantiatorStrategy怎么用?Java InstantiatorStrategy使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


InstantiatorStrategy类属于org.objenesis.strategy包,在下文中一共展示了InstantiatorStrategy类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: treeNode

import org.objenesis.strategy.InstantiatorStrategy; //导入依赖的package包/类
@Test
public void treeNode() {
    final Result<DecisionTreeRuleSet> result = (new CommisionRuleSetSupplier()).get();
    EhSupport.ensure(result.isSuccess(), "Could not create decision tree");
    final DecisionTreeRuleSet ruleSet = result.getData();

    final TreeNode node = DecisionTreeFactory.constructDecisionTree(ruleSet, DecisionTreeType.SINGLE);

    final Kryo kryo = new Kryo();
    // no default no-arg constructors
    kryo.setInstantiatorStrategy(new StdInstantiatorStrategy());

    final InstantiatorStrategy defaultInstantiatorStrategy = new Kryo.DefaultInstantiatorStrategy();
    kryo.getRegistration(ArrayList.class)
            .setInstantiator(defaultInstantiatorStrategy.newInstantiatorOf(ArrayList.class));
    kryo.getRegistration(HashSet.class)
            .setInstantiator(defaultInstantiatorStrategy.newInstantiatorOf(HashSet.class));
    UnmodifiableCollectionsSerializer.registerSerializers(kryo);

    final ByteArrayOutputStream out = new ByteArrayOutputStream();
    final Output output = new Output(out);
    kryo.writeObject(output, node);
    output.flush();
    output.close();

    final ByteArrayInputStream inputStream = new ByteArrayInputStream(out.toByteArray());
    final Input kryoInput = new Input(inputStream);
    final TreeNode tree = kryo.readObject(kryoInput, BaseTreeNode.class);

    final SingleDecisionTreeFactoryTest test = new SingleDecisionTreeFactoryTest();
    test.checkTreeNode(tree, ruleSet);

    assertEquals(node, tree);
}
 
开发者ID:jpmorganchase,项目名称:swblocks-decisiontree,代码行数:35,代码来源:TreeSerializationTest.java

示例2: ObjenesisBase

import org.objenesis.strategy.InstantiatorStrategy; //导入依赖的package包/类
/**
 * Flexible constructor allowing to pick the strategy and if caching should be used
 *
 * @param strategy Strategy to use
 * @param useCache If {@link ObjectInstantiator}s should be cached
 */
public ObjenesisBase(InstantiatorStrategy strategy, boolean useCache) {
   if(strategy == null) {
      throw new IllegalArgumentException("A strategy can't be null");
   }
   this.strategy = strategy;
   this.cache = useCache ? new ConcurrentHashMap<String, ObjectInstantiator<?>>() : null;
}
 
开发者ID:easymock,项目名称:objenesis,代码行数:14,代码来源:ObjenesisBase.java

示例3: testInstantiatorStrategy

import org.objenesis.strategy.InstantiatorStrategy; //导入依赖的package包/类
@Test
public void testInstantiatorStrategy() throws Exception {
    assertNotNull(factory.getInstantiatorStrategy());

    InstantiatorStrategy strategy = new StdInstantiatorStrategy();

    factory.setInstantiatorStrategy(strategy);

    assertSame(strategy, factory.getInstantiatorStrategy());

    factory.setInstantiatorStrategy(null);

    assertNotNull(factory.createCodec());

    assertNull(factory.getInstantiatorStrategy());

    assertSame(factory, factory.withInstantiatorStrategy(strategy));

    assertSame(strategy, factory.getInstantiatorStrategy());

    assertNotNull(factory.createCodec());
}
 
开发者ID:hekate-io,项目名称:hekate,代码行数:23,代码来源:KryoCodecFactoryTest.java

示例4: getInstantiatorStrategy

import org.objenesis.strategy.InstantiatorStrategy; //导入依赖的package包/类
public InstantiatorStrategy getInstantiatorStrategy () {
	return strategy;
}
 
开发者ID:HoratiusTang,项目名称:EsperDist,代码行数:4,代码来源:Kryo.java

示例5: DefaultInstantiatorStrategy

import org.objenesis.strategy.InstantiatorStrategy; //导入依赖的package包/类
public DefaultInstantiatorStrategy (InstantiatorStrategy fallbackStrategy) {
	this.fallbackStrategy = fallbackStrategy;
}
 
开发者ID:HoratiusTang,项目名称:EsperDist,代码行数:4,代码来源:Kryo.java

示例6: setFallbackInstantiatorStrategy

import org.objenesis.strategy.InstantiatorStrategy; //导入依赖的package包/类
public void setFallbackInstantiatorStrategy (final InstantiatorStrategy fallbackStrategy) {
	this.fallbackStrategy = fallbackStrategy;
}
 
开发者ID:HoratiusTang,项目名称:EsperDist,代码行数:4,代码来源:Kryo.java

示例7: getFallbackInstantiatorStrategy

import org.objenesis.strategy.InstantiatorStrategy; //导入依赖的package包/类
public InstantiatorStrategy getFallbackInstantiatorStrategy () {
	return fallbackStrategy;
}
 
开发者ID:HoratiusTang,项目名称:EsperDist,代码行数:4,代码来源:Kryo.java

示例8: getInstantiatorStrategy

import org.objenesis.strategy.InstantiatorStrategy; //导入依赖的package包/类
public InstantiatorStrategy getInstantiatorStrategy() {
	return strategy;
}
 
开发者ID:HoratiusTang,项目名称:EsperDist,代码行数:4,代码来源:Kryo.java

示例9: setFallbackInstantiatorStrategy

import org.objenesis.strategy.InstantiatorStrategy; //导入依赖的package包/类
public void setFallbackInstantiatorStrategy(final InstantiatorStrategy fallbackStrategy) {
	this.fallbackStrategy = fallbackStrategy;
}
 
开发者ID:HoratiusTang,项目名称:EsperDist,代码行数:4,代码来源:Kryo.java

示例10: getFallbackInstantiatorStrategy

import org.objenesis.strategy.InstantiatorStrategy; //导入依赖的package包/类
public InstantiatorStrategy getFallbackInstantiatorStrategy() {
	return fallbackStrategy;
}
 
开发者ID:HoratiusTang,项目名称:EsperDist,代码行数:4,代码来源:Kryo.java

示例11: DefaultInstantiatorStrategy

import org.objenesis.strategy.InstantiatorStrategy; //导入依赖的package包/类
public DefaultInstantiatorStrategy (InstantiatorStrategy fallbackStrategy) {
  this.fallbackStrategy = fallbackStrategy;
}
 
开发者ID:apache,项目名称:metron,代码行数:4,代码来源:SerDeUtils.java

示例12: setFallbackInstantiatorStrategy

import org.objenesis.strategy.InstantiatorStrategy; //导入依赖的package包/类
public void setFallbackInstantiatorStrategy (final InstantiatorStrategy fallbackStrategy) {
  this.fallbackStrategy = fallbackStrategy;
}
 
开发者ID:apache,项目名称:metron,代码行数:4,代码来源:SerDeUtils.java

示例13: getFallbackInstantiatorStrategy

import org.objenesis.strategy.InstantiatorStrategy; //导入依赖的package包/类
public InstantiatorStrategy getFallbackInstantiatorStrategy () {
  return fallbackStrategy;
}
 
开发者ID:apache,项目名称:metron,代码行数:4,代码来源:SerDeUtils.java

示例14: getInstantiatorStrategy

import org.objenesis.strategy.InstantiatorStrategy; //导入依赖的package包/类
/**
 * Returns the instantiator strategy (see {@link #setInstantiatorStrategy(InstantiatorStrategy)}).
 *
 * @return Instantiator strategy.
 */
public InstantiatorStrategy getInstantiatorStrategy() {
    return instantiatorStrategy;
}
 
开发者ID:hekate-io,项目名称:hekate,代码行数:9,代码来源:KryoCodecFactory.java

示例15: setInstantiatorStrategy

import org.objenesis.strategy.InstantiatorStrategy; //导入依赖的package包/类
/**
 * Sets instantiator strategy. Such strategy will be registered via {@link Kryo#setInstantiatorStrategy(InstantiatorStrategy)}.
 *
 * <p>
 * By default this parameter is set to {@link DefaultInstantiatorStrategy} with a fallback to {@link StdInstantiatorStrategy}.
 * </p>
 *
 * @param instantiatorStrategy Instantiator strategy.
 */
public void setInstantiatorStrategy(InstantiatorStrategy instantiatorStrategy) {
    this.instantiatorStrategy = instantiatorStrategy;
}
 
开发者ID:hekate-io,项目名称:hekate,代码行数:13,代码来源:KryoCodecFactory.java


注:本文中的org.objenesis.strategy.InstantiatorStrategy类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。