Esempio n. 1
0
 public void defineOperation(Statement left, Statement right) {
   if (left == null || left instanceof KeywordStatement) {
     operation = new NegateOperation();
   } else if (left.resultType().equals(INTEGER) && right.resultType().equals(INTEGER)) {
     operation = SubtractIntegerOperation.INSTANCE;
   } else if (NUMERIC.isComparableTo(left.resultType())) {
     operation = SubtractDecimalOperation.INSTANCE;
   } else if (left.resultType().equals(DATE) && right.resultType().equals(INTEGER)) {
     operation = new SubtractDateOperation();
   } else {
     throw new LangException(LangError.E31, "Uso incorreto do operador -");
   }
 }
Esempio n. 2
0
 /*
  * (non-Javadoc)
  *
  * @see
  * br.gov.serpro.ctd.lang.keyword.KeywordStatement#link(br.gov.serpro.ctd
  * .lang.Statement, br.gov.serpro.ctd.lang.Statement)
  */
 @Override
 public void link(Statement left, Statement right) {
   if (operation instanceof NegateOperation) { // Negate
     left = null;
     if (right.resultType().equals(INTEGER)) {
       operation = new IntegerNegateOperation();
     }
   }
   super.link(left, right);
 }