## Sanitizer ##

Annotate member variables for sanitation

```java
public class User {
    @ConcurrentSpace
    private String name;
}
```

Instantiate

```java
Sanitizer sanitizer = new Sanitizer(object);
```

Sanitize

```java
sanitizer.sanitize();
```

### Recursive sanitation ###

To traverse into embedded objects, collections, and arrays of non-primitive
types, enable recursion before calling `sanitize()`:

```java
new Sanitizer(object).recursive().sanitize();
```

Recursion follows non-`java.*` package types and `Collection` elements,
skipping primitives, enums, and `null` entries.

### Supported value types ###

Every annotation below is applied to `String` values directly. When the
annotated field is one of the following, every element is cleansed in place:

- `String`
- `Collection<String>` (e.g. `List<String>`, `Set<String>`)
- `String[]`

If the annotated `Collection` is unmodifiable, the cleansed values cannot be
written back and the field is left untouched.

## Accent ##

Strip accents from characters

```java
@Accent
```

## Concurrent Space ##

Replaces all concurrent spaces with single space

```java
@ConcurrentSpace
```

Example:

```java
User user = new User("John   Doe");
new Sanitizer(user).sanitize();
System.out.println(user.getName());
```

Output

```
John Doe
```

## Lowercase ##

Lowercase all characters

```java
@Lowercase
```

## Remove ##

Removes all literal occurrences of the given string. The argument is **not**
treated as a regular expression, so characters such as `.`, `*`, and `(` are
matched literally.

```java
@Remove("-")
```

Required
- value - [String]

## Trim ##

Remove leading and trailing spaces

```java
@Trim
```

## Trim to Null ##

Remove leading and trailing spaces and return null if empty

```java
@TrimToNull
```

## Uppercase ##

Uppercase all characters

```java
@Uppercase
```

## Custom ##

Sanitizes against a custom class

```java
@CustomSanitizer(MyCleanser.class)
```

Required
- value - Class that implements `Cleanser` or `ObjectAwareCleanser`

**Note:** The class supplied to `@CustomSanitizer` must implement either the
`Cleanser` or `ObjectAwareCleanser` interface and expose a public no-argument
constructor. If the class implements neither interface, the field is
silently skipped. If the class cannot be instantiated reflectively, an
`IllegalStateException` is thrown.

### Object-aware custom sanitizers ###

`Cleanser` only sees the annotated field's own value. For rules that depend
on a sibling field on the same object, implement `ObjectAwareCleanser`
instead:

```java
public class DiscountCodeCleanser implements ObjectAwareCleanser<String> {

    @Override
    public String cleanse(Object owner, String value) {
        Order order = (Order) owner;
        return "VIP".equals(order.getTier()) ? value.toUpperCase() : value;
    }

    @Override
    public String description() {
        return "Normalizes discount codes for VIP tier orders";
    }
}
```

`owner` is the object instance that owns the annotated field, so the
cleanser can read sibling fields to decide how to cleanse the value.

## Error handling ##

Reflective failures while reading or writing fields are surfaced as
`IllegalStateException` with the originating exception attached as the cause.
This replaces the previous behavior of writing stack traces to standard error.

