/** * List of child filters. * * <p>Where a child filter is considered: * * <ul> * <li>Not: has a single child filter being negated * <li>And: has a list of child filters * <li>Or: has a list of child filters * </ul> * * Any other filters will return false. * * <p>This represents the space covered by a number of the search functions. * * <p>The returned list is a mutable copy that can be used with filter factory to construct a * new filter when you are ready. To make that explicit I am returning an ArrayList so it is * clear that the result can be modified. * * @param filter * @return are belong to us */ public static ArrayList<Filter> children(Filter filter) { return children(filter, false); } /**
/** * Find the first child-filter (or the base filter itself) that is of the given type and uses * the specified property. * * @param filter * @param filterType - class of the filter to look for * @param property - name of the property to look for * @return */ public static <T extends Filter> T search( Filter filter, Class<T> filterType, String propertyName) { List<Filter> allBase = children(filter); for (Filter base : allBase) { if (filterType.isInstance(base) && uses(base, propertyName)) { return filterType.cast(base); } } return null; // not found }
/** * Find all filters (including the base filter itself) that are of the given type and use the * specified property. * * @param filter * @param filterType * @param property * @return all filters that are of the given type using the specified property */ static <T extends Filter> List<T> findAllByTypeAndName( Filter filter, Class<T> filterType, String property) { List<T> retVal = new ArrayList<T>(); List<Filter> allBase = children(filter); allBase.add(0, filter); for (Filter base : allBase) { if (filterType.isInstance(base) && uses(base, property)) { retVal.add(filterType.cast(base)); } } return retVal; } }
/** * List of child filters. * * Where a child filter is considered: * <ul> * <li>Not: has a single child filter being negated</li> * <li>And: has a list of child filters</li> * <li>Or: has a list of child filters</li> * </ul> * Any other filters will return false. * <p> * This represents the space covered by a number of the search functions. * <p> * The returned list is a mutable copy that can be used with filter factory to construct a * new filter when you are ready. To make that explicit I am returning an ArrayList so it * is clear that the result can be modified. * </p> * @param filter * @return are belong to us */ static public ArrayList<Filter> children( Filter filter ){ return children( filter, false ); } /**
/** * Find the first child-filter (or the base filter itself) that is of the given type and uses * the specified property. * @param filter * @param filterType - class of the filter to look for * @param property - name of the property to look for * @return */ public static <T extends Filter> T search(Filter filter, Class<T> filterType, String propertyName ){ List<Filter> allBase = children(filter); for( Filter base : allBase ){ if( filterType.isInstance(base) && uses(base, propertyName) ){ return filterType.cast(base); } } return null; // not found }
/** * Find all filters (including the base filter itself) that are of the given type and use * the specified property. * @param filter * @param filterType * @param property * @return all filters that are of the given type using the specified property */ static <T extends Filter> List<T> findAllByTypeAndName(Filter filter, Class<T> filterType, String property) { List<T> retVal = new ArrayList<T>(); List<Filter> allBase = children(filter); allBase.add( 0, filter ); for( Filter base : allBase ){ if( filterType.isInstance(base) && uses(base, property) ){ retVal.add( filterType.cast(base) ); } } return retVal; } }