00001 /* 00002 * ContainsAnyFilter.hpp 00003 * 00004 * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. 00005 * 00006 * Oracle is a registered trademarks of Oracle Corporation and/or its 00007 * affiliates. 00008 * 00009 * This software is the confidential and proprietary information of Oracle 00010 * Corporation. You shall not disclose such confidential and proprietary 00011 * information and shall use it only in accordance with the terms of the 00012 * license agreement you entered into with Oracle. 00013 * 00014 * This notice may not be removed or altered. 00015 */ 00016 #ifndef COH_CONTAINS_ANY_FILTER_HPP 00017 #define COH_CONTAINS_ANY_FILTER_HPP 00018 00019 #include "coherence/lang.ns" 00020 00021 #include "coherence/util/Set.hpp" 00022 #include "coherence/util/ValueExtractor.hpp" 00023 #include "coherence/util/filter/ComparisonFilter.hpp" 00024 #include "coherence/util/filter/IndexAwareFilter.hpp" 00025 00026 COH_OPEN_NAMESPACE3(coherence,util,filter) 00027 00028 00029 /** 00030 * Filter which tests a Collection or ObjectArray value returned from 00031 * a method invocation for containment of any value in a Set. 00032 * 00033 * More formally, if the specified extractor returns a Collection, 00034 * #evaluate functionally is equivalent to the following 00035 * code: 00036 * <pre> 00037 * return ((Collection) extract(o))->removeAll((Set) getValue()); 00038 * </pre> 00039 * If the specified method returns an ObjectArray, #evaluate is functionally 00040 * equivalent to the following code: 00041 * <pre> 00042 * return Collections->asList((ObjectArray::View) extract(o))->removeAll( 00043 * (Set) getValue()); 00044 * </pre> 00045 * 00046 * @author djl 2008.04.07 00047 */ 00048 class COH_EXPORT ContainsAnyFilter 00049 : public class_spec<ContainsAnyFilter, 00050 extends<ComparisonFilter>, 00051 implements<IndexAwareFilter> > 00052 { 00053 friend class factory<ContainsAnyFilter>; 00054 00055 // ----- constructors --------------------------------------------------- 00056 00057 protected: 00058 /** 00059 * Default constructor (necessary for the PortableObject interface). 00060 */ 00061 ContainsAnyFilter(); 00062 00063 /** 00064 * Construct an ContainsAnyFilter for testing containment of any 00065 * value in the given Set. 00066 * 00067 * @param vExtractor the ValueExtractor used by this filter 00068 * @param vSetValues the Set of values that a Collection or 00069 * ObjectArray is tested to contain 00070 */ 00071 ContainsAnyFilter(ValueExtractor::View vExtractor, 00072 Set::View vSetValues); 00073 00074 private: 00075 /** 00076 * Blocked copy constructor. 00077 */ 00078 ContainsAnyFilter(const ContainsAnyFilter&); 00079 00080 00081 // ----- ExtractorFilter interface -------------------------------------- 00082 00083 protected: 00084 /** 00085 * Evaluate the specified extracted value. 00086 * 00087 * @param vExtracted an extracted value to evaluate 00088 */ 00089 virtual bool evaluateExtracted(Object::View vExtracted) const; 00090 00091 00092 // ----- IndexAwareFilter interface ------------------------------------- 00093 00094 public: 00095 /** 00096 * {@inheritDoc} 00097 */ 00098 virtual size32_t calculateEffectiveness(Map::View vMapIndexes, 00099 Set::View vSetKeys) const; 00100 00101 /** 00102 * {@inheritDoc} 00103 */ 00104 virtual Filter::View applyIndex(Map::View vMapIndexes, 00105 Set::Handle hSetKeys) const; 00106 }; 00107 00108 COH_CLOSE_NAMESPACE3 00109 00110 #endif // COH_CONTAINS_ANY_FILTER_HPP