some useful xtend active annotations

477 views
Skip to first unread message

Salvatore Romeo

unread,
Mar 27, 2014, 11:05:43 AM3/27/14
to xtend...@googlegroups.com
I just published some active annotations we use in our team. You can find them here:


as specified in the sources, part of the utilities classes were taken from https://github.com/oehme/xtend-contrib, thanks to the author.

In some previous posts we talked about implementing default interface methods in xtend for java versions prior to java 8. The @Mix active annotation does just this:


please refer to TestMix in src/test/java for how to use it. It's still a basic version and more documentation will come!


Message has been deleted

Victor

unread,
Mar 27, 2014, 4:49:05 PM3/27/14
to xtend...@googlegroups.com
Hi,

That's cool, I have just two questions:

1) why don't you depend on xtend-contrib instead of copying classes provided by it?
2) why do you provide your own version of annotation already in xtend (Data and Property)

Victor

Salvatore Romeo

unread,
Mar 28, 2014, 4:01:27 AM3/28/14
to xtend...@googlegroups.com
1) definitely. it's on the TODO list.

2) because the included @Data and @Property add a prefix, the underscore (_) symbol, to each field. JPA and json serialization don't play well with this, so we implemented our own annotations. This problem was already discussed here: https://groups.google.com/forum/#!searchin/xtend-lang/Property$20underscore/xtend-lang/lSoBkpH24m4/4Je585PG-BwJ 
There are also some small differences: 
- Our @Property annotation will make all set methods return the this object, so to chain setters. 
- Our @Data implementation requires to define a constructor having some parameters. The parameters will be added as fields.

John Kozlov

unread,
Mar 28, 2014, 8:37:18 AM3/28/14
to xtend...@googlegroups.com

Victor

unread,
Mar 28, 2014, 9:46:29 AM3/28/14
to xtend...@googlegroups.com
Thanks, that makes sense :)

I also made some active annotation that build on top of the Cached annotation from xtend-contrib (to reset them when a certain method is called) and some useful extensions for functionaljava, mason and java.
The code is there:
https://wwwsecu.irit.fr/hg/SMAC/victor-noel-phd/contrib-dev/ (l/p: anon/anon)
and the maven repository is there:
http://www.irit.fr/~Victor.Noel/maven-repos/

Victor

Victor

unread,
Mar 28, 2014, 9:48:13 AM3/28/14
to xtend...@googlegroups.com
I'm wondering, isn't a lazy field the same as a Cached method as in xtend-contrib ?

John Kozlov

unread,
Mar 28, 2014, 10:15:11 AM3/28/14
to xtend...@googlegroups.com
Hm, it looks like they provide the same functionality. I'd even say that @Cached is a bit better, because there is no problem with ambiguity (does x mean x or getX()?). One minor difference is in the implementation. Mine supports primitive types via an additional bolean field. xtend-contrib is using boxing instead, which is a bit unsafe.


--
You received this message because you are subscribed to a topic in the Google Groups "Xtend Programming Language" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/xtend-lang/3BU0sBBiH8k/unsubscribe.
To unsubscribe from this group and all its topics, send an email to xtend-lang+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Salvatore Romeo

unread,
Mar 28, 2014, 10:30:26 AM3/28/14
to xtend...@googlegroups.com
good to see other useful uses of active annotations :-)

John Kozlov

unread,
Mar 28, 2014, 11:23:08 AM3/28/14
to xtend...@googlegroups.com
I hope that someday Xtend will have a big set of built-in annotations. @ToString, @Singleton, @Cached, @Mixin and others should defenitely be part of the standard library.

Victor

unread,
Mar 29, 2014, 5:30:22 AM3/29/14
to xtend...@googlegroups.com
I think that's the role xtend-contrib wants to play.

Maybe it would be coherent for interested people to try to contribute to it when they have active annotations such as the one you cited :)
Reply all
Reply to author
Forward
0 new messages