Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] add instance members to a class

I would instead use project Lombok annotations for the getter/setter. Lombok
annotations are respected in most IDEs for compile support, and also for
many build tools.

What do you mean by "instance" method?

Tim

-----Original Message-----
From: aspectj-users <aspectj-users-bounces@xxxxxxxxxxx> On Behalf Of Steve
White via aspectj-users
Sent: Friday, March 29, 2024 10:47 AM
To: aspectj-users@xxxxxxxxxxx
Cc: Steve White <stevan.white@xxxxxxxxx>
Subject: [aspectj-users] add instance members to a class

Hi,

I'm just learning about AspectJ.  I haven't been able to determine if I can
apply it to my problem.

The problem is to add an instance member, together with getters/setters, to
certain existing classes.  This seems to be an example of a crosscutting
concern.

So far, I have managed with AspectJ only to produce classes with new static
members.

Is it possible with AspectJ to create an annotation, say @Labelled, so that

    @Labelled
    public class LabelledClass extends PlainClass{
    }

so that instances of LabelledClass will have their own private String member
"itsLabel", with a getter "getLabel()", and a setter "setLabel()".  That is,
so that LabelledClass effectively implements

     interface LabelledInterface{
         String getLabel();
         void setLabel( String label );
    }

How would one go about this?  Is something like this possible?

If this kind of thing isn't possible, where can I find passages in the
documentation that would clarify the situation?

Thanks!
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
To unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/aspectj-users



Back to the top