HibernateUserAdministrationTest now based on the component mechanism.
[utils] / system / general / src / main / java / org / wamblee / system / core / DefaultProvidedInterface.java
index 3eb33ddc90c8a18bc2e9f5190c245c32fe8fe28a..10b8f6184cbbf5c5c50ce192720b8037b7132138 100644 (file)
  */ 
 package org.wamblee.system.core;
 
+import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
 
 /**
  * Default implementation of a service descriptor.
@@ -77,4 +81,32 @@ public class DefaultProvidedInterface implements ProvidedInterface {
                }
                return buf.toString();
        }
+       
+       @Override
+       public boolean equals(Object aObj) {
+           if ( !(aObj instanceof DefaultProvidedInterface)) { 
+               return false; 
+           }
+           DefaultProvidedInterface provided = (DefaultProvidedInterface)aObj; 
+           return getEqualsRepresentation().equals(provided.getEqualsRepresentation());
+       }
+       
+       @Override
+       public int hashCode() {
+           return getEqualsRepresentation().hashCode();
+       }
+       
+       
+       private String getEqualsRepresentation() { 
+           List<String> result = new ArrayList<String>(); 
+           for (Class cls: _interfaces) { 
+               result.add(cls.getName());
+           }
+           Collections.sort(result); 
+           String value = ""; 
+           for (String str: result) { 
+               value += ":" + str; 
+           }
+           return value; 
+       }
 }