Java - Assert (Inline code Assertion)

> Procedural Languages > Java

Table of Contents

1 - About

2 - Syntax

assert Expression1 : Expression2 ;

where:

  • Expression1 is a boolean expression.
  • Expression2 is an expression that has a value. (It cannot be an invocation of a method that is declared void.)
Advertising

3 - Example

// TypeCode or Java Class must be present
assert !(columnMetadata.getColumnTypeCode() == null && columnMetadata.getColumnTypeJava() == null) : "The column (" + columnMetadata.getColumnName() + ") has its type code and java type Null";
java.lang.AssertionError: The column (column1) has its type code and java type Null

	at net.bytle.table.database.Databases.getDataTypeOf(Databases.java:180)
	at net.bytle.table.database.Databases.getCreateTableStatementColumnsDefinition(Databases.java:129)
	at net.bytle.table.database.Databases.getCreateTableStatement(Databases.java:104)
	at net.bytle.table.TableLoader.TableLoader.<init>(TableLoader.java:110)
	at net.bytle.table.TableLoader.TableLoaderSqliteTest.dataLoadTest(TableLoaderSqliteTest.java:52)
lang/java/aseert.txt · Last modified: 2017/09/17 17:36 by gerardnico