package org.grouplens.grapht.spi.reflect;

import java.lang.annotation.Annotation;
import java.util.HashMap;
import java.util.Map;

import org.grouplens.grapht.annotation.Attribute;
import org.grouplens.grapht.spi.Attributes;

/**
 * Basic implementation of {@link Attributes} based on the {@link Annotation}
 * array reported by the injection point.
 * 
 * @author Michael Ludwig <mludwig@cs.umn.edu>
 */
class AttributesImpl implements Attributes {
    private final Map<Class<? extends Annotation>, Annotation> attrs;
    private final Annotation qualifier;
    
    public AttributesImpl(Annotation[] annots) {
        attrs = new HashMap<Class<? extends Annotation>, Annotation>();
        Annotation foundQualifier = null;
        for (Annotation a: annots) {
            if (a.annotationType().getAnnotation(Attribute.class) != null) {
                // a is an attribute
                attrs.put(a.annotationType(), a);
            }
            if (foundQualifier == null && Qualifiers.isQualifier(a.annotationType())) {
                // a is a qualifier
                foundQualifier = a;
            }
        }
        
        qualifier = foundQualifier;
    }
    
    @Override
    public Annotation getQualifier() {
        return qualifier;
    }

    @Override
    public <A extends Annotation> A getAttribute(Class<A> atype) {
        return atype.cast(attrs.get(atype));
    }
}

@@ -399,16 +399,23 @@
 du%3E%0A */%0A
+public 
 class At
@@ -1402,10 +1402,451 @@
 ;%0A    %7D%0A
+    %0A    @Override%0A    public boolean equals(Object o) %7B%0A        if (!(o instanceof AttributesImpl)) %7B%0A            return false;%0A        %7D%0A        %0A        AttributesImpl a = (AttributesImpl) o;%0A        return (qualifier == null ? a.qualifier == null : qualifier.equals(a)) && attrs.equals(a.attrs);%0A    %7D%0A    %0A    @Override%0A    public int hashCode() %7B%0A        return (qualifier == null ? 0 : qualifier.hashCode()) %5E attrs.hashCode();%0A    %7D%0A
 %7D%0A

Add equals() and hashCode() to AttributesImpl