Java Code Examples for org.apache.olingo.odata2.api.uri.expression.UnaryOperator#toUriLiteral()

The following examples show how to use org.apache.olingo.odata2.api.uri.expression.UnaryOperator#toUriLiteral() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FunctionalVisitor.java    From DataHubSystem with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public Object visitUnary(UnaryExpression ue, UnaryOperator operator, Object operand)
{
   // operand is a Node<?> (Expression Tree)
   // Returns an instance of Transformer<?> (functional java) as a Node<?> (Expression Tree)
   Transformer trans;
   switch (operator)
   {
      case   NOT: trans = Transformers.not();   break;
      case MINUS: trans = Transformers.minus(); break;

      default:
         throw new UnsupportedOperationException("Unsupported operator: " + operator.toUriLiteral());
   }
   ExecutableExpressionTree.Node param = ExecutableExpressionTree.Node.class.cast(operand);

   return ExecutableExpressionTree.Node.createNode(trans, param);
}
 
Example 2
Source File: SQLVisitor.java    From DataHubSystem with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public Object visitUnary(UnaryExpression unary_expression,
      UnaryOperator operator, Object operand)
{
   switch (operator)
   {
      case MINUS:
      {
         if (operand instanceof Long)
         {
            return -((Long) operand);
         }
         else if (operand instanceof Double)
         {
            return -((Double) operand);
         }
         else
         {
            throw new UnsupportedOperationException("Invalid expression: " +
                  unary_expression.getUriLiteral());
         }
      }
      case NOT:
      {
         return Restrictions.not((Criterion) operand);
      }
      default:
         break;
   }
   throw new UnsupportedOperationException("Unsupported operator: " +
         operator.toUriLiteral());
}
 
Example 3
Source File: InfoUnaryOperator.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
public InfoUnaryOperator(final UnaryOperator operator, final String category,
    final ParameterSetCombination combination) {
  this.operator = operator;
  this.category = category;
  syntax = operator.toUriLiteral();
  this.combination = combination;
}
 
Example 4
Source File: VisitorTool.java    From olingo-odata2 with Apache License 2.0 4 votes vote down vote up
@Override
public Object visitUnary(final UnaryExpression unaryExpression, final UnaryOperator operator, final Object operand) {
  return "{" + operator.toUriLiteral() + " " + operand.toString() + "}";
}