Skip to content

xnickmx/groovy-params-checker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

groovy-params-checker

Automatic Groovy parameter checker

What is this?

A tool to automatically check Groovy class method parameters to make sure they aren't null or empty.

Why would you use it?

You would use this if you:

  • Like your code to fail fast
  • Don't like writing boilerplate code
  • Don't like writing extra unit tests
  • Need a solution that supports Groovy
  • Prefer as solution that requires zero configuration to use

How to Use

  1. Include this project in your code via sources, Gradle, Maven, etc.
  2. Annotate your Groovy classes with @ParamsNotNullNotEmpty.
  3. At compile time, code will be added into each of your methods to check each parameter to make sure it is not null and in the case of Collections, Maps and Strings, it is not empty.
  4. At run time, if a parameter is null or empty, it will throw an IllegalArgumentException with details about the null or empty parameter.
  5. To disable the annotation at compile time, set the ParamsNotNullNotEmpty.NoOpMode property to true.

Example Usage

See the integration tests

Maven Central

Include in your Ant/Gradle/Grails/Maven project using binaries from Maven central

com.faceture groovy-params-checker 1.0.27

Informed and Inspired by

This project was informed and inspired by other great work:

  1. Groovy 1.6 AST Transformation Example blog and code by Kartik Shah.

  2. "AST Transformations: Prerequisites and Annotations" blog and code by Joachim Baumann.

  3. GContracts code by Andre Steingress.

About

Automatic Groovy parameter checker.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages