本文整理汇总了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);
}
示例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;
}
示例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());
}
示例4: getInstantiatorStrategy
import org.objenesis.strategy.InstantiatorStrategy; //导入依赖的package包/类
public InstantiatorStrategy getInstantiatorStrategy () {
return strategy;
}
示例5: DefaultInstantiatorStrategy
import org.objenesis.strategy.InstantiatorStrategy; //导入依赖的package包/类
public DefaultInstantiatorStrategy (InstantiatorStrategy fallbackStrategy) {
this.fallbackStrategy = fallbackStrategy;
}
示例6: setFallbackInstantiatorStrategy
import org.objenesis.strategy.InstantiatorStrategy; //导入依赖的package包/类
public void setFallbackInstantiatorStrategy (final InstantiatorStrategy fallbackStrategy) {
this.fallbackStrategy = fallbackStrategy;
}
示例7: getFallbackInstantiatorStrategy
import org.objenesis.strategy.InstantiatorStrategy; //导入依赖的package包/类
public InstantiatorStrategy getFallbackInstantiatorStrategy () {
return fallbackStrategy;
}
示例8: getInstantiatorStrategy
import org.objenesis.strategy.InstantiatorStrategy; //导入依赖的package包/类
public InstantiatorStrategy getInstantiatorStrategy() {
return strategy;
}
示例9: setFallbackInstantiatorStrategy
import org.objenesis.strategy.InstantiatorStrategy; //导入依赖的package包/类
public void setFallbackInstantiatorStrategy(final InstantiatorStrategy fallbackStrategy) {
this.fallbackStrategy = fallbackStrategy;
}
示例10: getFallbackInstantiatorStrategy
import org.objenesis.strategy.InstantiatorStrategy; //导入依赖的package包/类
public InstantiatorStrategy getFallbackInstantiatorStrategy() {
return fallbackStrategy;
}
示例11: DefaultInstantiatorStrategy
import org.objenesis.strategy.InstantiatorStrategy; //导入依赖的package包/类
public DefaultInstantiatorStrategy (InstantiatorStrategy fallbackStrategy) {
this.fallbackStrategy = fallbackStrategy;
}
示例12: setFallbackInstantiatorStrategy
import org.objenesis.strategy.InstantiatorStrategy; //导入依赖的package包/类
public void setFallbackInstantiatorStrategy (final InstantiatorStrategy fallbackStrategy) {
this.fallbackStrategy = fallbackStrategy;
}
示例13: getFallbackInstantiatorStrategy
import org.objenesis.strategy.InstantiatorStrategy; //导入依赖的package包/类
public InstantiatorStrategy getFallbackInstantiatorStrategy () {
return fallbackStrategy;
}
示例14: getInstantiatorStrategy
import org.objenesis.strategy.InstantiatorStrategy; //导入依赖的package包/类
/**
* Returns the instantiator strategy (see {@link #setInstantiatorStrategy(InstantiatorStrategy)}).
*
* @return Instantiator strategy.
*/
public InstantiatorStrategy getInstantiatorStrategy() {
return instantiatorStrategy;
}
示例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;
}