@Test public void testScalarNotEqual() throws Exception { OperatorContext context = mock(OperatorContext.class); BaseEventTypeNode eventNode = mock(BaseEventTypeNode.class); FilterOperand op0 = new LiteralOperand(new Variant(1)); FilterOperand op1 = new LiteralOperand(new Variant(2)); when(context.resolve(op0, eventNode)) .thenReturn(1); when(context.resolve(op1, eventNode)) .thenReturn(2); Boolean result = Operators.EQUALS.apply( context, eventNode, new FilterOperand[]{op0, op1} ); assertNotNull(result); assertFalse(result); }
@Nullable @Override public Boolean apply( OperatorContext context, BaseEventTypeNode eventNode, FilterOperand[] operands) throws UaException { validate(context, operands); FilterOperand op0 = operands[0]; FilterOperand op1 = operands[1]; Object value0 = context.resolve(op0, eventNode); Object value1 = context.resolve(op1, eventNode); if (value0 == null || value1 == null) { return null; } BuiltinDataType dt0 = getType(value0); BuiltinDataType dt1 = getType(value1); if (dt0 == null || dt1 == null) { throw new UaException(StatusCodes.Bad_UnexpectedError); } int p0 = ImplicitConversions.getPrecedence(dt0); int p1 = ImplicitConversions.getPrecedence(dt1); if (p0 == p1) { assert dt0 == dt1; return equals(value0, value1); } else if (p0 >= p1) { Object converted1 = convert(value1, dt0); return equals(value0, converted1); } else { Object converted0 = convert(value0, dt1); return equals(converted0, value1); } }
Equals implements Operator<Boolean> { @Nullable @Override public Boolean apply( OperatorContext context, BaseEventTypeNode eventNode, FilterOperand[] operands) throws UaException { validate(context, operands); FilterOperand op0 = operands[0]; FilterOperand op1 = operands[1]; Object value0 = context.resolve(op0, eventNode); Object value1 = context.resolve(op1, eventNode); if (value0 == null || value1 == null) { return null; } BuiltinDataType dt0 = getType(value0); BuiltinDataType dt1 = getType(value1); if (dt0 == null || dt1 == null) { throw new UaException(StatusCodes.Bad_UnexpectedError); } int p0 = ImplicitConversions.getPrecedence(dt0); int p1 = ImplicitConversions.getPrecedence(dt1); if (p0 == p1) { assert dt0 == dt1; return equals(value0, value1); } else if (p0 >= p1) { Object converted1 = convert(value1, dt0); return equals(value0, converted1); } else { Object converted0 = convert(value0, dt1); return equals(converted0, value1); } } }
Equals implements Operator<Boolean> { @Nullable @Override public Boolean apply( OperatorContext context, BaseEventTypeNode eventNode, FilterOperand[] operands) throws UaException { validate(context, operands); FilterOperand op0 = operands[0]; FilterOperand op1 = operands[1]; Object value0 = context.resolve(op0, eventNode); Object value1 = context.resolve(op1, eventNode); if (value0 == null || value1 == null) { return null; } BuiltinDataType dt0 = getType(value0); BuiltinDataType dt1 = getType(value1); if (dt0 == null || dt1 == null) { throw new UaException(StatusCodes.Bad_UnexpectedError); } int p0 = ImplicitConversions.getPrecedence(dt0); int p1 = ImplicitConversions.getPrecedence(dt1); if (p0 == p1) { assert dt0 == dt1; return equals(value0, value1); } else if (p0 >= p1) { Object converted1 = convert(value1, dt0); return equals(value0, converted1); } else { Object converted0 = convert(value0, dt1); return equals(converted0, value1); } } Equals(); }
Equals implements Operator<Boolean> { @Nullable @Override public Boolean apply( OperatorContext context, BaseEventTypeNode eventNode, FilterOperand[] operands) throws UaException { validate(context, operands); FilterOperand op0 = operands[0]; FilterOperand op1 = operands[1]; Object value0 = context.resolve(op0, eventNode); Object value1 = context.resolve(op1, eventNode); if (value0 == null || value1 == null) { return null; } BuiltinDataType dt0 = getType(value0); BuiltinDataType dt1 = getType(value1); if (dt0 == null || dt1 == null) { throw new UaException(StatusCodes.Bad_UnexpectedError); } int p0 = ImplicitConversions.getPrecedence(dt0); int p1 = ImplicitConversions.getPrecedence(dt1); if (p0 == p1) { assert dt0 == dt1; return equals(value0, value1); } else if (p0 >= p1) { Object converted1 = convert(value1, dt0); return equals(value0, converted1); } else { Object converted0 = convert(value0, dt1); return equals(converted0, value1); } } Equals(); @Override void validate(FilterContext context, FilterOperand[] operands); @Nullable @Override Boolean apply(
        OperatorContext context,
        BaseEventTypeNode eventNode,
        FilterOperand[] operands); }
Equals implements Operator<Boolean> { @Nullable @Override public Boolean apply( OperatorContext context, BaseEventTypeNode eventNode, FilterOperand[] operands) throws UaException { validate(context, operands); FilterOperand op0 = operands[0]; FilterOperand op1 = operands[1]; Object value0 = context.resolve(op0, eventNode); Object value1 = context.resolve(op1, eventNode); if (value0 == null || value1 == null) { return null; } BuiltinDataType dt0 = getType(value0); BuiltinDataType dt1 = getType(value1); if (dt0 == null || dt1 == null) { throw new UaException(StatusCodes.Bad_UnexpectedError); } int p0 = ImplicitConversions.getPrecedence(dt0); int p1 = ImplicitConversions.getPrecedence(dt1); if (p0 == p1) { assert dt0 == dt1; return equals(value0, value1); } else if (p0 >= p1) { Object converted1 = convert(value1, dt0); return equals(value0, converted1); } else { Object converted0 = convert(value0, dt1); return equals(converted0, value1); } } Equals(); @Override void validate(FilterContext context, FilterOperand[] operands); @Nullable @Override Boolean apply(
        OperatorContext context,
        BaseEventTypeNode eventNode,
        FilterOperand[] operands);  }