Returns a predicate which will unwrap and rethrow any throwables caught in {@code predicate}.

@param predicate the predicate
@param <T> the input type
@param <E> the exception type
@return a predicate
501176
public static <T, E extends Throwable> @NonNull Predicate<T> unwrappingRethrowPredicate(final @NonNull ThrowingPredicate<T, E> predicate) {
    return input -> {
      try {
        return predicate.throwingTest(input);
      } catch(final Throwable t) {
        throw rethrow(unwrap(t));
      }
    };
  }
1247467
protected Throwable unwrap(Throwable throwable) {
        if (throwable instanceof ExecutionException && throwable.getCause() != null) {
            return throwable.getCause();
        }
        return throwable;
    }
566097
public final EventFilterParser.in_predicate_return in_predicate() throws RecognitionException {
        EventFilterParser.in_predicate_return retval = new EventFilterParser.in_predicate_return();
        retval.start = input.LT(1);


        CommonTree root_0 = null;

        Token IN58=null;
        Token char_literal59=null;
        Token STRING60=null;
        Token char_literal61=null;
        Token STRING62=null;
        Token char_literal63=null;
        Token IN65=null;
        Token char_literal66=null;
        Token NUMBER67=null;
        Token char_literal68=null;
        Token NUMBER69=null;
        Token char_literal70=null;
        EventFilterParser.path_function_return path_function57 =null;

        EventFilterParser.path_function_return path_function64 =null;


        CommonTree IN58_tree=null;
        CommonTree char_literal59_tree=null;
        CommonTree STRING60_tree=null;
        CommonTree char_literal61_tree=null;
        CommonTree STRING62_tree=null;
        CommonTree char_literal63_tree=null;
        CommonTree IN65_tree=null;
        CommonTree char_literal66_tree=null;
        CommonTree NUMBER67_tree=null;
        CommonTree char_literal68_tree=null;
        CommonTree NUMBER69_tree=null;
        CommonTree char_literal70_tree=null;
        RewriteRuleTokenStream stream_IN=new RewriteRuleTokenStream(adaptor,"token IN");
        RewriteRuleTokenStream stream_35=new RewriteRuleTokenStream(adaptor,"token 35");
        RewriteRuleTokenStream stream_33=new RewriteRuleTokenStream(adaptor,"token 33");
        RewriteRuleTokenStream stream_34=new RewriteRuleTokenStream(adaptor,"token 34");
        RewriteRuleTokenStream stream_STRING=new RewriteRuleTokenStream(adaptor,"token STRING");
        RewriteRuleTokenStream stream_NUMBER=new RewriteRuleTokenStream(adaptor,"token NUMBER");
        RewriteRuleSubtreeStream stream_path_function=new RewriteRuleSubtreeStream(adaptor,"rule path_function");
        try {
            // EventFilter.g:147:2: ( path_function IN '(' STRING ( ',' STRING )* ')' -> ^( IN path_function ( STRING )+ ) | path_function IN '(' NUMBER ( ',' NUMBER )* ')' -> ^( IN path_function ( NUMBER )+ ) )
            int alt10=2;
            int LA10_0 = input.LA(1);

            if ( (LA10_0==XPATH_FUN_NAME) ) {
                int LA10_1 = input.LA(2);

                if ( (LA10_1==33) ) {
                    int LA10_2 = input.LA(3);

                    if ( (LA10_2==STRING) ) {
                        int LA10_3 = input.LA(4);

                        if ( (LA10_3==34) ) {
                            int LA10_4 = input.LA(5);

                            if ( (LA10_4==IN) ) {
                                int LA10_5 = input.LA(6);

                                if ( (LA10_5==33) ) {
                                    int LA10_6 = input.LA(7);

                                    if ( (LA10_6==STRING) ) {
                                        alt10=1;
                                    }
                                    else if ( (LA10_6==NUMBER) ) {
                                        alt10=2;
                                    }
                                    else {
                                        NoViableAltException nvae =
                                            new NoViableAltException("", 10, 6, input);

                                        throw nvae;

                                    }
                                }
                                else {
                                    NoViableAltException nvae =
                                        new NoViableAltException("", 10, 5, input);

                                    throw nvae;

                                }
                            }
                            else {
                                NoViableAltException nvae =
                                    new NoViableAltException("", 10, 4, input);

                                throw nvae;

                            }
                        }
                        else {
                            NoViableAltException nvae =
                                new NoViableAltException("", 10, 3, input);

                            throw nvae;

                        }
                    }
                    else {
                        NoViableAltException nvae =
                            new NoViableAltException("", 10, 2, input);

                        throw nvae;

                    }
                }
                else {
                    NoViableAltException nvae =
                        new NoViableAltException("", 10, 1, input);

                    throw nvae;

                }
            }
            else {
                NoViableAltException nvae =
                    new NoViableAltException("", 10, 0, input);

                throw nvae;

            }
            switch (alt10) {
                case 1 :
                    // EventFilter.g:147:4: path_function IN '(' STRING ( ',' STRING )* ')'
                    {
                    pushFollow(FOLLOW_path_function_in_in_predicate796);
                    path_function57=path_function();

                    state._fsp--;

                    stream_path_function.add(path_function57.getTree());

                    IN58=(Token)match(input,IN,FOLLOW_IN_in_in_predicate798);
                    stream_IN.add(IN58);


                    char_literal59=(Token)match(input,33,FOLLOW_33_in_in_predicate800);
                    stream_33.add(char_literal59);


                    STRING60=(Token)match(input,STRING,FOLLOW_STRING_in_in_predicate802);
                    stream_STRING.add(STRING60);


                    // EventFilter.g:147:32: ( ',' STRING )*
                    loop8:
                    do {
                        int alt8=2;
                        int LA8_0 = input.LA(1);

                        if ( (LA8_0==35) ) {
                            alt8=1;
                        }


                        switch (alt8) {
                    	case 1 :
                    	    // EventFilter.g:147:33: ',' STRING
                    	    {
                    	    char_literal61=(Token)match(input,35,FOLLOW_35_in_in_predicate805);
                    	    stream_35.add(char_literal61);


                    	    STRING62=(Token)match(input,STRING,FOLLOW_STRING_in_in_predicate807);
                    	    stream_STRING.add(STRING62);


                    	    }
                    	    break;

                    	default :
                    	    break loop8;
                        }
                    } while (true);


                    char_literal63=(Token)match(input,34,FOLLOW_34_in_in_predicate811);
                    stream_34.add(char_literal63);


                    // AST REWRITE
                    // elements: IN, STRING, path_function
                    // token labels:
                    // rule labels: retval
                    // token list labels:
                    // rule list labels:
                    // wildcard labels:
                    retval.tree = root_0;
                    RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

                    root_0 = (CommonTree)adaptor.nil();
                    // 147:50: -> ^( IN path_function ( STRING )+ )
                    {
                        // EventFilter.g:147:53: ^( IN path_function ( STRING )+ )
                        {
                        CommonTree root_1 = (CommonTree)adaptor.nil();
                        root_1 = (CommonTree)adaptor.becomeRoot(
                        new StringInTreeNode(stream_IN.nextToken())
                        , root_1);

                        adaptor.addChild(root_1, stream_path_function.nextTree());

                        if ( !(stream_STRING.hasNext()) ) {
                            throw new RewriteEarlyExitException();
                        }
                        while ( stream_STRING.hasNext() ) {
                            adaptor.addChild(root_1,
                            new StringTreeNode(stream_STRING.nextToken())
                            );

                        }
                        stream_STRING.reset();

                        adaptor.addChild(root_0, root_1);
                        }

                    }


                    retval.tree = root_0;

                    }
                    break;
                case 2 :
                    // EventFilter.g:148:3: path_function IN '(' NUMBER ( ',' NUMBER )* ')'
                    {
                    pushFollow(FOLLOW_path_function_in_in_predicate836);
                    path_function64=path_function();

                    state._fsp--;

                    stream_path_function.add(path_function64.getTree());

                    IN65=(Token)match(input,IN,FOLLOW_IN_in_in_predicate838);
                    stream_IN.add(IN65);


                    char_literal66=(Token)match(input,33,FOLLOW_33_in_in_predicate840);
                    stream_33.add(char_literal66);


                    NUMBER67=(Token)match(input,NUMBER,FOLLOW_NUMBER_in_in_predicate842);
                    stream_NUMBER.add(NUMBER67);


                    // EventFilter.g:148:31: ( ',' NUMBER )*
                    loop9:
                    do {
                        int alt9=2;
                        int LA9_0 = input.LA(1);

                        if ( (LA9_0==35) ) {
                            alt9=1;
                        }


                        switch (alt9) {
                    	case 1 :
                    	    // EventFilter.g:148:32: ',' NUMBER
                    	    {
                    	    char_literal68=(Token)match(input,35,FOLLOW_35_in_in_predicate845);
                    	    stream_35.add(char_literal68);


                    	    NUMBER69=(Token)match(input,NUMBER,FOLLOW_NUMBER_in_in_predicate847);
                    	    stream_NUMBER.add(NUMBER69);


                    	    }
                    	    break;

                    	default :
                    	    break loop9;
                        }
                    } while (true);


                    char_literal70=(Token)match(input,34,FOLLOW_34_in_in_predicate851);
                    stream_34.add(char_literal70);


                    // AST REWRITE
                    // elements: NUMBER, path_function, IN
                    // token labels:
                    // rule labels: retval
                    // token list labels:
                    // rule list labels:
                    // wildcard labels:
                    retval.tree = root_0;
                    RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

                    root_0 = (CommonTree)adaptor.nil();
                    // 148:49: -> ^( IN path_function ( NUMBER )+ )
                    {
                        // EventFilter.g:148:52: ^( IN path_function ( NUMBER )+ )
                        {
                        CommonTree root_1 = (CommonTree)adaptor.nil();
                        root_1 = (CommonTree)adaptor.becomeRoot(
                        new NumericInTreeNode(stream_IN.nextToken())
                        , root_1);

                        adaptor.addChild(root_1, stream_path_function.nextTree());

                        if ( !(stream_NUMBER.hasNext()) ) {
                            throw new RewriteEarlyExitException();
                        }
                        while ( stream_NUMBER.hasNext() ) {
                            adaptor.addChild(root_1,
                            new NumberTreeNode(stream_NUMBER.nextToken())
                            );

                        }
                        stream_NUMBER.reset();

                        adaptor.addChild(root_0, root_1);
                        }

                    }


                    retval.tree = root_0;

                    }
                    break;

            }
            retval.stop = input.LT(-1);


            retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }

        finally {
        	// do for sure before leaving
        }
        return retval;
    }
1080145
public static <X extends Throwable> void throwIf(final X e, final Predicate<X> p) {
        if (p.test(e))
            throw ExceptionSoftener.<RuntimeException> uncheck(e);
    }
526816
public static Throwable unwrap(@Nullable Throwable t) {
		if (t instanceof UncheckedException || t instanceof java.util.concurrent.ExecutionException
				|| t instanceof java.lang.reflect.InvocationTargetException
				|| t instanceof UndeclaredThrowableException) {
			return t.getCause();
		}

		return t;
	}
845092
public static <T> com.google.common.base.Predicate<T> wrap(Predicate predicate) {
        Path<?> path = predicate.accept(PathExtractor.DEFAULT, null);
        if (path != null) {
            final Evaluator<Boolean> ev = createEvaluator(path.getRoot(), predicate);
            return new com.google.common.base.Predicate<T>() {
                @Override
                public boolean apply(T input) {
                    return ev.evaluate(input);
                }
            };
        } else {
            throw new IllegalArgumentException("No path in " + predicate);
        }
    }
603743
public static <T, E extends Exception> List<T> filter(final T[] a, final int fromIndex, final int toIndex, final Try.Predicate<? super T, E> filter,
            final int max) throws E {
        checkFromToIndex(fromIndex, toIndex, len(a));
        N.checkArgNotNull(filter);

        if (N.isNullOrEmpty(a)) {
            return new ArrayList<>();
        }

        final List<T> result = new ArrayList<>(min(9, max, (toIndex - fromIndex)));

        for (int i = fromIndex, cnt = 0; i < toIndex && cnt < max; i++) {
            if (filter.test(a[i])) {
                result.add(a[i]);
                cnt++;
            }
        }

        return result;
    }
1143716
static <R> BiPredicate<R, Throwable> resultPredicateFor(Predicate<R> resultPredicate) {
    return (t, u) -> {
      if (u == null) {
        return resultPredicate.test(t);
      } else {
        // resultPredicate is only defined over the success type.
        // It doesn't know how to handle a failure of type Throwable,
        // so we return false here.
        return false;
      }
    };
  }
560102
private Selector parsePredicate(String predicate, String fullPath) 
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      tc.entry(cclass,
               "parsePredicate",
               "predicate: " + predicate); 

    Selector parsed = null;
    try
    {
      // Preprocess predicate for special characters
      String parserInput = preProcessForSpecials(predicate);
      
      // Attempt to parse predicate with "JMS" parser
      predicateParser =  MatchParserImpl.prime(predicateParser, parserInput, true);     
      parsed = predicateParser.getSelector(parserInput);
      if (parsed.getType() == Selector.INVALID)
      {
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
          tc.debug(this,cclass, "parsePredicate", "Unable to parse predicate");           
        // reset the output to null
        parsed = null;
      }
      else
      {
        postProcessSelectorTree(parsed, fullPath);
      }
    }
    catch (Exception ex)
    {
      // No FFDC Code Needed.
      // In this case we will only trace the exception that we encountered.
      // It could be that the XPath parser is able to process this predicate
      // and that we've encountered a discrepancy between the syntax of an
      // expression supported by JMS and by XPath.
      if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
        tc.debug(this,cclass, "parsePredicate", ex);   
    }
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      tc.exit(this,cclass, "parsePredicate", parsed);     
    return parsed;
  }
1051631
@SuppressWarnings("unchecked")
  public RetryPolicy<R> abortIf(BiPredicate<R, ? extends Throwable> completionPredicate) {
    Assert.notNull(completionPredicate, "completionPredicate");
    abortConditions.add((BiPredicate<R, Throwable>) completionPredicate);
    return this;
  }
1003889
public Predicate<Exception> raise(Class<? extends Exception> exception) {
    return create(error -> error != null && exception.isAssignableFrom(error.getClass()));
  }
637552
public static <T extends Throwable> RuntimeException rethrowAllowedTypeFirst(final Throwable t,
                                                                                 Class<T> allowedType) throws T {
        rethrowIfError(t);
        if (allowedType.isAssignableFrom(t.getClass())) {
            throw (T) t;
        } else {
            throw peel(t);
        }
    }
381696
public static <X extends Throwable> void throwOrHandle(final X e, final Predicate<X> p, final Consumer<X> handler) {
        if (p.test(e))
            throw ExceptionSoftener.<RuntimeException> uncheck(e);
        else
            handler.accept(e);
    }
630261
public EasyRandomParameters excludeField(Predicate<Field> predicate) {
        Objects.requireNonNull(predicate, "Predicate must not be null");
        fieldExclusionPredicates.add(predicate);
        exclusionRandomizerRegistry.addFieldPredicate(predicate);
        return this;
    }
513082
public EasyRandomParameters excludeType(Predicate<Class<?>> predicate) {
        Objects.requireNonNull(predicate, "Predicate must not be null");
        typeExclusionPredicates.add(predicate);
        exclusionRandomizerRegistry.addTypePredicate(predicate);
        return this;
    }
220573
private String preProcessForSpecials(String predicate) 
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      tc.entry(cclass,
               "preProcessForSpecials",
               "predicate: " + predicate);     
    String processed = predicate;
   
    String replace = replaceSpecialsWithSub(predicate);

    if (replace != null)
    {
      processed = replace;      
    }
    
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      tc.exit(this,cclass, "preProcessForSpecials", processed);    
    return processed; 
  }
1146599
public final FluentCloseableIterable<T> filter(Predicate<? super T> predicate) {
        return from(CloseableIterables.filter(this, predicate));
    }