<commit_before>xtend-contrib
=================

A collection of Active Annotations that will be useful in many projects, but which would be too controversial to include in the Xtend standard library.

[![Build Status](https://oehme.ci.cloudbees.com/job/xtend-contrib/badge/icon)](https://oehme.ci.cloudbees.com/job/xtend-contrib/)
```xml
<dependency>
  <groupId>com.github.oehme.xtend</groupId>
  <artifactId>xtend-contrib</artifactId>
  <version>[0.5,0.6)</version>
</dependency>
```
Features
========

You can see all the features in action in the [examples project](https://github.com/oehme/xtend-contrib/tree/master/xtend-contrib-examples/src/main/java/de/oehme/xtend/contrib/examples)

@Cached
-------
Caches invocations of a method, e.g. to make recursive algorithms more efficient.
```xtend
@Cached
def BigInteger fibonacci(int n) {
    switch n {
        case 0: 0bi
        case 1: 1bi
        default: fibonacci(n - 1) + fibonacci(n - 2)
    }
}
```

@Buildable
--------
Creates a fluent Builder for ValueObjects. Works nicely with the @Data annotation that is shipped with Xtend by default.
```xtend
@Data
@Buildable
class Person {
    String firstName
    String lastName
    int age
}
```

@Messages
---------
Creates a statically typed facade for localization ResourceBundles.
The generated methods take an argument for each placeholder in the message.
The type of the argument will be inferred from the message format.

```properties
Hello=Hello {0}, the time currently is {1, time}!
Trains={0,number} trains spotted.
```

```xtend
@Messages class MyMessages {
    def static void main(String[] args) {
        val messages = new MyMessages(Locale.GERMAN)
        println(messages.hello("Stefan", new Date))
        print(messages.trains(3))
    }
}
```

@Log
----
Adds a java.util.logging.Logger to your class
```xtend
@Log class Commander {
    def whatIsThis() {
        log.warning("It's a trap!")
    }
}
```

@ExtractInterface
-----------------

There are times where you only have one production implementation of a class, but others for testing purposes. 
In such cases you just need to add the @ExtractInterface annotation to your class and Xtend will automatically create an interface with all the public methods of the class.
```xtend
@ExtractInterface
//generates an interface called "Thing"
class DefaultThing {
    override foo() {

    }

    override bar(String baz) {
        "foobar"
    }
}
```

Convenience methods for copying signatures
--------------------------------------------------
When writing advanced Active Annotations, one recurring task is copying methods, e.g. to implement an interface or to add an indirection.
The SignatureHelper greatly simplifies this.

![](http://www.cloudbees.com/sites/default/files/Button-Built-on-CB-1.png)<commit_msg>added some requests for user participation<commit_after>xtend-contrib
=================

A collection of Active Annotations that will be useful in many projects, but which would be too controversial to include in the Xtend standard library.

[![Build Status](https://oehme.ci.cloudbees.com/job/xtend-contrib/badge/icon)](https://oehme.ci.cloudbees.com/job/xtend-contrib/)
```xml
<dependency>
  <groupId>com.github.oehme.xtend</groupId>
  <artifactId>xtend-contrib</artifactId>
  <version>[0.5,0.6)</version>
</dependency>
```
Features
========

You can see all the features in action in the [examples project](https://github.com/oehme/xtend-contrib/tree/master/xtend-contrib-examples/src/main/java/de/oehme/xtend/contrib/examples)

@Cached
-------
Caches invocations of a method, e.g. to make recursive algorithms more efficient.
```xtend
@Cached
def BigInteger fibonacci(int n) {
    switch n {
        case 0: 0bi
        case 1: 1bi
        default: fibonacci(n - 1) + fibonacci(n - 2)
    }
}
```

@Buildable
--------
Creates a fluent Builder for ValueObjects. Works nicely with the @Data annotation that is shipped with Xtend by default.
```xtend
@Data
@Buildable
class Person {
    String firstName
    String lastName
    int age
}
```

@Messages
---------
Creates a statically typed facade for localization ResourceBundles.
The generated methods take an argument for each placeholder in the message.
The type of the argument will be inferred from the message format.

```properties
Hello=Hello {0}, the time currently is {1, time}!
Trains={0,number} trains spotted.
```

```xtend
@Messages class MyMessages {
    def static void main(String[] args) {
        val messages = new MyMessages(Locale.GERMAN)
        println(messages.hello("Stefan", new Date))
        print(messages.trains(3))
    }
}
```

@Log
----
Adds a java.util.logging.Logger to your class
```xtend
@Log class Commander {
    def whatIsThis() {
        log.warning("It's a trap!")
    }
}
```
*If you find this annotation useful, but want to have it for another framework like log4j, please tell me in the issue section.*

@ExtractInterface
-----------------

There are times where you only have one production implementation of a class, but others for testing purposes. 
In such cases you just need to add the @ExtractInterface annotation to your class and Xtend will automatically create an interface with all the public methods of the class.
```xtend
@ExtractInterface
//generates an interface called "Thing"
class DefaultThing {
    override foo() {

    }

    override bar(String baz) {
        "foobar"
    }
}
```

*This annotation is a candidate for future removal. It was added at the request of a colleague, but I have never seen a real world use case for it. Please speak up in the issue section if you want me to keep it and tell me why =)*

Convenience methods for copying signatures
--------------------------------------------------
When writing advanced Active Annotations, one recurring task is copying methods, e.g. to implement an interface or to add an indirection.
The SignatureHelper greatly simplifies this.

![](http://www.cloudbees.com/sites/default/files/Button-Built-on-CB-1.png)
{'fraction_non_alphanumeric': 0.1321512211441954, 'fraction_numerical': 0.0051856808297089324, 'mean_word_length': 3.373811265544989, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 6, 'lorem ipsum': 0, 'www.': 2, 'xml': 2}, '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': '437723', 'n_tokens_mistral': 1798, 'n_tokens_neox': 1693, 'n_words': 640}