Created
June 12, 2019 14:17
-
-
Save hprange/9ec8752017a8171b5c6cc16c6966404a to your computer and use it in GitHub Desktop.
A class to compare EOs according to the eoEquals contract when evaluating qualifiers in memory.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.wocommunity.eof; | |
import com.webobjects.eocontrol.EOEnterpriseObject; | |
import com.webobjects.eocontrol.EOQualifier.ComparisonSupport; | |
import com.webobjects.foundation.NSKeyValueCoding; | |
import er.extensions.eof.ERXEOControlUtilities; | |
/** | |
* The {@code EOComparisonSupport} extends the {@code EOQualifier.ComparisonSupport} class and evaluates all | |
* {@code EOGenericRecord} objects according to the {@code ERXEOControlUtilities.eoEquals} contract. | |
* <p> | |
* Include the code below during the application initialization to enable support for this class: | |
* | |
* <pre> | |
* EOKeyValueQualifier.ComparisonSupport.setSupportForClass(new EOComparisonSupport(), EOGenericRecord.class); | |
* </pre> | |
* | |
* Note: This class fixes the problem when evaluating toOne relationships in memory. It doesn't change the behavior when | |
* evaluating arrays of EOs using the contains selector. | |
* | |
* @author <a href="mailto:[email protected]">Henrique Prange</a> | |
*/ | |
public class EOComparisonSupport extends ComparisonSupport { | |
/** | |
* Compares two {@code EOEnterpriseObject}s according to the {@code ERXEOControlUtilities.eoEquals} contract. | |
* | |
* @see com.webobjects.eocontrol.EOQualifier.ComparisonSupport#isEqualTo(java.lang.Object, java.lang.Object) | |
*/ | |
@Override | |
public boolean isEqualTo(Object left, Object right) { | |
Object leftValue = left == NSKeyValueCoding.NullValue ? null : left; | |
Object rightValue = right == NSKeyValueCoding.NullValue ? null : right; | |
return ERXEOControlUtilities.eoEquals((EOEnterpriseObject) leftValue, (EOEnterpriseObject) rightValue); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment