本文整理汇总了Java中net.ssehub.easy.varModel.model.values.BooleanValue.FALSE属性的典型用法代码示例。如果您正苦于以下问题:Java BooleanValue.FALSE属性的具体用法?Java BooleanValue.FALSE怎么用?Java BooleanValue.FALSE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类net.ssehub.easy.varModel.model.values.BooleanValue
的用法示例。
在下文中一共展示了BooleanValue.FALSE属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: assertSpecialBooleanOperations
/**
* Tests all nine possible situations of an binary boolean operation.
* It will test:
* <ol>
* <li><tt>undef OPERATION false</tt></li>
* <li><tt>undef OPERATION true</tt></li>
* <li><tt>undef OPERATION undef</tt></li>
* <li><tt>false OPERATION false</tt></li>
* <li><tt>false OPERATION true</tt></li>
* <li><tt>false OPERATION undef</tt></li>
* <li><tt>true OPERATION false</tt></li>
* <li><tt>true OPERATION true</tt></li>
* <li><tt>true OPERATION undef</tt></li>
* </ol>
* @param operation One of {@link OclKeyWords#AND} or {@link OclKeyWords#OR}.
* @param expectedValues The expected values for the given list above, should bean arrays with length = 9.
* If expected that the {@link EvaluationVisitor} is not able to resolve the operation, add <tt>null</tt> to
* the specific position of the array.
* @see #testSpecialBooleanOperartions()
*/
private void assertSpecialBooleanOperations(String operation, Boolean[] expectedValues) {
DecisionVariableDeclaration unDefVar = new DecisionVariableDeclaration("unDefVar", BooleanType.TYPE, project);
project.add(unDefVar);
Configuration config = new Configuration(project);
EvaluationVisitor evaluator = new EvaluationVisitor(config, null, false, null);
Variable nullVar = new Variable(unDefVar);
ConstantValue constFalseVal = new ConstantValue(BooleanValue.FALSE);
ConstantValue constTrueVal = new ConstantValue(BooleanValue.TRUE);
// All nine possible constraints
assertSpecialOperation(nullVar, operation, constFalseVal, expectedValues[0], evaluator);
assertSpecialOperation(nullVar, operation, constTrueVal, expectedValues[1], evaluator);
assertSpecialOperation(nullVar, operation, nullVar, expectedValues[2], evaluator);
assertSpecialOperation(constFalseVal, operation, constFalseVal, expectedValues[3], evaluator);
assertSpecialOperation(constFalseVal, operation, constTrueVal, expectedValues[4], evaluator);
assertSpecialOperation(constFalseVal, operation, nullVar, expectedValues[5], evaluator);
assertSpecialOperation(constTrueVal, operation, constFalseVal, expectedValues[6], evaluator);
assertSpecialOperation(constTrueVal, operation, constTrueVal, expectedValues[7], evaluator);
assertSpecialOperation(constTrueVal, operation, nullVar, expectedValues[8], evaluator);
}
示例2: toIVMLValue
@Override
protected Value toIVMLValue(IDecisionVariable trgVariable, Object oValue) throws ValueDoesNotMatchTypeException {
IDatatype type = trgVariable.getDeclaration().getType();
Value result = null;
if (IntegerType.TYPE.isAssignableFrom(type) && oValue instanceof Double) {
oValue = ((Double) oValue).intValue();
} else if (BooleanType.TYPE.isAssignableFrom(type) && oValue instanceof Double) {
result = ((Double) oValue) >= 0.5 ? BooleanValue.TRUE : BooleanValue.FALSE;
}
if (null == result) {
result = ValueFactory.createValue(type, oValue);
}
return result;
}
示例3: testIfThenElse
/**
* Tests the if-then-else expression.
*
* @throws ValueDoesNotMatchTypeException in case that value assignments fail (shall not occur)
* @throws ConfigurationException in case that initial assignment of values fail (shall not occur)
* @throws CSTSemanticException in case that the expressions created during this test are not
* valid (shall not occur)
*/
@Test
public void testIfThenElse() throws ValueDoesNotMatchTypeException, ConfigurationException, CSTSemanticException {
Project project = new Project("Test");
DecisionVariableDeclaration decl = new DecisionVariableDeclaration("test", IntegerType.TYPE, project);
project.add(decl);
Configuration config = new Configuration(project);
config.getDecision(decl).setValue(ValueFactory.createValue(IntegerType.TYPE, 1), AssignmentState.ASSIGNED);
// if test>0 then true else false
ConstraintSyntaxTree const0 = new ConstantValue(ValueFactory.createValue(IntegerType.TYPE, 0));
ConstraintSyntaxTree condition = Utils.createCall(decl, IntegerType.GREATER_EQUALS_INTEGER_INTEGER, const0);
condition.inferDatatype();
ConstraintSyntaxTree expr = new IfThen(condition,
new ConstantValue(BooleanValue.TRUE),
new ConstantValue(BooleanValue.FALSE));
EvaluationVisitor visitor = new EvaluationVisitor();
visitor.init(config, AssignmentState.DEFAULT, false, null);
expr.accept(visitor);
Assert.assertEquals(BooleanValue.TRUE, visitor.getResult());
visitor.clearResult();
config.getDecision(decl).setValue(ValueFactory.createValue(IntegerType.TYPE, -1), AssignmentState.ASSIGNED);
expr.accept(visitor);
Assert.assertEquals(BooleanValue.FALSE, visitor.getResult());
visitor.clearResult();
expr = new IfThen(condition, new ConstantValue(BooleanValue.TRUE), null);
expr.accept(visitor);
Assert.assertNull(visitor.getResult());
visitor.clearResult();
visitor.clear();
}
示例4: aggregate
@Override
public BooleanValue aggregate(EvaluationAccessor result, Value iter, EvaluationAccessor value,
Map<Object, Object> data) throws ValueDoesNotMatchTypeException {
if (!(BooleanValue.TRUE.equals(result.getValue())
&& BooleanValue.TRUE.equals(value.getValue()))) {
// forAll is only true if all evaluations are true
result.setValue(BooleanValue.FALSE, false);
}
return BooleanValue.FALSE;
}
示例5: evaluate
public EvaluationAccessor evaluate(EvaluationAccessor operand, EvaluationAccessor[] arguments) {
EvaluationAccessor result = null;
Value value = operand.getValue();
if (value instanceof StringValue) {
String str = ((StringValue) value).getValue();
BooleanValue bValue; // close to OCL
if (equalsIgnoreCase(str, "true", operand)) {
bValue = BooleanValue.TRUE;
} else {
bValue = BooleanValue.FALSE;
}
result = ConstantAccessor.POOL.getInstance().bind(bValue, operand.getContext());
}
return result;
}
示例6: getStartResult
@Override
public Value getStartResult(IDatatype type, IDatatype iterType) throws ValueDoesNotMatchTypeException {
return BooleanValue.FALSE;
}
示例7: handleBinaryBoolean
/**
* Handles an {@link BooleanType#AND}, {@link BooleanType#OR} or {@link BooleanType#XOR} operation. Should evaluate
* special situations like <code>undef OR true</code> to <code>true</code>. Dynamically changes evaluation sequence
* depending on {@link #containsIsDefined(ConstraintSyntaxTree)}.
*
* @param operand The operand of the OR operation. The operand should already been visited.
* @param call the call representing the OR operation
* @return <tt>true</tt> the operation was evaluated successfully, <tt>false</tt> otherwise.
*/
private boolean handleBinaryBoolean(EvaluationAccessor operand, OCLFeatureCall call) {
boolean hasBeenEvaluated = false;
Operation op = call.getResolvedOperation();
EvaluationAccessor operandAccessor = operand;
EvaluationAccessor parameterAccessor = null;
ConstraintSyntaxTree parameter = call.getParameter(0);
if (containsIsDefined(call.getOperand())) {
if (null != parameter) { // if there is no parameter then no change in result
// change evaluation sequence - may not help if both contains an isDefined
parameterAccessor = getAccessor(parameterAccessor, parameter);
// re-evaluate operand!
operandAccessor = getAccessor(operandAccessor, call.getOperand());
}
}
if (op == BooleanType.AND) {
if (null != operandAccessor && operandAccessor.getValue() == BooleanValue.FALSE) {
result = ConstantAccessor.POOL.getInstance().bind(BooleanValue.FALSE, operand.getContext());
hasBeenEvaluated = true;
} else if (null != operand && null != parameter) {
parameterAccessor = getAccessor(parameterAccessor, parameter);
if (null != parameterAccessor && parameterAccessor.getValue() == BooleanValue.FALSE) {
result = ConstantAccessor.POOL.getInstance().bind(BooleanValue.FALSE, operand.getContext());
hasBeenEvaluated = true;
}
}
} else if (op == BooleanType.OR) {
if (null != operandAccessor && operandAccessor.getValue() == BooleanValue.TRUE) {
result = ConstantAccessor.POOL.getInstance().bind(BooleanValue.TRUE, operand.getContext());
hasBeenEvaluated = true;
} else if (null != operandAccessor && null != parameter) {
parameterAccessor = getAccessor(parameterAccessor, parameter);
if (null != parameterAccessor && parameterAccessor.getValue() == BooleanValue.TRUE) {
result = ConstantAccessor.POOL.getInstance().bind(BooleanValue.TRUE, operand.getContext());
hasBeenEvaluated = true;
}
}
} else { // xor
if (null != operandAccessor && null != parameter) {
parameterAccessor = getAccessor(parameterAccessor, parameter);
if (null != parameterAccessor) {
boolean xorRes = operand.getValue() == BooleanValue.TRUE ^ result.getValue() == BooleanValue.TRUE;
result = ConstantAccessor.POOL.getInstance().bind(BooleanValue.toBooleanValue(xorRes),
operand.getContext());
hasBeenEvaluated = true;
}
}
}
if (null != parameterAccessor) {
parameterAccessor.release();
}
if (operandAccessor != operand) { // we have a temporary operand
operandAccessor.release();
}
return hasBeenEvaluated;
}
示例8: constraintFailed
/**
* Returns whether the {@link #getResult() result of a constraint evaluation}
* indicates that the evaluated constraint failed.
*
* @param result the evaluation result
* @return <code>true</code> if the constraint failed, <code>false</code> else
*/
public static boolean constraintFailed(Object result) {
return (BooleanValue.FALSE == result || Boolean.FALSE == result);
}