rewritten in Xtend
Java 1.5 compatibility