<commit_before>[![Travis CI](https://img.shields.io/travis/tvinke/bulletproof.svg)](https://travis-ci.org/tvinke/bulletproof)
# Bulletproof
*Groovy AST transformations, such as @Value and @NonNull, which makes constructing an instance more bullet-proof.*

![bulletproof logo](https://raw.githubusercontent.com/tvinke/bulletproof/master/logo.png)

Groovy has the `Immutable` annotation which allows to create immutable classes, which is a prerequisite for creating [value objects](https://en.wikipedia.org/wiki/Value_object). Unfortunately, when a class has been annotated with `Immutable` it's no longer possible to add your own constructor to verify if provided parameters are not `null`, making our value objects really bullet-proof.

Bulletproof helps to fill this gap by adding a few AST transformations.
 * The `NonNull` annotation which modifies every constructor to perform null-checks. Add this to an `Immutable` class and no `null` slips past your constructor.
 * The `Value` meta-annotation which puts both `NonNull` and `Immutable` on your class as a convenience to do above step with one annotation.

## Contents
 * [Annotations](#annotations)
   * [@NonNull](#nonnull)
   * [@Value](#value)
 * [Future Changes](#future-changes)

## Annotations

Consult the [bulletproof 0.1 Groovydocs](http://tvinke.github.io/bulletproof/v0.1/groovydoc/) for complete API information.

### NonNull

The `NonNull` annotation on the class-level triggers an AST transformation which modifies every constructor to perform a null-check.

```groovy
@groovy.transform.Immutable
@tvinke.bulletproof.transform.NonNull
class Person {
    String name
}
new Person() // throws IllegalArgumentException: "Name can not be null"
```

### Value
<commit_msg>Add installation instructions<commit_after>[![Travis CI](https://img.shields.io/travis/tvinke/bulletproof.svg)](https://travis-ci.org/tvinke/bulletproof)
[![Maven Central](https://img.shields.io/maven-central/v/com.github.tvinke/bulletproof.svg)](http://repo1.maven.org/maven2/com/github/tvinke/bulletproof/0.1/bulletproof-0.1.jar)
[![GitHub release](https://img.shields.io/github/tag/tvinke/bulletproof.svg)](https://github.com/tvinke/bulletproof/releases/tag/v0.1)
# Bulletproof
*Groovy AST transformations, such as @Value and @NonNull, which makes constructing an instance more bullet-proof.*

![bulletproof logo](https://raw.githubusercontent.com/tvinke/bulletproof/master/logo.png)

Groovy has the `Immutable` annotation which allows to create immutable classes, which is a prerequisite for creating [value objects](https://en.wikipedia.org/wiki/Value_object). Unfortunately, when a class has been annotated with `Immutable` it's no longer possible to add your own constructor to verify if provided parameters are not `null`, making our value objects really bullet-proof.

Bulletproof helps to fill this gap by adding a few AST transformations.
 * The `NonNull` annotation which modifies every constructor to perform null-checks. Add this to an `Immutable` class and no `null` slips past your constructor.
 * The `Value` meta-annotation which puts both `NonNull` and `Immutable` on your class as a convenience to do above step with one annotation.

## Contents
 * [Prerequisites](#prerequisites)
 * [Installation](#installation)
 * [Annotations](#annotations)
   * [@NonNull](#nonnull)
   * [@Value](#value)
 * [Future Changes](#future-changes)

## Prerequisites

Bulletproof requires Java 7 or later.

## Installation

Add the bulletproof jar to the classpath in your preferred way and you're set.

### Grape
```groovy
@Grab('com.github.tvinke:bulletproof:0.1') 
```

### Gradle
```groovy
compile group: 'com.github.tvinke', name: 'bulletproof', version: '0.1'
```

### Maven
```xml
 <dependency>
    <groupId>com.github.tvinke</groupId>
    <artifactId>bulletproof</artifactId>
    <version>0.1</version>
</dependency>
```

## Annotations

Consult the [bulletproof 0.1 Groovydocs](http://tvinke.github.io/bulletproof/v0.1/groovydoc/) for complete API information.

### NonNull

The `NonNull` annotation on the class-level triggers an AST transformation which modifies every constructor to perform a null-check.

```groovy
@groovy.transform.Immutable
@tvinke.bulletproof.transform.NonNull
class Person {
    String name
}
new Person() // throws IllegalArgumentException: "Name can not be null"
```

### Value

{'fraction_non_alphanumeric': 0.11762003216172755, 'fraction_numerical': 0.005283712382265104, 'mean_word_length': 5.175886524822695, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 11, 'lorem ipsum': 0, 'www.': 0, 'xml': 1}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '388055', 'n_tokens_mistral': 1351, 'n_tokens_neox': 1247, 'n_words': 409}