On 10 December 2010 18:20, Oleg Kalnichevski <[email protected]> wrote:
> On Fri, 2010-12-10 at 17:15 +0000, sebb wrote:
>> > +    public final boolean equals(Object obj) {
>> > +        if (obj == null) return false;
>>
>> That null check not necessary, because null fails the instanceof check.
>>
>
> I think it saves one comparison operation.

Also, I forgot to say that unless obj is often null, it would be
better to do the self-equality check first.

> Feel free to remove it, but
> ideally all other classes (and they are really a few) should be changed
> as well

OK, I'll see about working my way through them.

>> > +        if (this == obj) return true;
>> > +        if (obj instanceof HttpRoute) {
>> > +            HttpRoute that = (HttpRoute) obj;
>> > +            return LangUtils.equals(this.targetHost, that.targetHost) &&
>> > +                LangUtils.equals(this.localAddress, that.localAddress) &&
>>
>> That's a lot neater than the null checks.
>>
>
> That is precisely the intent of LangUtils ;-)
>
> cheers
>
> Oleg
>
>
> ---------------------------------------------------------------------
> 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