Hello Viraj,

the first case (@XYZ) is how I thought about it (see also the test
code in the attachment). This way .equals() could be implemented
automatically.
Of course you have to override the equals() method like this, if you
would like it to behave "as designed":

// maybe some sort of postprocessing for class files could make this unnecessary
@Override
public boolean equals(Object b) {
    return Automatic.equals(this, b);
}

the second case also looks interesting and may be useful.

Regards
--Tim

On Tue, Jan 6, 2009 at 3:57 PM, Viraj Turakhia <[email protected]> wrote:
> HI Tim,
> This project interests me. Would like to know more about it.
> Could you please explain this better?
>
> I am confused, what will I do if I want my class's objects to be
> compared using XYZ.equals();?
> Will I write it as:
>
> @XYZ
> public class MyClass{
> ...
> ...
> ...
> }
>
> or
>
> @Annot(equals="XYZ" compareTo="MyComparator")
> public class MyClass{
> ...
> ...
> ...
> }
>
> LMK.
>
> -v
>
> On Tue, Jan 6, 2009 at 7:11 PM, Tim Lebedkov <[email protected]> wrote:
>> Hello [email protected] reader,
>>
>> I would like to start a new project (in the sandbox?) for annotation
>> based implementation of methods like equals.
>> The idea is to annotate a class like this:
>>
>> @AutomaticEquals
>> class Test {
>>    private int a;
>> }
>>
>> and compare 2 instances of this class using
>> AutomaticEquals.equals(test1, test2).
>> Which would work just like
>> org.apache.commons.lang.builder.EqualsBuilder.reflectionEquals(this,
>> obj);
>> Additional candidates for annotation based implementations could be
>> toString() and compare() and clone().
>>
>> So here are my questions:
>> - is it OK to start a project like this here or should I start one for
>> example on code.google.com and move the code later to apache.org?
>> - if yes, what would be my next steps?
>>
>> Regards
>> --Tim
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>>
>
>
>
> --
> The first right of human is the right of EGO.
> --
> http://digmethrough.gebogebo.com
> http://www.xperienceexperience.blogspot.com
> http://thisiswherewelive.blogspot.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to