/** * Will invert the meaning of this filter by wrapping it with * a filter that negates the return of the accept method. * * If the passed in filter is already wrapped, it will be * unwrapped and returned. This is to prevent endless wrapping * if the invert method is called many times. * * @param filter * @return */ public static Filter invert(Filter filter) { if (filter instanceof NegativeFilter) { NegativeFilter negativeFilter = (NegativeFilter) filter; return negativeFilter.getFilter(); } return new NegativeFilter(filter); }
/** * Will invert the meaning of this filter by wrapping it with * a filter that negates the return of the accept method. * * If the passed in filter is already wrapped, it will be * unwrapped and returned. This is to prevent endless wrapping * if the invert method is called many times. * * @param filter * @return */ public static Filter invert(Filter filter) { if (filter instanceof NegativeFilter) { NegativeFilter negativeFilter = (NegativeFilter) filter; return negativeFilter.getFilter(); } return new NegativeFilter(filter); }
/** * Will invert the meaning of this filter by wrapping it with * a filter that negates the return of the accept method. * * If the passed in filter is already wrapped, it will be * unwrapped and returned. This is to prevent endless wrapping * if the invert method is called many times. * * @param filter * @return */ public static Filter invert(Filter filter) { if (filter instanceof NegativeFilter) { NegativeFilter negativeFilter = (NegativeFilter) filter; return negativeFilter.getFilter(); } return new NegativeFilter(filter); }