本文整理汇总了Java中org.apache.commons.collections4.functors.ConstantFactory类的典型用法代码示例。如果您正苦于以下问题:Java ConstantFactory类的具体用法?Java ConstantFactory怎么用?Java ConstantFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ConstantFactory类属于org.apache.commons.collections4.functors包,在下文中一共展示了ConstantFactory类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visitLiteral
import org.apache.commons.collections4.functors.ConstantFactory; //导入依赖的package包/类
@Override
public Object visitLiteral(LiteralExpression literal, EdmLiteral edm_literal)
{
try
{
// A literal is a Provider<?> (Functional Java)
// Returns a Node<?> (Expression Tree)
Object o = edm_literal.getType().valueOfString(
edm_literal.getLiteral(),
EdmLiteralKind.DEFAULT,
null,
edm_literal.getType().getDefaultType());
return ExecutableExpressionTree.Node.createLeave(ConstantFactory.constantFactory(o));
}
catch (EdmException ex)
{
throw new RuntimeException(ex);
}
}
示例2: nullFactory
import org.apache.commons.collections4.functors.ConstantFactory; //导入依赖的package包/类
/**
* Gets a Factory that will return null each time the factory is used.
* This could be useful during testing as a placeholder.
*
* @see org.apache.commons.collections4.functors.ConstantFactory
* @param <T> the "type" of null object the factory should return.
* @return the factory
*/
public static <T> Factory<T> nullFactory() {
return ConstantFactory.<T>constantFactory(null);
}
示例3: constantFactory
import org.apache.commons.collections4.functors.ConstantFactory; //导入依赖的package包/类
/**
* Creates a Factory that will return the same object each time the factory
* is used. No check is made that the object is immutable. In general, only
* immutable objects should use the constant factory. Mutable objects should
* use the prototype factory.
*
* @see org.apache.commons.collections4.functors.ConstantFactory
*
* @param <T> the type that the factory creates
* @param constantToReturn the constant object to return each time in the factory
* @return the <code>constant</code> factory.
*/
public static <T> Factory<T> constantFactory(final T constantToReturn) {
return ConstantFactory.constantFactory(constantToReturn);
}