All Projects → oehme → xtend-contrib

oehme / xtend-contrib

Licence: MIT license
Provides commonly requested features that are too controversial for the Xtend core library

Programming Languages

Xtend
68 projects
shell
77523 projects

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 Download Features

You can see all the features in action in the examples project

@Cached

Caches invocations of a method, e.g. to make recursive algorithms more efficient.

@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.

@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.

Hello=Hello {0}, the time currently is {1, time}!
Trains={0,number} trains spotted.
@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

@Log class Commander {
    def whatIsThis() {
        log.warning("It's a trap!")
    }
}

Similar annotations for other major logging frameworks are also avaiable.

Convenience classes for writing Active Annotations

  • SignatureHelper simplifies copying methods, e.g. to implement an interface or to add an indirection.
  • Reflections allows you to scan packages for types in order to aggregate them
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].