Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Marker Annotations

Generation of  a method like this is not something that AspectJ can easily 
help you with. You could write a generic equals method that uses 
reflection to find out which fields have the annotation and compare them 
(and then maybe use itds to declare that equals implementation on behalf 
of the target types). Avoiding reflection though, I think the best 
solution to this is probably to use something like APT: 
http://java.sun.com/j2se/1.5.0/docs/guide/apt/

-- Adrian
Adrian_Colyer@xxxxxxxxxx



neil@xxxxxxxxxxxx 
Sent by: aspectj-users-bounces@xxxxxxxxxxx
17/05/2005 20:26
Please respond to
aspectj-users@xxxxxxxxxxx


To
aspectj-users@xxxxxxxxxxx
cc

Subject
[aspectj-users] Marker Annotations






I've been using AspectJ a bit and I've got a question that is way outside
of my experience and was wondering if someone could help.

I would like to use a Market Annotation on fields in a class to generate
an equals method. Something like:

public class Rubble {
   @Equal
   private Long fred;

   @Equal
   private String wilma;
}

would build a new:

   public boolean equals(Object value) {
       Rubble rubbleValue = (Rubble)value;
       return (fred.equals(rubbleValue.fred &&
                      wilma.equals(rubbleValue.wilma));
}

Obviously the example equals method logic isn't complete.  I would
probably use EqualsBuilder or something to make it easier.

TIA

Neil Hart

_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users




Back to the top