package er.extensions.qualifiers; import com.webobjects.eocontrol.EOAndQualifier; import com.webobjects.eocontrol.EOQualifier; import com.webobjects.foundation.NSArray; import com.webobjects.foundation.NSMutableArray; import er.extensions.eof.ERXQ; /** * ERXAndQualifier is a chainable extension of EOAndQualifier. * * @author mschrag */ public class ERXAndQualifier extends EOAndQualifier implements IERXChainableQualifier { /** * Do I need to update serialVersionUID? * See section 5.6 <cite>Type Changes Affecting Serialization</cite> on page 51 of the * <a href="http://java.sun.com/j2se/1.4/pdf/serial-spec.pdf">Java Object Serialization Spec</a> */ private static final long serialVersionUID = 1L; public ERXAndQualifier(NSArray<? extends EOQualifier> qualifiers) { super((NSArray<EOQualifier>) qualifiers); } public ERXAndQualifier(EOQualifier... qualifiers) { super(new NSArray<>(qualifiers)); } @SuppressWarnings("unchecked") public ERXAndQualifier and(EOQualifier... qualifiers) { NSMutableArray<EOQualifier> newQualifiers = qualifiers().mutableClone(); for (EOQualifier qualifier : qualifiers) { if (qualifier != null) { newQualifiers.addObject(qualifier); } } return new ERXAndQualifier(newQualifiers); } public ERXNotQualifier not() { return ERXQ.not(this); } public ERXOrQualifier or(EOQualifier... qualifiers) { return ERXChainedQualifierUtils.or(this, qualifiers); } public void filter(NSMutableArray<?> array) { ERXQ.filter(array, this); } public <T> NSArray<T> filtered(NSArray<T> array) { return ERXQ.filtered(array, this); } public <T> T first(NSArray<T> array) { return ERXQ.first(array, this); } public <T> T one(NSArray<T> array) { return ERXQ.one(array, this); } public <T> T requiredOne(NSArray<T> array) { return ERXQ.requiredOne(array, this); } }