Simple.

public class Something extends Whatever implements List {
    private @Delegate List listDelegate = new ArrayList();
}

lombok would add all methods that exist in List.java (as that is the
type of 'listDelegate' - arraylist is merely what's assigned to it,
it's about the type of the field you stick @Delegate on), and
implement each one simply by wrapping a call through to the
listDelegate object. e.g:

public int size() {
    return listDelegate.size();
}


We're going to add this, because it's cool, simple, and yet very
powerful, but we need to extend lombok a little further first - right
now lombok does transformations on pure ASTs. At the point of the pure
AST, there is zero typing information available, and lombok is not
aware of the filer (the thing that uses the classpath and, in javac,
sourcepath, and in eclipse, your project dependencies, to figure out
what "List" is supposed to refer to). In other words, lombok is not
currently capable of figuring out that "List" is in fact referring to
"java.util.List", and even if it knew that this is about
java.util.List, it would have no way of figuring out which methods are
in java.util.List (well, List is in the runtime, but what if you want
to @Delegate one of your own types and not something in the core java
libraries? That should obviously work too before we release such a
feature).

It won't be too hard to add it, and with typing info you can do a lot
more than @Delegate.


Note how you don't need to mark your class abstract, and you also do
not need to use a special format to construct instances of this class.
There will also be zero runtime dependencies - it's all sorted out at
compile time, exactly as if you wrote all those wrapper methods
yourself.


If someone has a better idea I'd love to hear it. I can't take credit
for it; someone on the lombok googlegroup at 
http://groups.google.com/group/project-lombok
suggested it, and I copied the entire idea verbatim into the near
future planning.

On Aug 26, 11:50 pm, Mark Derricutt <m...@talios.com> wrote:
> After Project Lombok was first mentioned here I was thinking how this could
> work with mixins, and again after listening about the mixins for java
> (hereon known as M4J) project mentioned on the last show, and watching the
> video athttp://www.berniecode.com/writing/java-mixins/I was thinking about
> this again.
>
> If one was to do mixins lombok style, what would be  good way of doing it?
>  M4J requires shipping the M4J library/api which you use to construct the
> mixedin object.  I was thinking lombok style could inject a static method
> which you use for the constructor, something like
> MyBusinessObject.newMixin() or the like.
>
> I could really do with using something like this :)
>
> --
> Pull me down under...
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "The 
Java Posse" group.
To post to this group, send email to javaposse@googlegroups.com
To unsubscribe from this group, send email to 
javaposse+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to