Giter Club home page Giter Club logo

groovy-params-checker's Introduction

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.

groovy-params-checker's People

Contributors

xnickmx avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.