/** * <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); }
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)); } }
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); } }
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); } }
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); } }
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); } }
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); } }
throws JPRACompilerParseException Preconditions.checkPreconditionV( Objects.equals(PACKAGE_BEGIN, se.text()), "Text must be %s",
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); } }
throws JPRACompilerParseException Preconditions.checkPreconditionV( Objects.equals(VECTOR, se.text()), "Text must be %s",
throws JPRACompilerParseException Preconditions.checkPreconditionV( Objects.equals(BOOLEAN_SET, se.text()), "Text must be %s",
throws JPRACompilerParseException Preconditions.checkPreconditionV( Objects.equals(ARRAY, se.text()), "Text must be %s",
throws JPRACompilerParseException Preconditions.checkPreconditionV( Objects.equals(IMPORT, se.text()), "Text must be %s",
throws JPRACompilerParseException Preconditions.checkPreconditionV( Objects.equals(STRING, se.text()), "Text must be %s",
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); }
throws JPRACompilerParseException Preconditions.checkPreconditionV( Objects.equals(RECORD, se.text()), "Text must be %s",
throws JPRACompilerParseException Preconditions.checkPreconditionV( Objects.equals(PACKED, se.text()), "Text must be %s",
Preconditions.checkPreconditionV( this.imports.containsKey(q_name), "Imports must contain %s",
Preconditions.checkPreconditionV( tt instanceof TypeUserDefinedType, "Type must be an instance of %s",
this.import_names.inverse(); Preconditions.checkPreconditionV( ini.containsKey(q_existing), "Import names must contain %s", q_existing);