mcconnell 2003/07/12 06:11:55
Modified: meta/api/src/java/org/apache/avalon/meta/info Type.java
Log:
Added equals( Object ) and hashCode() implementations.
Revision Changes Path
1.8 +71 -2
avalon-sandbox/meta/api/src/java/org/apache/avalon/meta/info/Type.java
Index: Type.java
===================================================================
RCS file:
/home/cvs/avalon-sandbox/meta/api/src/java/org/apache/avalon/meta/info/Type.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- Type.java 12 Jul 2003 08:43:04 -0000 1.7
+++ Type.java 12 Jul 2003 13:11:55 -0000 1.8
@@ -78,12 +78,12 @@
{
private final InfoDescriptor m_descriptor;
private final ContextDescriptor m_context;
+ private final Configuration m_configuration;
private final ServiceDescriptor[] m_services;
private final DependencyDescriptor[] m_dependencies;
private final CategoryDescriptor[] m_loggers;
private final StageDescriptor[] m_stages;
private final ExtensionDescriptor[] m_extensions;
- private final Configuration m_configuration;
/**
* Creation of a new Type instance using a supplied component descriptor,
@@ -374,5 +374,74 @@
public String toString()
{
return getInfo().toString();
+ }
+
+ public boolean equals(Object other)
+ {
+ boolean isEqual = other instanceof Type;
+ isEqual = isEqual && m_descriptor.equals(((Type)other).m_descriptor);
+ isEqual = isEqual && m_configuration.equals(((Type)other).m_configuration);
+ isEqual = isEqual && m_context.equals(((Type)other).m_context);
+ for( int i=0; i<m_loggers.length; i++ )
+ {
+ isEqual = isEqual && m_loggers[i].equals(((Type)other).m_loggers[i]);
+ }
+ for( int i=0; i<m_services.length; i++ )
+ {
+ isEqual = isEqual && m_services[i].equals(((Type)other).m_services[i]);
+ }
+ for( int i=0; i<m_dependencies.length; i++ )
+ {
+ isEqual = isEqual &&
m_dependencies[i].equals(((Type)other).m_dependencies[i]);
+ }
+ for( int i=0; i<m_stages.length; i++ )
+ {
+ isEqual = isEqual && m_stages[i].equals(((Type)other).m_stages[i]);
+ }
+ for( int i=0; i<m_extensions.length; i++ )
+ {
+ isEqual = isEqual &&
m_extensions[i].equals(((Type)other).m_extensions[i]);
+ }
+ return isEqual;
+ }
+
+ public int hashCode()
+ {
+ int hash = m_descriptor.hashCode();
+ hash >>>= 13;
+ hash ^= m_context.hashCode();
+ hash >>>= 13;
+ if( m_configuration != null )
+ {
+ hash ^= m_context.hashCode();
+ hash >>>= 13;
+ }
+ hash >>>= 13;
+ for( int i=0; i<m_services.length; i++ )
+ {
+ hash ^= m_services[i].hashCode();
+ hash >>>= 13;
+ }
+ for( int i=0; i<m_dependencies.length; i++ )
+ {
+ hash ^= m_dependencies[i].hashCode();
+ hash >>>= 13;
+ }
+ for( int i=0; i<m_loggers.length; i++ )
+ {
+ hash ^= m_loggers[i].hashCode();
+ hash >>>= 13;
+ }
+ for( int i=0; i<m_stages.length; i++ )
+ {
+ hash ^= m_stages[i].hashCode();
+ hash >>>= 13;
+ }
+ for( int i=0; i<m_extensions.length; i++ )
+ {
+ hash ^= m_extensions[i].hashCode();
+ hash >>>= 13;
+ }
+ return hash;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]