Telosys doc
WebsiteTwitterLinkedInNews
  • Telosys documentation
  • Telosys CLI
    • Installation on Linux
    • Installation on Windows
    • CLI configuration
    • CLI commands
    • Getting started
  • Telosys with VSCode
    • Extension installation
    • VSCode settings
    • Telosys terminal in VSCode
    • Telosys editor configuration
  • Telosys with JetBrains IDE
  • Project configuration
  • Project variables
  • Project databases
  • Models and entities
    • Model structure
    • Entity
    • Attribute / Link
    • Annotations
    • Tags
    • Examples
    • Model creation
    • Model installation
    • Models management
  • Bundles of templates
    • Bundle structure
    • Bundle creation
    • Bundles installation
    • Bundles management
    • Velocity language
    • Velocity directives
    • Velocity object types
    • Telosys directives
    • Telosys variables
    • Telosys objects
    • Code snippets
  • Code generation
    • "gen" command
    • "genb" command
  • Target languages
    • C++
    • C#
    • Golang
    • Java
    • JavaScript
    • Kotlin
    • PHP
    • Python
    • Scala
    • TypeScript
  • Target databases (SQL)
    • Predefined rules
    • Specific rules
    • Type size and precision
  • Telosys with Git
    • GitHub usage
    • Install with Git
    • Publish with Git
  • Support the project
  • How to contribute
  • Sponsors
  • IDE and editors
  • Telosys 3 Eclipse plugin
    • Eclipse plugin installation
    • Eclipse customization
    • Telosys 3 database model
Powered by GitBook
On this page
  • #assertFalse
  • #assertTrue
  • #cancel
  • #checkId
  • #error
  • #using
  1. Bundles of templates

Telosys directives

In addition to the standard Velocity language syntax, Telosys provides some specific "directives".

These directives can be useful to simplify writing or debugging templates.

#assertFalse

( Telosys specific directive - since version 2.0.7 )

Checks that the value of the first argument is FALSE. Otherwise throws an error with the given message.

Examples :

 #assertFalse( $flag, "Flag is true (false expected)" ) 
 #assertFalse( $entity.hasCompositePrimaryKey(), "Composite Primary Key not supported" ) 

#assertTrue

( Telosys specific directive - since version 2.0.7 )

Checks that the value of the first argument is TRUE. Otherwise throws an error with the given message.

Examples :

 #assertTrue( $flag, "Flag is not true!" ) 
 #assertTrue( $entity.hasPrimaryKey(), "Primary Key required!" )

#cancel

( Telosys specific directive - since version 3.3.0 )

Cancels the current generation. When "#cancel" is used in a template the target file is not generated. This directive is useful when certain entities are not supposed to be generated. A cancellation is not considered as an error (no reported in errors).

This directive has only one argument: a message to indicate why the generation was canceled

Examples :

#if ( $entity.name.startsWith("Abcd") )
#cancel("No JPA class for this entity")
#end

#checkId

( Telosys specific directive - since version 3.0.0 )

Checks the existence of ID/Primary Key in the given entity. Throws an error if there's no ID/Primary Key defined in the entity.

Examples :

 #checkId( $entity) 

#error

( Telosys specific directive - since version 2.0.7 )

Throws an error with the given message

Examples :

 #if( $flag ) 
 #error( "Flag is true!" ) 
 #end 

 #if( ! $entity.hasPrimaryKey() ) 
 #error( "Primary Key required!" ) 
 #end 

#using

( Telosys specific directive - since version 2.0.7 )

Declares that the current template will use unusual objects or variables which must therefore be defined in the context. This directive verifies that all required objects or variables are defined in the Velocity context. It throws an error if one of the given objects is not defined. Often used to verify that required specific variables have been defined.

Examples :

 #using( "var1" ) 
 #using( "var1", "var2" ) 
 #using( "var1", "var2", "foo", "bar" ) 

 #using( '$var1' ) 
 #using( '$var1', '$var2' ) 
PreviousVelocity object typesNextTelosys variables

Last updated 1 month ago