Java 类org.apache.commons.collections4.functors.ConstantFactory 实例源码

项目:dhus-core    文件:FunctionalVisitor.java   
@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);
   }
}
项目:DataHubSystem    文件:FunctionalVisitor.java   
@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);
   }
}
项目:HCFCore    文件:FactoryUtils.java   
/**
 * 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);
}
项目:HCFCore    文件:FactoryUtils.java   
/**
 * 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);
}
项目:HCFCore    文件:FactoryUtils.java   
/**
 * 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);
}
项目:HCFCore    文件:FactoryUtils.java   
/**
 * 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);
}