本文整理了Java中com.io7m.jaffirm.core.Preconditions.checkPreconditionV()
方法的一些代码示例,展示了Preconditions.checkPreconditionV()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Preconditions.checkPreconditionV()
方法的具体详情如下:
包路径:com.io7m.jaffirm.core.Preconditions
类名称:Preconditions
方法名:checkPreconditionV
[英]A version of #checkPrecondition(boolean,String) that constructs a description message from the given format string and arguments.
Note that the use of variadic arguments may entail allocating memory on virtual machines that fail to eliminate the allocations with escape analysis.
[中]#checkPremission(boolean,String)的一个版本,它根据给定的格式字符串和参数构造描述消息。
请注意,使用可变参数可能需要在虚拟机上分配内存,这些虚拟机无法通过转义分析消除分配。
代码示例来源:origin: com.io7m.jaffirm/com.io7m.jaffirm.core
/**
* <p>A version of {@link #checkPrecondition(boolean, String)} that constructs
* a description message from the given format string and arguments.</p>
*
* <p>Note that the use of variadic arguments may entail allocating memory on
* virtual machines that fail to eliminate the allocations with <i>escape
* analysis</i>.</p>
*
* @param condition The predicate
* @param format The format string
* @param objects The format string arguments
*
* @since 1.1.0
*/
public static void checkPreconditionV(
final boolean condition,
final String format,
final Object... objects)
{
checkPreconditionV("<unspecified>", condition, format, objects);
}
代码示例来源:origin: com.io7m.jptbox/com.io7m.jptbox.core
private void checkXY(
final int x,
final int y)
{
Preconditions.checkPreconditionV(
x >= 0,
"X (%d) must be >= 0",
Integer.valueOf(x));
Preconditions.checkPreconditionV(
x < this.width,
"X (%d) must be < width (%d)",
Integer.valueOf(x),
Integer.valueOf(this.width));
Preconditions.checkPreconditionV(
y >= 0,
"Y (%d) must be >= 0",
Integer.valueOf(y));
Preconditions.checkPreconditionV(
y < this.height,
"Y (%d) must be < height (%d)",
Integer.valueOf(y),
Integer.valueOf(this.height));
}
}
代码示例来源:origin: com.io7m.jpra/com.io7m.jpra.compiler.core
private StatementPackageEnd<Unresolved, Untyped> parsePackageEnd(
final SExpressionListType le,
final SExpressionSymbolType se)
throws JPRACompilerParseException
{
Preconditions.checkPreconditionV(
Objects.equals(PACKAGE_END, se.text()),
"Text must be %s",
PACKAGE_END);
if (le.size() == 1) {
return new StatementPackageEnd<>(getExpressionLexical(se));
}
try (final ByteArrayOutputStream bao = new ByteArrayOutputStream(256)) {
this.serial.serialize(le, bao);
final StringBuilder sb = new StringBuilder(128);
sb.append("Syntax error.");
sb.append(System.lineSeparator());
sb.append(" Expected: (package-end)");
sb.append(System.lineSeparator());
sb.append(" Got: ");
sb.append(bao.toString(StandardCharsets.UTF_8.name()));
throw JPRACompilerParseException.syntaxError(le, sb.toString());
} catch (final IOException e) {
throw new UnreachableCodeException(e);
}
}
代码示例来源:origin: com.io7m.jpra/com.io7m.jpra.compiler.core
private SizeExprType<Unresolved, Untyped> parseSizeInOctets(
final SExpressionListType le,
final SExpressionSymbolType se)
throws JPRACompilerParseException
{
Preconditions.checkPreconditionV(
Objects.equals(SIZE_IN_OCTETS, se.text()),
"Text must be %s",
SIZE_IN_OCTETS);
if (le.size() == 2) {
return new SizeExprInOctets<>(this.parseTypeExpression(le.get(1)));
}
try (final ByteArrayOutputStream bao = new ByteArrayOutputStream(256)) {
this.serial.serialize(le, bao);
final StringBuilder sb = new StringBuilder(128);
sb.append("Syntax error.");
sb.append(System.lineSeparator());
sb.append(" Expected: (size-in-octets <type-expression>)");
sb.append(System.lineSeparator());
sb.append(" Got: ");
sb.append(bao.toString(StandardCharsets.UTF_8.name()));
throw JPRACompilerParseException.syntaxError(le, sb.toString());
} catch (final IOException e) {
throw new UnreachableCodeException(e);
}
}
代码示例来源:origin: com.io7m.jpra/com.io7m.jpra.compiler.core
private StatementCommandSize<Unresolved, Untyped> parseCommandSize(
final SExpressionListType le,
final SExpressionSymbolType se)
throws JPRACompilerParseException
{
Preconditions.checkPreconditionV(
Objects.equals(COMMAND_SIZE, se.text()),
"Text must be %s",
COMMAND_SIZE);
if (le.size() == 2) {
return new StatementCommandSize<>(this.parseSizeExpression(le.get(1)));
}
try (final ByteArrayOutputStream bao = new ByteArrayOutputStream(256)) {
this.serial.serialize(le, bao);
final StringBuilder sb = new StringBuilder(128);
sb.append("Syntax error.");
sb.append(System.lineSeparator());
sb.append(" Expected: (:size <size-expression>)");
sb.append(System.lineSeparator());
sb.append(" Got: ");
sb.append(bao.toString(StandardCharsets.UTF_8.name()));
throw JPRACompilerParseException.syntaxError(le, sb.toString());
} catch (final IOException e) {
throw new UnreachableCodeException(e);
}
}
代码示例来源:origin: com.io7m.jpra/com.io7m.jpra.compiler.core
private StatementCommandType<Unresolved, Untyped> parseCommandType(
final SExpressionListType le,
final SExpressionSymbolType se)
throws JPRACompilerParseException
{
Preconditions.checkPreconditionV(
Objects.equals(COMMAND_TYPE, se.text()),
"Text must be %s",
COMMAND_TYPE);
if (le.size() == 2) {
return new StatementCommandType<>(this.parseTypeExpression(le.get(1)));
}
try (final ByteArrayOutputStream bao = new ByteArrayOutputStream(256)) {
this.serial.serialize(le, bao);
final StringBuilder sb = new StringBuilder(128);
sb.append("Syntax error.");
sb.append(System.lineSeparator());
sb.append(" Expected: (:type <type-expression>)");
sb.append(System.lineSeparator());
sb.append(" Got: ");
sb.append(bao.toString(StandardCharsets.UTF_8.name()));
throw JPRACompilerParseException.syntaxError(le, sb.toString());
} catch (final IOException e) {
throw new UnreachableCodeException(e);
}
}
代码示例来源:origin: com.io7m.jpra/com.io7m.jpra.compiler.core
private SizeExprType<Unresolved, Untyped> parseSizeInBits(
final SExpressionListType le,
final SExpressionSymbolType se)
throws JPRACompilerParseException
{
Preconditions.checkPreconditionV(
Objects.equals(SIZE_IN_BITS, se.text()),
"Text must be %s",
SIZE_IN_BITS);
if (le.size() == 2) {
return new SizeExprInBits<>(this.parseTypeExpression(le.get(1)));
}
try (final ByteArrayOutputStream bao = new ByteArrayOutputStream(256)) {
this.serial.serialize(le, bao);
final StringBuilder sb = new StringBuilder(128);
sb.append("Syntax error.");
sb.append(System.lineSeparator());
sb.append(" Expected: (size-in-bits <type-expression>)");
sb.append(System.lineSeparator());
sb.append(" Got: ");
sb.append(bao.toString(StandardCharsets.UTF_8.name()));
throw JPRACompilerParseException.syntaxError(le, sb.toString());
} catch (final IOException e) {
throw new UnreachableCodeException(e);
}
}
代码示例来源:origin: com.io7m.jpra/com.io7m.jpra.compiler.core
throws JPRACompilerParseException
Preconditions.checkPreconditionV(
Objects.equals(PACKAGE_BEGIN, se.text()),
"Text must be %s",
代码示例来源:origin: com.io7m.jpra/com.io7m.jpra.compiler.core
private TypeExprType<Unresolved, Untyped> parseTypeFloat(
final SExpressionListType le,
final SExpressionSymbolType se)
throws JPRACompilerParseException
{
Preconditions.checkPreconditionV(
Objects.equals(FLOAT, se.text()),
"Text must be %s",
FLOAT);
if (le.size() == 2) {
final SExpressionType s_expr = le.get(1);
return new TypeExprFloat<>(
Untyped.get(),
getExpressionLexical(s_expr),
this.parseSizeExpression(s_expr));
}
try (final ByteArrayOutputStream bao = new ByteArrayOutputStream(256)) {
this.serial.serialize(le, bao);
final StringBuilder sb = new StringBuilder(128);
sb.append("Syntax error.");
sb.append(System.lineSeparator());
sb.append(" Expected: (float <size-in-bits>)");
sb.append(System.lineSeparator());
sb.append(" Got: ");
sb.append(bao.toString(StandardCharsets.UTF_8.name()));
throw JPRACompilerParseException.syntaxError(le, sb.toString());
} catch (final IOException e) {
throw new UnreachableCodeException(e);
}
}
代码示例来源:origin: com.io7m.jpra/com.io7m.jpra.compiler.core
throws JPRACompilerParseException
Preconditions.checkPreconditionV(
Objects.equals(VECTOR, se.text()),
"Text must be %s",
代码示例来源:origin: com.io7m.jpra/com.io7m.jpra.compiler.core
throws JPRACompilerParseException
Preconditions.checkPreconditionV(
Objects.equals(BOOLEAN_SET, se.text()),
"Text must be %s",
代码示例来源:origin: com.io7m.jpra/com.io7m.jpra.compiler.core
throws JPRACompilerParseException
Preconditions.checkPreconditionV(
Objects.equals(ARRAY, se.text()),
"Text must be %s",
代码示例来源:origin: com.io7m.jpra/com.io7m.jpra.compiler.core
throws JPRACompilerParseException
Preconditions.checkPreconditionV(
Objects.equals(IMPORT, se.text()),
"Text must be %s",
代码示例来源:origin: com.io7m.jpra/com.io7m.jpra.compiler.core
throws JPRACompilerParseException
Preconditions.checkPreconditionV(
Objects.equals(STRING, se.text()),
"Text must be %s",
代码示例来源:origin: com.io7m.jpra/com.io7m.jpra.compiler.core
void putType(final TypeUserDefinedType t)
{
Preconditions.checkPreconditionV(
!this.types.contains(t.getName()),
"Types must not contain %s",
t.getName());
this.types.put(t.getName(), t);
}
代码示例来源:origin: com.io7m.jpra/com.io7m.jpra.compiler.core
throws JPRACompilerParseException
Preconditions.checkPreconditionV(
Objects.equals(RECORD, se.text()),
"Text must be %s",
代码示例来源:origin: com.io7m.jpra/com.io7m.jpra.compiler.core
throws JPRACompilerParseException
Preconditions.checkPreconditionV(
Objects.equals(PACKED, se.text()),
"Text must be %s",
代码示例来源:origin: com.io7m.jpra/com.io7m.jpra.compiler.core
Preconditions.checkPreconditionV(
this.imports.containsKey(q_name),
"Imports must contain %s",
代码示例来源:origin: com.io7m.jpra/com.io7m.jpra.compiler.core
Preconditions.checkPreconditionV(
tt instanceof TypeUserDefinedType,
"Type must be an instance of %s",
代码示例来源:origin: com.io7m.jpra/com.io7m.jpra.compiler.core
this.import_names.inverse();
Preconditions.checkPreconditionV(
ini.containsKey(q_existing),
"Import names must contain %s", q_existing);
内容来源于网络,如有侵权,请联系作者删除!