当前位置: 首页>>代码示例>>Java>>正文


Java BooleanValue类代码示例

本文整理汇总了Java中net.ssehub.easy.varModel.model.values.BooleanValue的典型用法代码示例。如果您正苦于以下问题:Java BooleanValue类的具体用法?Java BooleanValue怎么用?Java BooleanValue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


BooleanValue类属于net.ssehub.easy.varModel.model.values包,在下文中一共展示了BooleanValue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: evaluateGuard

import net.ssehub.easy.varModel.model.values.BooleanValue; //导入依赖的package包/类
/**
 * Evaluates the guard of a breakdown call.
 * 
 * @param call the call
 * @return whether the call is active (due to the guard) or not
 * @throws VilException in case of evaluation problems
 */
private boolean evaluateGuard(AbstractBreakdownCall call) throws VilException {
    boolean active = true;
    Expression guard = call.getGuardExpression();
    if (null != guard) {
        Object o = guard.accept(this);
        if (o instanceof DecisionVariable) {
            o = ((DecisionVariable) o).getValue();
        }
        if (o instanceof BooleanValue) {
            o = ((BooleanValue) o).getValue();
        }
        if (!Boolean.TRUE.equals(o)) {
            active = false;
        }
    }
    return active;
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:25,代码来源:RtVilExecution.java

示例2: assertSpecialBooleanOperations

import net.ssehub.easy.varModel.model.values.BooleanValue; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:42,代码来源:EvaluationVisitorTest.java

示例3: assertEquals

import net.ssehub.easy.varModel.model.values.BooleanValue; //导入依赖的package包/类
/**
 * Asserts equality between an expected boolean value and an actual evaluation accessor value.
 * Releases <code>actual</code>.
 * 
 * @param expected the expected value
 * @param actual the actual evaluation result
 */
static final void assertEquals(Boolean expected, EvaluationAccessor actual) {
    Value val;
    if (null != actual) {
        val = actual.getValue();
        actual.release();
    } else {
        val = null;
    }
    if (null != expected && val instanceof BooleanValue) {
        Assert.assertEquals(expected, ((BooleanValue) val).getValue());
    } else if (null == expected && null == val) {
        Assert.assertTrue(true); // useless, I know
    } else {
        Assert.fail("expected " + expected + " is not equal to " + val);
    }
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:24,代码来源:Utils.java

示例4: testCopyDerivedType

import net.ssehub.easy.varModel.model.values.BooleanValue; //导入依赖的package包/类
/**
 * Tests whether a simple {@link DerivedDatatype} without any dependencies can be copied.
 * @throws CSTSemanticException If <tt>true</tt>  cannot be created as constraint for a boolean type
 */
@Test
public void testCopyDerivedType() throws CSTSemanticException {
    Project original = new Project("testCopyDerivedType");
    IDatatype basisType = BooleanType.TYPE;
    DerivedDatatype dType = new DerivedDatatype("posType", basisType, original);
    Constraint constraint = new Constraint(dType);
    OCLFeatureCall equality = new OCLFeatureCall(new Variable(dType.getTypeDeclaration()), OclKeyWords.EQUALS,
            new ConstantValue(BooleanValue.TRUE));
    constraint.setConsSyntax(equality);
    dType.setConstraints(new Constraint[] {constraint});
    original.add(dType);
    
    java.util.Set<Project> copiedProjects = new HashSet<Project>();
    Project copy = copyProject(original, copiedProjects);
    DerivedDatatype copiedType = (DerivedDatatype) copy.getElement(0);
    assertDerivedType(dType, copiedType, copy, copiedProjects);
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:22,代码来源:ProjectCopyVisitorTest.java

示例5: testSimpleOperationCopy

import net.ssehub.easy.varModel.model.values.BooleanValue; //导入依赖的package包/类
/**
 * Tests whether a simple {@link OperationDefinition}, without any dependencies, can be copied.
 * Tests also that {@link ExplicitTypeVariableDeclaration}s can be copied (as they may be used inside of
 * {@link OperationDefinition}s but not elsewhere.
 */
@Test
public void testSimpleOperationCopy() {
    Project original = new Project("testSimpleOperationCopy");
    OperationDefinition operation = new OperationDefinition(original);
    ExplicitTypeVariableDeclaration parameterDecl = new ExplicitTypeVariableDeclaration("param1", RealType.TYPE,
        operation);
    ConstantValue constTrueFunc = new ConstantValue(BooleanValue.TRUE);
    CustomOperation func = new CustomOperation(BooleanType.TYPE, "returnsTrue", original.getType(), constTrueFunc,
        new DecisionVariableDeclaration[] {parameterDecl});
    operation.setOperation(func);
    original.add(operation);
    
    Project copy = copyProject(original);
    OperationDefinition copiedOp = (OperationDefinition) copy.getElement(0);
    assertUserOperation(operation, copiedOp, copy);
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:22,代码来源:ProjectCopyVisitorTest.java

示例6: testOperationDependingCompletely

import net.ssehub.easy.varModel.model.values.BooleanValue; //导入依赖的package包/类
/**
 * Tests whether a {@link OperationDefinition} can be copied, which depends on an unresolved type.
 */
@Test
public void testOperationDependingCompletely() {
    Project original = new Project("testOperationDependingCompletely");
    DerivedDatatype aliasType = new DerivedDatatype("boolAlias", BooleanType.TYPE, original);
    OperationDefinition operation = new OperationDefinition(original);
    ExplicitTypeVariableDeclaration parameterDecl = new ExplicitTypeVariableDeclaration("param1", aliasType,
        operation);
    ConstantValue constTrueFunc = new ConstantValue(BooleanValue.TRUE);
    CustomOperation func = new CustomOperation(aliasType, "returnsTrue", original.getType(), constTrueFunc,
        new DecisionVariableDeclaration[] {parameterDecl});
    operation.setOperation(func);
    original.add(operation);
    original.add(aliasType);
    
    Project copy = copyProject(original);
    // Attention: Ordering has changed!
    OperationDefinition copiedOp = (OperationDefinition) copy.getElement(1);
    assertUserOperation(operation, copiedOp, copy);
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:23,代码来源:ProjectCopyVisitorTest.java

示例7: testFreezeBlockKnownDeclarationSimpleBut

import net.ssehub.easy.varModel.model.values.BooleanValue; //导入依赖的package包/类
/**
 * Tests copying a {@link FreezeBlock}. It tests:
 * <ul>
 *   <li>A known declaration</li>
 *   <li>Simple but block (constant expression)</li>
 * </ul>
 */
@Test
public void testFreezeBlockKnownDeclarationSimpleBut() {
    Project orgProject = new Project("testFreezeBlockKnownDeclarationSimpleBut");
    DecisionVariableDeclaration decl = new DecisionVariableDeclaration("decl", RealType.TYPE, orgProject);
    orgProject.add(decl);
    DecisionVariableDeclaration itrDecl = new DecisionVariableDeclaration("i", BooleanType.TYPE, orgProject);
    ConstantValue trueExpr = new ConstantValue(BooleanValue.TRUE);
    FreezeBlock freeze = new FreezeBlock(new IFreezable[] {decl}, itrDecl, trueExpr, orgProject);
    orgProject.add(freeze);
    
    java.util.Set<Project> allCopiedProjects = new HashSet<Project>();
    Project copiedProject = copyProject(orgProject, allCopiedProjects);
    // Attention: Ordering has changed
    FreezeBlock copiedBlock = (FreezeBlock) copiedProject.getElement(1);
    assertFreezeBlock(freeze, copiedBlock, copiedProject, allCopiedProjects);
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:24,代码来源:ProjectCopyVisitorTest.java

示例8: testFreezeBlockKnownDeclarationAnnotationBut

import net.ssehub.easy.varModel.model.values.BooleanValue; //导入依赖的package包/类
/**
 * Tests copying a {@link FreezeBlock}. It tests:
 * <ul>
 *   <li>A known declaration</li>
 *   <li>But expression on annotation</li>
 * </ul>
 */
@Test
public void testFreezeBlockKnownDeclarationAnnotationBut() {
    Project orgProject = new Project("testFreezeBlockKnownDeclarationAnnotationBut");
    Attribute annoDecl = new Attribute("anno", BooleanType.TYPE, orgProject, orgProject);
    orgProject.add(annoDecl);
    orgProject.attribute(annoDecl);
    Compound cType = new Compound("CP", orgProject);
    DecisionVariableDeclaration slotDecl = new DecisionVariableDeclaration("slot", StringType.TYPE, cType);
    cType.add(slotDecl);
    orgProject.add(cType);
    DecisionVariableDeclaration decl = new DecisionVariableDeclaration("decl", cType, orgProject);
    orgProject.add(decl);
    
    DecisionVariableDeclaration itrDecl = new DecisionVariableDeclaration("i", BooleanType.TYPE, orgProject);
    AttributeVariable annotationAccess = new AttributeVariable(new Variable(itrDecl), annoDecl);
    ConstantValue trueExpr = new ConstantValue(BooleanValue.TRUE);
    OCLFeatureCall equality = new OCLFeatureCall(annotationAccess, OclKeyWords.EQUALS, trueExpr); 
    FreezeBlock freeze = new FreezeBlock(new IFreezable[] {decl}, itrDecl, equality, orgProject);
    orgProject.add(freeze);
    
    java.util.Set<Project> allCopiedProjects = new HashSet<Project>();
    Project copiedProject = copyProject(orgProject, allCopiedProjects);
    FreezeBlock copiedBlock = (FreezeBlock) copiedProject.getElement(3);
    assertFreezeBlock(freeze, copiedBlock, copiedProject, allCopiedProjects);
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:33,代码来源:ProjectCopyVisitorTest.java

示例9: testSimplePartialEvaluationCopy

import net.ssehub.easy.varModel.model.values.BooleanValue; //导入依赖的package包/类
/**
 * Tests a copying of an evaluation block without problematic dependencies or nested declarations.
 * @throws CSTSemanticException If {@link Constraint#setConsSyntax(ConstraintSyntaxTree)} is not working.
 */
@Test
public void testSimplePartialEvaluationCopy() throws CSTSemanticException {
    Project orgProject = new Project("testSimplePartialEvaluationCopy");
    DecisionVariableDeclaration decl = new DecisionVariableDeclaration("decl", BooleanType.TYPE, orgProject);
    orgProject.add(decl);
    PartialEvaluationBlock evalBlock = new PartialEvaluationBlock("evalBlock", orgProject);
    Constraint constraint = new Constraint(evalBlock);
    OCLFeatureCall equality = new OCLFeatureCall(new Variable(decl), OclKeyWords.EQUALS,
        new ConstantValue(BooleanValue.TRUE));
    constraint.setConsSyntax(equality);
    evalBlock.setEvaluables(new IPartialEvaluable[] {constraint});
    orgProject.add(evalBlock);
    
    java.util.Set<Project> copiedProjects = new HashSet<Project>();
    Project copiedProject = copyProject(orgProject, copiedProjects);
    PartialEvaluationBlock copiedBlock = (PartialEvaluationBlock) copiedProject.getElement(1);
    assertEvalBlock(evalBlock, copiedBlock, copiedProject, copiedProjects);
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:23,代码来源:ProjectCopyVisitorTest.java

示例10: testDependingPartialEvaluationCopy

import net.ssehub.easy.varModel.model.values.BooleanValue; //导入依赖的package包/类
/**
 * Tests a copying of an evaluation block depending on a declaration defined at a later point.
 * @throws CSTSemanticException If {@link Constraint#setConsSyntax(ConstraintSyntaxTree)} is not working.
 */
@Test
public void testDependingPartialEvaluationCopy() throws CSTSemanticException {
    Project orgProject = new Project("testDependingPartialEvaluationCopy");
    DecisionVariableDeclaration decl = new DecisionVariableDeclaration("decl", BooleanType.TYPE, orgProject);
    PartialEvaluationBlock evalBlock = new PartialEvaluationBlock("evalBlock", orgProject);
    Constraint constraint = new Constraint(evalBlock);
    OCLFeatureCall equality = new OCLFeatureCall(new Variable(decl), OclKeyWords.EQUALS,
            new ConstantValue(BooleanValue.TRUE));
    constraint.setConsSyntax(equality);
    evalBlock.setEvaluables(new IPartialEvaluable[] {constraint});
    orgProject.add(evalBlock);
    orgProject.add(decl);
    
    java.util.Set<Project> copiedProjects = new HashSet<Project>();
    Project copiedProject = copyProject(orgProject, copiedProjects);
    PartialEvaluationBlock copiedBlock = (PartialEvaluationBlock) copiedProject.getElement(0);
    assertEvalBlock(evalBlock, copiedBlock, copiedProject, copiedProjects);
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:23,代码来源:ProjectCopyVisitorTest.java

示例11: testPartialEvaluationCopyWithInternallyDeclaredVariable

import net.ssehub.easy.varModel.model.values.BooleanValue; //导入依赖的package包/类
/**
 * Tests a copying of an evaluation block containing a constraining, which uses a
 * {@link DecisionVariableDeclaration} declared inside of the block.
 * @throws CSTSemanticException If {@link Constraint#setConsSyntax(ConstraintSyntaxTree)} is not working.
 */
@Test
public void testPartialEvaluationCopyWithInternallyDeclaredVariable() throws CSTSemanticException {
    Project orgProject = new Project("testPartialEvaluationCopyWithInternallyDeclaredVariable");
    PartialEvaluationBlock evalBlock = new PartialEvaluationBlock("evalBlock", orgProject);
    DecisionVariableDeclaration decl = new DecisionVariableDeclaration("decl", BooleanType.TYPE, evalBlock);
    Constraint constraint = new Constraint(evalBlock);
    OCLFeatureCall equality = new OCLFeatureCall(new Variable(decl), OclKeyWords.EQUALS,
        new ConstantValue(BooleanValue.TRUE));
    constraint.setConsSyntax(equality);
    evalBlock.setEvaluables(new IPartialEvaluable[] {constraint});
    orgProject.add(evalBlock);
    evalBlock.addModelElement(decl);
    
    java.util.Set<Project> copiedProjects = new HashSet<Project>();
    Project copiedProject = copyProject(orgProject, copiedProjects);
    PartialEvaluationBlock copiedBlock = (PartialEvaluationBlock) copiedProject.getElement(0);
    assertEvalBlock(evalBlock, copiedBlock, copiedProject, copiedProjects);
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:24,代码来源:ProjectCopyVisitorTest.java

示例12: testAssignBlockCopySimple

import net.ssehub.easy.varModel.model.values.BooleanValue; //导入依赖的package包/类
/**
 * Tests that simple {@link AttributeAssignment}s can be copied without outstanding dependencies.
 */
@Test
public void testAssignBlockCopySimple() {
    Project orgProject = new Project("testAssignBlockCopySimple");
    Attribute annoDecl = new Attribute("anno", BooleanType.TYPE, orgProject, orgProject);
    orgProject.add(annoDecl);
    orgProject.attribute(annoDecl);
    AttributeAssignment assignBlock = new AttributeAssignment(orgProject);
    ConstantValue constTrue = new ConstantValue(BooleanValue.TRUE);
    Assignment assignment = new Assignment(annoDecl.getName(), OclKeyWords.EQUALS, constTrue);
    assignBlock.add(assignment);
    DecisionVariableDeclaration decl = new DecisionVariableDeclaration("decl", StringType.TYPE, assignBlock);
    assignBlock.add(decl);
    orgProject.add(assignBlock);
    
    java.util.Set<Project> allCopiedProject = new HashSet<Project>();
    Project copy = copyProject(orgProject, allCopiedProject);
    AttributeAssignment copiedBlock = (AttributeAssignment) copy.getElement(1);
    assertAssignBlock(assignBlock, copiedBlock, copy, allCopiedProject);
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:23,代码来源:ProjectCopyVisitorTest.java

示例13: comparisionOperation

import net.ssehub.easy.varModel.model.values.BooleanValue; //导入依赖的package包/类
/**
 * Compares two numbers.
 * Supported comparisons are: less, less_equals, greater, and greater_equals.
 * @param operand the operand
 * @param arguments the arguments
 * @param strategy A {@link INumberComparator}, specifying which comparison should be used.
 * @return The result of the comparison. 
 */
private static EvaluationAccessor comparisionOperation(EvaluationAccessor operand,
    EvaluationAccessor[] arguments, INumberComparator strategy) {
    
    EvaluationAccessor result = null;
    if (null != operand && operand.getValue() != null && arguments.length == 1 && null != arguments[0].getValue()) {
        Object oValue = operand.getValue().getValue();
        Object aValue = arguments[0].getValue().getValue();
        
        if (oValue instanceof Number && aValue instanceof Number && null != strategy) {
            boolean booleanResult = strategy.compare((Number) oValue, (Number) aValue);
            
            result = ConstantAccessor.POOL.getInstance().bind(BooleanValue.toBooleanValue(booleanResult),
                operand.getContext());
        }
    }
    
    return result;
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:27,代码来源:GenericNumberOperations.java

示例14: evaluate

import net.ssehub.easy.varModel.model.values.BooleanValue; //导入依赖的package包/类
@Override
public EvaluationAccessor evaluate(EvaluationAccessor operand, EvaluationAccessor[] arguments) {
    // see VIL implementation            
    EvaluationAccessor result = null;
    Value value = operand.getValue();
    if (value instanceof ContainerValue) {
        ContainerValue cont = (ContainerValue) value;
        boolean hasDuplicates = false;
        int size = cont.getElementSize();
        if (size > 0) {
            Set<Value> known = new HashSet<Value>(size);
            for (int i = 0; !hasDuplicates && i < size; i++) {
                hasDuplicates = !known.add(cont.getElement(i));
            }
        }
        result = ConstantAccessor.POOL.getInstance().bind(
                BooleanValue.toBooleanValue(hasDuplicates), operand.getContext());
    }
    return result;
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:21,代码来源:SequenceOperations.java

示例15: visitMultiAndExpression

import net.ssehub.easy.varModel.model.values.BooleanValue; //导入依赖的package包/类
@Override
public void visitMultiAndExpression(MultiAndExpression expression) {
    Boolean res = Boolean.TRUE;
    for (int e = 0; Boolean.TRUE == res && e < expression.getExpressionCount(); e++) {
        expression.getExpression(e).accept(this);
        if (null != result) {
            Value val = result.getValue();
            clearResult();
            if (val instanceof BooleanValue) {
                res = ((BooleanValue) val).getValue();
            } else {
                res = null;
            }
        } else {
            res = null;
        }
    }
    if (null != res) {
        result = ConstantAccessor.POOL.getInstance().bind(BooleanValue.toBooleanValue(res), context);
    }
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:22,代码来源:EvaluationVisitor.java


注:本文中的net.ssehub.easy.varModel.model.values.BooleanValue类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。