You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@velocity.apache.org by nb...@apache.org on 2008/04/26 08:33:27 UTC

svn commit: r651803 - /velocity/tools/trunk/src/main/java/org/apache/velocity/tools/config/FactoryConfiguration.java

Author: nbubna
Date: Fri Apr 25 23:33:09 2008
New Revision: 651803

URL: http://svn.apache.org/viewvc?rev=651803&view=rev
Log:
add a useful implementation of equals() and hashCode() for FactoryConfiguration

Modified:
    velocity/tools/trunk/src/main/java/org/apache/velocity/tools/config/FactoryConfiguration.java

Modified: velocity/tools/trunk/src/main/java/org/apache/velocity/tools/config/FactoryConfiguration.java
URL: http://svn.apache.org/viewvc/velocity/tools/trunk/src/main/java/org/apache/velocity/tools/config/FactoryConfiguration.java?rev=651803&r1=651802&r2=651803&view=diff
==============================================================================
--- velocity/tools/trunk/src/main/java/org/apache/velocity/tools/config/FactoryConfiguration.java (original)
+++ velocity/tools/trunk/src/main/java/org/apache/velocity/tools/config/FactoryConfiguration.java Fri Apr 25 23:33:09 2008
@@ -191,6 +191,32 @@
         }
     }
 
+    /**
+     * This will consider the object equal if it is a FactoryConfiguration
+     * and whose {@link #toString(boolean)} method, when passed <code>false</code>,
+     * returns a String equal to that returned by a call to toString(false) on this
+     * instance.  {@link #toString(boolean)} is used since that returns a String
+     * encompassing all relevant info about the configuration except for the
+     * source information.  In other words, two FactoryConfigurations are considered
+     * equal if they have the same data, properties and toolboxes in String form.
+     */
+    @Override
+    public boolean equals(Object o)
+    {
+        if (o instanceof FactoryConfiguration)
+        {
+            FactoryConfiguration that = (FactoryConfiguration)o;
+            return that.toString(false).equals(this.toString(false));
+        }
+        return false;
+    }
+
+    @Override
+    public int hashCode()
+    {
+        return toString(false).hashCode();
+    }
+
     @Override
     public String toString()
     {