commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Carman" <ja...@carmanconsulting.com>
Subject Re: Annotation based library for equals,toString etc
Date Tue, 06 Jan 2009 18:21:26 GMT
I wouldn't think you'd want the AutomaticEquals stuff to be at the
top-level, necessarily.  Can you annotate property getters or perhaps
the fields themselves?

On Tue, Jan 6, 2009 at 10:59 AM, Tim Lebedkov <Tim.Lebedkov@web.de> wrote:
> 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 <virajturakhia@gmail.com> 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 <Tim.Lebedkov@web.de> wrote:
>>> Hello dev@commons.apache.org 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: dev-unsubscribe@commons.apache.org
>>> For additional commands, e-mail: dev-help@commons.apache.org
>>>
>>>
>>
>>
>>
>> --
>> 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: dev-unsubscribe@commons.apache.org
>> For additional commands, e-mail: dev-help@commons.apache.org
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message