Overriding equals() on AAAttributes.
authorwassa <wassa@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Wed, 9 Apr 2003 14:47:00 +0000 (14:47 +0000)
committerwassa <wassa@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Wed, 9 Apr 2003 14:47:00 +0000 (14:47 +0000)
git-svn-id: https://subversion.switch.ch/svn/shibboleth/java-idp/trunk@556 ab3bd59b-922f-494d-bb5f-6f0a3c29deca

src/edu/internet2/middleware/shibboleth/aa/AAAttribute.java
src/edu/internet2/middleware/shibboleth/aa/AAAttributeSet.java

index 49d8314..7f00177 100644 (file)
@@ -91,6 +91,11 @@ public class AAAttribute extends SAMLAttribute implements ResolverAttribute, Arp
                        null);
        }
 
+       public AAAttribute(String name, Object[] values) throws SAMLException {
+               this(name);
+               setValues(values);
+       }
+
        public boolean hasValues() {
                if (values.isEmpty()) {
                        return false;
@@ -204,13 +209,24 @@ public class AAAttribute extends SAMLAttribute implements ResolverAttribute, Arp
                return valueHandler;
        }
 
-       /* (non-Javadoc)
+       /**
         * @see java.lang.Object#equals(java.lang.Object)
         */
-       public boolean equals(Object obj) {
-               // TODO Figure out what to do here
-               System.err.println("Hit AAAttribute equals().");
-               return super.equals(obj);
+       public boolean equals(Object object) {
+
+               if (!(object instanceof AAAttribute)) {
+                       return false;
+               }
+               if (lifetime != ((AAAttribute) object).lifetime) {
+                       return false;
+               }
+               if (name != ((AAAttribute) object).name) {
+                       return false;
+               }
+               if (!valueHandler.getClass().getName().equals(((AAAttribute) object).valueHandler.getClass().getName())) {
+                       return false;
+               }
+               return values.equals(((AAAttribute) object).values);
        }
 
 }
index d0594a2..6b81320 100644 (file)
@@ -69,6 +69,19 @@ public class AAAttributeSet implements ResolverAttributeSet, ArpAttributeSet {
 
        private HashMap attributes = new HashMap();
 
+       public AAAttributeSet() {
+       }
+
+       public AAAttributeSet(AAAttribute attribute) {
+               attributes.put(attribute.getName(), attribute);
+       }
+
+       public AAAttributeSet(AAAttribute[] attributes) {
+               for (int i = 0; i < attributes.length; i++) {
+                       this.attributes.put(attributes[i].getName(), attributes[i]);
+               }
+       }
+
        public void add(AAAttribute attribute) {
                attributes.put(attribute.getName(), attribute);
        }
@@ -126,4 +139,14 @@ public class AAAttributeSet implements ResolverAttributeSet, ArpAttributeSet {
                }
 
        }
+       /**
+        * @see java.lang.Object#equals(java.lang.Object)
+        */
+       public boolean equals(Object object) {
+               if (!(object instanceof AAAttributeSet)) {
+                       return false;
+               }
+               return attributes.equals(((AAAttributeSet) object).attributes);
+       }
+
 }