geronimo-xbean-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jacek Laskowski <ja...@laskowski.net.pl>
Subject Re: svn commit: r908295 - /geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/context/impl/XBeanNamespaceHandler.java
Date Wed, 10 Feb 2010 10:57:59 GMT
On Wed, Feb 10, 2010 at 1:32 AM,  <djencks@apache.org> wrote:
> Author: djencks
> Date: Wed Feb 10 00:32:13 2010
> New Revision: 908295
...
> +    private boolean equals(NonNullMetadata key1, NonNullMetadata key2) {
> +        if (key1 == key2) return true;
> +        if (key1.getClass() != key2.getClass()) return false;
> +        if (key1 instanceof RefMetadata) return ((RefMetadata) key1).getComponentId().equals(((RefMetadata)
key2).getComponentId());
> +        if (key1 instanceof ReferenceMetadata) {
> +            if (((ReferenceMetadata) key1).getTimeout() != ((ReferenceMetadata)
key2).getTimeout()) return false;
> +        }
> +        if (key1 instanceof ServiceReferenceMetadata) {
> +            ServiceReferenceMetadata sr1 = (ServiceReferenceMetadata) key1;
> +            ServiceReferenceMetadata sr2 = (ServiceReferenceMetadata) key2;
> +            return sr1.getAvailability() == sr2.getAvailability()
> +                    && sr1.getInterface().equals(sr2.getInterface())
> +                    && sr1.getComponentName().equals(sr2.getComponentName())
> +                    && sr1.getFilter().equals(sr2.getFilter())
> +                    && sr1.getReferenceListeners().equals(sr2.getReferenceListeners())
> +
> +                    && sr1.getId().equals(sr2.getId())
> +                    && sr1.getActivation() == sr2.getActivation()
> +                    && sr1.getDependsOn().equals(sr2.getDependsOn());
> +        }
> +        if (key1 instanceof ValueMetadata) {
> +            ValueMetadata v1 = (ValueMetadata) key1;
> +            ValueMetadata v2 = (ValueMetadata) key2;
> +            if (v1.getStringValue() != null ? v1.getStringValue().equals(v2.getStringValue())
: v2.getStringValue() == null
> +                    && v1.getType() != null ? v1.getType().equals(v2.getType())
: v2.getType() == null) {
> +                return true;
> +            }
> +        }
> +        return false;
> +    }
> +

Hi Dave,

I wonder if it wasn't clearer to introduce proper equals method in
ServiceReferenceMetadata and ValueMetadata classes, and delegate its
calls to them?

Jacek

-- 
Jacek Laskowski
Notatnik Projektanta Java EE - http://wszystkojawne.pl
p.s. Szukam speca/firmy od grafiki/CSS/HTML

Mime
View raw message