本文整理汇总了Java中com.sri.ai.util.Util.myAssert方法的典型用法代码示例。如果您正苦于以下问题:Java Util.myAssert方法的具体用法?Java Util.myAssert怎么用?Java Util.myAssert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sri.ai.util.Util
的用法示例。
在下文中一共展示了Util.myAssert方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: replace
import com.sri.ai.util.Util; //导入方法依赖的package包/类
@Override
public Expression replace(Expression expression, Expression newSubExpression) {
AbstractQuantifiedExpression quantifiedExpression = castOrThrowError(AbstractQuantifiedExpression.class, expression, "Attempt to use " + IndexExpressionTypeSubExpressionAddress.class.getSimpleName() + " to replace sub-expression " + newSubExpression + " in %s, but the latter should have been an instance of %s but is instead an instance of %s");
Util.myAssert(() -> quantifiedExpression.getIndexExpressions() instanceof ExtensionalIndexExpressionsSet, () -> quantifiedExpression.getClass().getSimpleName() + ".replaceIndexExpression assumes extensional set of index expressions but " + quantifiedExpression + " has a non-extensional index expression set");
List<Expression> indexExpressionsList = ((ExtensionalIndexExpressionsSet) quantifiedExpression.getIndexExpressions()).getList();
List<Expression> newIndexExpressionsList =
replaceElementNonDestructively(indexExpressionsList, indexExpressionIndex,
ie -> replaceAddressedSubExpressionInIndexExpressionByNewSubExpression(ie, newSubExpression));
Expression result;
if (newIndexExpressionsList != indexExpressionsList) {
IndexExpressionsSet newIndexExpressions = new ExtensionalIndexExpressionsSet(newIndexExpressionsList);
result = quantifiedExpression.setIndexExpressions(newIndexExpressions);
}
else {
result = quantifiedExpression;
}
return result;
}
示例2: nullary
import com.sri.ai.util.Util; //导入方法依赖的package包/类
private void nullary() {
try {
Util.myAssert(() -> true , () -> "error message 1");
Util.myAssert(() -> false, () -> "error message 2");
if (System.getProperty(Util.MY_ASSERT_OFF) == null) {
fail("Should have thrown an AssertionError but did not. System.getProperty(Util.MY_ASSERT_OFF) = " + System.getProperty(Util.MY_ASSERT_OFF));
}
}
catch (AssertionError error) {
if (error.getMessage().equals("error message 2")) {
if (System.getProperty(Util.MY_ASSERT_OFF) == null) {
// good, passed the unit test
}
else {
fail("Threw assertion error when it should not have.");
}
}
else {
fail("Threw the wrong assertion error.");
}
}
// good, passed the unit test
}
示例3: isLiteral
import com.sri.ai.util.Util; //导入方法依赖的package包/类
/**
* Convenience for <code>this.getTheory().isLiteral(expression, this)</code>.
* @param expression
* @return
*/
default boolean isLiteral(Expression expression) {
Theory theory = getTheory();
Util.myAssert(theory != null, () -> "Context does not contain a theory, but is trying to check if " + expression + " is a literal according to some theory. Please make sure the context has been provided a theory");
boolean result = theory.isLiteralOrBooleanConstant(expression, this);
return result;
}
示例4: extendWithSymbolsAndTypes
import com.sri.ai.util.Util; //导入方法依赖的package包/类
/**
* Extends with pairs of symbols and their respective types represented as strings.
* @param symbolsAndTypes
* @return
*/
default Registry extendWithSymbolsAndTypes(Expression... symbolsAndTypes) {
Util.myAssert(symbolsAndTypes.length % 2 == 0, () -> "Need to extend registry with a sequence of symbols and their types");
List<Expression> indexExpressions = makeIndexExpressionsFromSymbolsAndTypes(symbolsAndTypes);
Registry result = extendWith(new ExtensionalIndexExpressionsSet(indexExpressions));
return result;
}
示例5: getExpressionAndIndexExpressionsFromProblemExpression
import com.sri.ai.util.Util; //导入方法依赖的package包/类
@Override
public Pair<Expression, IndexExpressionsSet> getExpressionAndIndexExpressionsFromProblemExpression(Expression expression, Context context) {
String functorString = getFunctionString();
Util.myAssert(() -> expression.hasFunctor(functorString), () -> "Expression expected to be application of " + functorString + " but is " + expression);
IntensionalSet set = (IntensionalSet) expression.get(0);
Expression body = IfThenElse.make(set.getCondition(), set.getHead(), additiveIdentityElement());
Pair<Expression, IndexExpressionsSet> result = Pair.make(body, set.getIndexExpressions());
return result;
}
示例6: assertFunctionType
import com.sri.ai.util.Util; //导入方法依赖的package包/类
/**
* Assert that the give expression represents a function type application.
*
* @param expression
* the expression to be tested.
*/
public static void assertFunctionType(Expression expression) {
Util.myAssert(expression.hasFunctor(FUNCTION_TYPE), () -> "Functor in expression " + expression
+ " should be a functional type (that is, have functor '->')");
Util.myAssert(expression.numberOfArguments() == 1 || expression.numberOfArguments() == 2,
() -> "Function type has illegal number of arguments (should be 1 or 2), has "
+ expression.numberOfArguments() + " for " + expression);
}
示例7: CompoundTheory
import com.sri.ai.util.Util; //导入方法依赖的package包/类
public CompoundTheory(Theory... subTheoriesArray) {
super();
this.subTheories = list(subTheoriesArray);
Util.myAssert(() -> subTheories.size() != 0, () -> getClass() + " needs to receive at least one sub-theory but got none.");
}
示例8: replace
import com.sri.ai.util.Util; //导入方法依赖的package包/类
@Override
public Expression replace(Expression expression, Expression newSubExpression) {
Util.myAssert(() -> expression instanceof AbstractExtensionalSet, () -> getClass().getSimpleName() + ".IndexAddress applied to expression " + expression + " of class " + expression.getClass());
Expression result = ((ExtensionalSet)expression).setElementDefinition(this.index, newSubExpression);
return result;
}
示例9: getSubExpressionOf
import com.sri.ai.util.Util; //导入方法依赖的package包/类
@Override
public Expression getSubExpressionOf(Expression expression) {
Util.myAssert(() -> expression instanceof AbstractExtensionalSet, () -> getClass().getSimpleName() + ".IndexAddress applied to expression " + expression + " of class " + expression.getClass());
Expression result = ((AbstractExtensionalSet) expression).getElementDefinition(index);
return result;
}
示例10: replace
import com.sri.ai.util.Util; //导入方法依赖的package包/类
@Override
public Expression replace(Expression expression, Expression newSubExpression) {
Util.myAssert(() -> expression instanceof DefaultTuple, () -> DefaultTuple.class.getSimpleName() + ".IndexAddress applied to expression " + expression + " of class " + expression.getClass());
Expression result = expression.set(this.index, newSubExpression);
return result;
}
示例11: replace
import com.sri.ai.util.Util; //导入方法依赖的package包/类
@Override
public Expression replace(Expression expression, Expression newSubExpression) {
Util.myAssert(() -> expression.getSyntacticFormType().equals(FunctionApplication.SYNTACTIC_FORM_TYPE), () -> DefaultFunctionApplication.class.getSimpleName() + ".IndexAddress applied to expression " + expression + " of class " + expression.getClass());
Expression result = expression.set(this.index, newSubExpression);
return result;
}
示例12: computeCurrent
import com.sri.ai.util.Util; //导入方法依赖的package包/类
public T computeCurrent() {
Util.myAssert(baseCurrentIsInitialized, () -> "No current element defined for iterator.");
T result = function.apply(baseCurrent);
return result;
}