I found no such function and so the hunt begun to find a suitable solution.
I tried looking into some under the hood java functionality to help, but settled on another approach that seems to work pretty well, here's how it goes.
Our 'Beans' are all structured where their 'instance' data is in a variable structure i.e.
I also have a generic method in my beans called 'getInstance' which returns a Structure containing all the instance data, it's a simple but powerful method that helps in debugging what data is contained in the Bean at a glance
...cffunction methog="getInstance" returntype="struct"
So I added a 'compareObject' method to my bean where I can pass in a bean of the same type and compare the 2 objects by introspecting the data from the 'getInstance' call on each of them and then simply looping through the structure keys and comparing them -
So regardless of whether the data is a date, numeric or string, the
<!--- Author: penny - Date: 6/9/2008 --->
<cffunction name="compareObject" output="false" access="public" returntype="boolean" hint="Compares 2 objects that have a getInstance Interface defined for them - ">
<cfargument name="ruleBean" type="ruleBean" required="true"/>
<!--- first compare the Structure Keys if that's the same (which they should be if they're the same object so let's ignore) --->
<!--- Next for each key in the Structure, compare the values - if there is one that is a non-match, then return a false and exit --->
<cfset var item = ''/>
<cfset var returnValue = true/>
<cfset var tmpObj =arguments.ruleBean.getInstance() />
<cfloop collection="#variables.instance#" item="item">
<cfif variables.instance[item] neq tmpObj[item]>
<cfset returnValue = false/>
<cfreturn returnValue />
Note: this is calling 'isSimpleValue' to compare only numerics, boolean, datetime, strings and not Structures and Arrays, which simplifies the comparison scope, but may likely solve the 90% rule while leaving it up to you to implement or extend this method to do comparison accross your complex instance data.
So calling this is as simple as instantiating the bean, and calling the compareObject method on it, and passing in the bean you want to compare it to..
<cfset rule = createObject( "component", "ruleBean").init(1)/>
<cfset rule2 = createObject( "component", "ruleBean").init(2)/>
<cfset x =rule.compareObject(rule2) />
Returns 'false' as they are not equal (instance data in one object is '1' while the other is '2'.
Until we have a true 'compareObject' function to compare 2 objects, this will have to work for now.