idx int64 0 165k | question stringlengths 73 4.15k | target stringlengths 5 918 | len_question int64 21 890 | len_target int64 3 255 |
|---|---|---|---|---|
24,900 | public static boolean isCaller ( final String className , final String methodName ) { final Throwable throwable = new Throwable ( ) ; final StackTraceElement [ ] stackElements = throwable . getStackTrace ( ) ; if ( null == stackElements ) { LOGGER . log ( Level . WARN , "Empty call stack" ) ; return false ; } final boolean matchAllMethod = "*" . equals ( methodName ) ; for ( int i = 1 ; i < stackElements . length ; i ++ ) { if ( stackElements [ i ] . getClassName ( ) . equals ( className ) ) { return matchAllMethod ? true : stackElements [ i ] . getMethodName ( ) . equals ( methodName ) ; } } return false ; } | Checks the current method is whether invoked by a caller specified by the given class name and method name . | 169 | 21 |
24,901 | public static void printCallstack ( final Level logLevel , final String [ ] carePackages , final String [ ] exceptablePackages ) { if ( null == logLevel ) { LOGGER . log ( Level . WARN , "Requires parameter [logLevel]" ) ; return ; } final Throwable throwable = new Throwable ( ) ; final StackTraceElement [ ] stackElements = throwable . getStackTrace ( ) ; if ( null == stackElements ) { LOGGER . log ( Level . WARN , "Empty call stack" ) ; return ; } final long tId = Thread . currentThread ( ) . getId ( ) ; final StringBuilder stackBuilder = new StringBuilder ( "CallStack [tId=" ) . append ( tId ) . append ( Strings . LINE_SEPARATOR ) ; for ( int i = 1 ; i < stackElements . length ; i ++ ) { final String stackElemClassName = stackElements [ i ] . getClassName ( ) ; if ( ! StringUtils . startsWithAny ( stackElemClassName , carePackages ) || StringUtils . startsWithAny ( stackElemClassName , exceptablePackages ) ) { continue ; } stackBuilder . append ( " [className=" ) . append ( stackElements [ i ] . getClassName ( ) ) . append ( ", fileName=" ) . append ( stackElements [ i ] . getFileName ( ) ) . append ( ", lineNumber=" ) . append ( stackElements [ i ] . getLineNumber ( ) ) . append ( ", methodName=" ) . append ( stackElements [ i ] . getMethodName ( ) ) . append ( ' ' ) . append ( Strings . LINE_SEPARATOR ) ; } stackBuilder . append ( "], full depth [" ) . append ( stackElements . length ) . append ( "]" ) ; LOGGER . log ( logLevel , stackBuilder . toString ( ) ) ; } | Prints call stack with the specified logging level . | 424 | 10 |
24,902 | public static void start ( final String taskTitle ) { Stopwatch root = STOPWATCH . get ( ) ; if ( null == root ) { root = new Stopwatch ( taskTitle ) ; // Creates the root stopwatch STOPWATCH . set ( root ) ; return ; } final Stopwatch recent = getRecentRunning ( STOPWATCH . get ( ) ) ; if ( null == recent ) { return ; } recent . addLeaf ( new Stopwatch ( taskTitle ) ) ; // Adds sub-stopwatch } | Starts a task timing with the specified task title . | 106 | 11 |
24,903 | public static String getTimingStat ( ) { final Stopwatch root = STOPWATCH . get ( ) ; if ( null == root ) { return "No stopwatch" ; } final StringBuilder stringBuilder = new StringBuilder ( ) ; root . appendTimingStat ( 1 , stringBuilder ) ; return stringBuilder . toString ( ) ; } | Gets the current timing statistics . | 72 | 7 |
24,904 | public static long getElapsed ( final String taskTitle ) { final long currentTimeMillis = System . currentTimeMillis ( ) ; if ( StringUtils . isBlank ( taskTitle ) ) { return - 1 ; } final Stopwatch root = STOPWATCH . get ( ) ; if ( null == root ) { return - 1 ; } final Stopwatch stopwatch = get ( root , taskTitle ) ; if ( null == stopwatch ) { return - 1 ; } if ( stopwatch . isEnded ( ) ) { return stopwatch . getElapsedTime ( ) ; } return currentTimeMillis - stopwatch . getStartTime ( ) ; } | Gets elapsed time from the specified parent stopwatch with the specified task title . | 140 | 16 |
24,905 | private static Stopwatch get ( final Stopwatch parent , final String taskTitle ) { if ( taskTitle . equals ( parent . getTaskTitle ( ) ) ) { return parent ; } for ( final Stopwatch leaf : parent . getLeaves ( ) ) { final Stopwatch ret = get ( leaf , taskTitle ) ; if ( null != ret ) { return ret ; } } return null ; } | Gets stopwatch from the specified parent stopwatch with the specified task title . | 83 | 16 |
24,906 | private static Stopwatch getRecentRunning ( final Stopwatch parent ) { if ( null == parent ) { return null ; } final List < Stopwatch > leaves = parent . getLeaves ( ) ; if ( leaves . isEmpty ( ) ) { if ( parent . isRunning ( ) ) { return parent ; } else { return null ; } } for ( int i = leaves . size ( ) - 1 ; i > - 1 ; i -- ) { final Stopwatch leaf = leaves . get ( i ) ; if ( leaf . isRunning ( ) ) { return getRecentRunning ( leaf ) ; } else { continue ; } } return parent ; } | Gets the recent running stopwatch with the specified parent stopwatch . | 135 | 14 |
24,907 | public static boolean isIPv4 ( final String ip ) { if ( StringUtils . isBlank ( ip ) ) { return false ; } final String regex = "^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$" ; final Pattern pattern = Pattern . compile ( regex ) ; final Matcher matcher = pattern . matcher ( ip ) ; return matcher . matches ( ) ; } | Is IPv4 . | 209 | 4 |
24,908 | public static List < String > toLines ( final String string ) throws IOException { if ( null == string ) { return null ; } final List < String > ret = new ArrayList <> ( ) ; try ( final BufferedReader bufferedReader = new BufferedReader ( new StringReader ( string ) ) ) { String line = bufferedReader . readLine ( ) ; while ( null != line ) { ret . add ( line ) ; line = bufferedReader . readLine ( ) ; } } return ret ; } | Converts the specified string into a string list line by line . | 111 | 13 |
24,909 | public static boolean isNumeric ( final String string ) { try { Double . parseDouble ( string ) ; } catch ( final Exception e ) { return false ; } return true ; } | Checks whether the specified string is numeric . | 38 | 9 |
24,910 | public static boolean isEmail ( final String string ) { if ( StringUtils . isBlank ( string ) ) { return false ; } if ( MAX_EMAIL_LENGTH < string . length ( ) ) { return false ; } final String [ ] parts = string . split ( "@" ) ; if ( 2 != parts . length ) { return false ; } final String local = parts [ 0 ] ; if ( MAX_EMAIL_LENGTH_LOCAL < local . length ( ) ) { return false ; } final String domain = parts [ 1 ] ; if ( MAX_EMAIL_LENGTH_DOMAIN < domain . length ( ) ) { return false ; } return EMAIL_PATTERN . matcher ( string ) . matches ( ) ; } | Checks whether the specified string is a valid email address . | 163 | 12 |
24,911 | public static String [ ] trimAll ( final String [ ] strings ) { if ( null == strings ) { return null ; } return Arrays . stream ( strings ) . map ( StringUtils :: trim ) . toArray ( size -> new String [ size ] ) ; } | Trims every string in the specified strings array . | 57 | 10 |
24,912 | public static boolean containsIgnoreCase ( final String string , final String [ ] strings ) { if ( null == strings ) { return false ; } return Arrays . stream ( strings ) . anyMatch ( str -> StringUtils . equalsIgnoreCase ( string , str ) ) ; } | Determines whether the specified strings contains the specified string ignoring case considerations . | 60 | 15 |
24,913 | public static boolean contains ( final String string , final String [ ] strings ) { if ( null == strings ) { return false ; } return Arrays . stream ( strings ) . anyMatch ( str -> StringUtils . equals ( string , str ) ) ; } | Determines whether the specified strings contains the specified string . | 54 | 12 |
24,914 | private void initBeforeList ( ) { final List < ProcessAdvice > beforeRequestProcessAdvices = new ArrayList <> ( ) ; final Method invokeHolder = getInvokeHolder ( ) ; final Class < ? > processorClass = invokeHolder . getDeclaringClass ( ) ; // 1. process class advice if ( null != processorClass && processorClass . isAnnotationPresent ( Before . class ) ) { final Class < ? extends ProcessAdvice > [ ] bcs = processorClass . getAnnotation ( Before . class ) . value ( ) ; for ( int i = 0 ; i < bcs . length ; i ++ ) { final Class < ? extends ProcessAdvice > bc = bcs [ i ] ; final ProcessAdvice beforeRequestProcessAdvice = BeanManager . getInstance ( ) . getReference ( bc ) ; beforeRequestProcessAdvices . add ( beforeRequestProcessAdvice ) ; } } // 2. process method advice if ( invokeHolder . isAnnotationPresent ( Before . class ) ) { final Class < ? extends ProcessAdvice > [ ] bcs = invokeHolder . getAnnotation ( Before . class ) . value ( ) ; for ( int i = 0 ; i < bcs . length ; i ++ ) { final Class < ? extends ProcessAdvice > bc = bcs [ i ] ; final ProcessAdvice beforeRequestProcessAdvice = BeanManager . getInstance ( ) . getReference ( bc ) ; beforeRequestProcessAdvices . add ( beforeRequestProcessAdvice ) ; } } this . beforeRequestProcessAdvices = beforeRequestProcessAdvices ; } | Initializes before process advices . | 340 | 7 |
24,915 | private void initAfterList ( ) { final List < ProcessAdvice > afterRequestProcessAdvices = new ArrayList <> ( ) ; final Method invokeHolder = getInvokeHolder ( ) ; final Class < ? > processorClass = invokeHolder . getDeclaringClass ( ) ; // 1. process method advice if ( invokeHolder . isAnnotationPresent ( After . class ) ) { final Class < ? extends ProcessAdvice > [ ] acs = invokeHolder . getAnnotation ( After . class ) . value ( ) ; for ( int i = 0 ; i < acs . length ; i ++ ) { final Class < ? extends ProcessAdvice > ac = acs [ i ] ; final ProcessAdvice beforeRequestProcessAdvice = BeanManager . getInstance ( ) . getReference ( ac ) ; afterRequestProcessAdvices . add ( beforeRequestProcessAdvice ) ; } } // 2. process class advice if ( null != processorClass && processorClass . isAnnotationPresent ( After . class ) ) { final Class < ? extends ProcessAdvice > [ ] acs = invokeHolder . getAnnotation ( After . class ) . value ( ) ; for ( int i = 0 ; i < acs . length ; i ++ ) { final Class < ? extends ProcessAdvice > ac = acs [ i ] ; final ProcessAdvice beforeRequestProcessAdvice = BeanManager . getInstance ( ) . getReference ( ac ) ; afterRequestProcessAdvices . add ( beforeRequestProcessAdvice ) ; } } this . afterRequestProcessAdvices = afterRequestProcessAdvices ; } | Initializes after process advices . | 341 | 7 |
24,916 | public Query select ( final String propertyName , final String ... propertyNames ) { projections . add ( new Projection ( propertyName ) ) ; if ( null != propertyNames && 0 < propertyNames . length ) { for ( int i = 0 ; i < propertyNames . length ; i ++ ) { projections . add ( new Projection ( propertyNames [ i ] ) ) ; } } return this ; } | Set SELECT projections . | 84 | 4 |
24,917 | public Query addSort ( final String propertyName , final SortDirection sortDirection ) { sorts . put ( propertyName , sortDirection ) ; return this ; } | Adds sort for the specified property with the specified direction . | 35 | 11 |
24,918 | public static String getTimeAgo ( final long time , final Locale locale ) { final BeanManager beanManager = BeanManager . getInstance ( ) ; final LangPropsService langService = beanManager . getReference ( LangPropsService . class ) ; final Map < String , String > langs = langService . getAll ( locale ) ; final long diff = System . currentTimeMillis ( ) - time ; long r ; if ( diff > YEAR_UNIT ) { r = diff / YEAR_UNIT ; return r + " " + langs . get ( "yearsAgoLabel" ) ; } if ( diff > MONTH_UNIT ) { r = diff / MONTH_UNIT ; return r + " " + langs . get ( "monthsAgoLabel" ) ; } if ( diff > WEEK_UNIT ) { r = diff / WEEK_UNIT ; return r + " " + langs . get ( "weeksAgoLabel" ) ; } if ( diff > DAY_UNIT ) { r = diff / DAY_UNIT ; return r + " " + langs . get ( "daysAgoLabel" ) ; } if ( diff > HOUR_UNIT ) { r = diff / HOUR_UNIT ; return r + " " + langs . get ( "hoursAgoLabel" ) ; } if ( diff > MINUTE_UNIT ) { r = diff / MINUTE_UNIT ; return r + " " + langs . get ( "minutesAgoLabel" ) ; } return langs . get ( "justNowLabel" ) ; } | Gets time ago format text . | 347 | 7 |
24,919 | public static boolean isSameDay ( final Date date1 , final Date date2 ) { final Calendar cal1 = Calendar . getInstance ( ) ; cal1 . setTime ( date1 ) ; final Calendar cal2 = Calendar . getInstance ( ) ; cal2 . setTime ( date2 ) ; return cal1 . get ( Calendar . ERA ) == cal2 . get ( Calendar . ERA ) && cal1 . get ( Calendar . DATE ) == cal2 . get ( Calendar . DATE ) ; } | Determines whether the specified date1 is the same day with the specified date2 . | 106 | 18 |
24,920 | public static boolean isSameWeek ( final Date date1 , final Date date2 ) { final Calendar cal1 = Calendar . getInstance ( ) ; cal1 . setFirstDayOfWeek ( Calendar . MONDAY ) ; cal1 . setTime ( date1 ) ; final Calendar cal2 = Calendar . getInstance ( ) ; cal2 . setFirstDayOfWeek ( Calendar . MONDAY ) ; cal2 . setTime ( date2 ) ; return cal1 . get ( Calendar . ERA ) == cal2 . get ( Calendar . ERA ) && cal1 . get ( Calendar . YEAR ) == cal2 . get ( Calendar . YEAR ) && cal1 . get ( Calendar . WEEK_OF_YEAR ) == cal2 . get ( Calendar . WEEK_OF_YEAR ) ; } | Determines whether the specified date1 is the same week with the specified date2 . | 166 | 18 |
24,921 | public static boolean isSameMonth ( final Date date1 , final Date date2 ) { final Calendar cal1 = Calendar . getInstance ( ) ; cal1 . setTime ( date1 ) ; final Calendar cal2 = Calendar . getInstance ( ) ; cal2 . setTime ( date2 ) ; return cal1 . get ( Calendar . ERA ) == cal2 . get ( Calendar . ERA ) && cal1 . get ( Calendar . YEAR ) == cal2 . get ( Calendar . YEAR ) && cal1 . get ( Calendar . MONTH ) == cal2 . get ( Calendar . MONTH ) ; } | Determines whether the specified date1 is the same month with the specified date2 . | 126 | 18 |
24,922 | public static long getDayStartTime ( final long time ) { final Calendar start = Calendar . getInstance ( ) ; start . setTimeInMillis ( time ) ; final int year = start . get ( Calendar . YEAR ) ; final int month = start . get ( Calendar . MONTH ) ; final int day = start . get ( Calendar . DATE ) ; start . set ( year , month , day , 0 , 0 , 0 ) ; start . set ( Calendar . MILLISECOND , 0 ) ; return start . getTimeInMillis ( ) ; } | Gets the day start time with the specified time . | 119 | 11 |
24,923 | public static long getDayEndTime ( final long time ) { final Calendar end = Calendar . getInstance ( ) ; end . setTimeInMillis ( time ) ; final int year = end . get ( Calendar . YEAR ) ; final int month = end . get ( Calendar . MONTH ) ; final int day = end . get ( Calendar . DATE ) ; end . set ( year , month , day , 23 , 59 , 59 ) ; end . set ( Calendar . MILLISECOND , 999 ) ; return end . getTimeInMillis ( ) ; } | Gets the day end time with the specified time . | 119 | 11 |
24,924 | public static int getWeekDay ( final long time ) { final Calendar calendar = Calendar . getInstance ( ) ; calendar . setTimeInMillis ( time ) ; int ret = calendar . get ( Calendar . DAY_OF_WEEK ) - 1 ; if ( ret <= 0 ) { ret = 7 ; } return ret ; } | Gets the week day with the specified time . | 69 | 10 |
24,925 | public static long getWeekStartTime ( final long time ) { final Calendar start = Calendar . getInstance ( ) ; start . setFirstDayOfWeek ( Calendar . MONDAY ) ; start . setTimeInMillis ( time ) ; start . set ( Calendar . DAY_OF_WEEK , Calendar . MONDAY ) ; start . set ( Calendar . HOUR , 0 ) ; start . set ( Calendar . MINUTE , 0 ) ; start . set ( Calendar . SECOND , 0 ) ; start . set ( Calendar . MILLISECOND , 0 ) ; return start . getTimeInMillis ( ) ; } | Gets the week start time with the specified time . | 132 | 11 |
24,926 | public static long getWeekEndTime ( final long time ) { final Calendar end = Calendar . getInstance ( ) ; end . setFirstDayOfWeek ( Calendar . MONDAY ) ; end . setTimeInMillis ( time ) ; end . set ( Calendar . DAY_OF_WEEK , Calendar . SUNDAY ) ; end . set ( Calendar . HOUR , 23 ) ; end . set ( Calendar . MINUTE , 59 ) ; end . set ( Calendar . SECOND , 59 ) ; end . set ( Calendar . MILLISECOND , 999 ) ; return end . getTimeInMillis ( ) ; } | Gets the week end time with the specified time . | 131 | 11 |
24,927 | public static long getMonthStartTime ( final long time ) { final Calendar start = Calendar . getInstance ( ) ; start . setTimeInMillis ( time ) ; final int year = start . get ( Calendar . YEAR ) ; final int month = start . get ( Calendar . MONTH ) ; start . set ( year , month , 1 , 0 , 0 , 0 ) ; start . set ( Calendar . MILLISECOND , 0 ) ; return start . getTimeInMillis ( ) ; } | Gets the month start time with the specified time . | 105 | 11 |
24,928 | public static long getMonthEndTime ( final long time ) { final Calendar end = Calendar . getInstance ( ) ; end . setTimeInMillis ( getDayStartTime ( time ) ) ; end . set ( Calendar . DAY_OF_MONTH , end . getActualMaximum ( Calendar . DAY_OF_MONTH ) ) ; end . set ( Calendar . HOUR , 23 ) ; end . set ( Calendar . MINUTE , 59 ) ; end . set ( Calendar . SECOND , 59 ) ; end . set ( Calendar . MILLISECOND , 999 ) ; return end . getTimeInMillis ( ) ; } | Gets the month end time with the specified time . | 134 | 11 |
24,929 | public static < T > Set < T > arrayToSet ( final T [ ] array ) { if ( null == array ) { return Collections . emptySet ( ) ; } final Set < T > ret = new HashSet < T > ( ) ; for ( int i = 0 ; i < array . length ; i ++ ) { final T object = array [ i ] ; ret . add ( object ) ; } return ret ; } | Converts the specified array to a set . | 90 | 9 |
24,930 | private static MatchResult route ( final String requestURI , final String httpMethod , final Map < String , ContextHandlerMeta > pathVarContextHandlerMetasHolder ) { MatchResult ret ; for ( final Map . Entry < String , ContextHandlerMeta > entry : pathVarContextHandlerMetasHolder . entrySet ( ) ) { final String uriTemplate = entry . getKey ( ) ; final ContextHandlerMeta contextHandlerMeta = entry . getValue ( ) ; final Map < String , String > resolveResult = UriTemplates . resolve ( requestURI , uriTemplate ) ; if ( null == resolveResult ) { continue ; } ret = new MatchResult ( contextHandlerMeta , requestURI , httpMethod , uriTemplate ) ; ret . setPathVars ( resolveResult ) ; return ret ; } return null ; } | Routes the specified request URI containing path vars with the specified HTTP method and path var context handler metas holder . | 172 | 25 |
24,931 | private String getHttpMethod ( final HttpServletRequest request ) { String ret = ( String ) request . getAttribute ( Keys . HttpRequest . REQUEST_METHOD ) ; if ( StringUtils . isBlank ( ret ) ) { ret = request . getMethod ( ) ; } return ret ; } | Gets the HTTP method . | 66 | 6 |
24,932 | private String getRequestURI ( final HttpServletRequest request ) { String ret = ( String ) request . getAttribute ( Keys . HttpRequest . REQUEST_URI ) ; if ( StringUtils . isBlank ( ret ) ) { ret = request . getRequestURI ( ) ; } return ret ; } | Gets the request URI . | 67 | 6 |
24,933 | private void generateContextHandlerMeta ( final Set < Bean < ? > > processBeans ) { for ( final Bean < ? > latkeBean : processBeans ) { final Class < ? > clz = latkeBean . getBeanClass ( ) ; final Method [ ] declaredMethods = clz . getDeclaredMethods ( ) ; for ( int i = 0 ; i < declaredMethods . length ; i ++ ) { final Method method = declaredMethods [ i ] ; final RequestProcessing requestProcessingMethodAnn = method . getAnnotation ( RequestProcessing . class ) ; if ( null == requestProcessingMethodAnn ) { continue ; } final ContextHandlerMeta contextHandlerMeta = new ContextHandlerMeta ( ) ; contextHandlerMeta . setUriTemplates ( requestProcessingMethodAnn . value ( ) ) ; contextHandlerMeta . setHttpMethods ( requestProcessingMethodAnn . method ( ) ) ; contextHandlerMeta . setInvokeHolder ( method ) ; contextHandlerMeta . initProcessAdvices ( ) ; addContextHandlerMeta ( contextHandlerMeta ) ; } } } | Scan beans to get the context handler meta . | 231 | 9 |
24,934 | public void error ( final String msg ) { if ( proxy . isErrorEnabled ( ) ) { if ( proxy instanceof LocationAwareLogger ) { ( ( LocationAwareLogger ) proxy ) . log ( null , FQCN , LocationAwareLogger . ERROR_INT , msg , null , null ) ; } else { proxy . error ( msg ) ; } } } | Logs the specified message at the ERROR level . | 81 | 10 |
24,935 | public void warn ( final String msg ) { if ( proxy . isWarnEnabled ( ) ) { if ( proxy instanceof LocationAwareLogger ) { ( ( LocationAwareLogger ) proxy ) . log ( null , FQCN , LocationAwareLogger . WARN_INT , msg , null , null ) ; } else { proxy . warn ( msg ) ; } } } | Logs the specified message at the WARN level . | 82 | 10 |
24,936 | public void info ( final String msg ) { if ( proxy . isInfoEnabled ( ) ) { if ( proxy instanceof LocationAwareLogger ) { ( ( LocationAwareLogger ) proxy ) . log ( null , FQCN , LocationAwareLogger . INFO_INT , msg , null , null ) ; } else { proxy . info ( msg ) ; } } } | Logs the specified message at the INFO level . | 81 | 10 |
24,937 | public void debug ( final String msg ) { if ( proxy . isDebugEnabled ( ) ) { if ( proxy instanceof LocationAwareLogger ) { ( ( LocationAwareLogger ) proxy ) . log ( null , FQCN , LocationAwareLogger . DEBUG_INT , msg , null , null ) ; } else { proxy . debug ( msg ) ; } } } | Logs the specified message at the DEBUG level . | 81 | 10 |
24,938 | public void trace ( final String msg ) { if ( proxy . isTraceEnabled ( ) ) { if ( proxy instanceof LocationAwareLogger ) { ( ( LocationAwareLogger ) proxy ) . log ( null , FQCN , LocationAwareLogger . TRACE_INT , msg , null , null ) ; } else { proxy . trace ( msg ) ; } } } | Logs the specified message at the TRACE level . | 83 | 11 |
24,939 | public void log ( final Level level , final String msg , final Throwable throwable ) { switch ( level ) { case ERROR : if ( proxy . isErrorEnabled ( ) ) { if ( proxy instanceof LocationAwareLogger ) { ( ( LocationAwareLogger ) proxy ) . log ( null , FQCN , LocationAwareLogger . ERROR_INT , msg , null , throwable ) ; } else { proxy . error ( msg , throwable ) ; } } break ; case WARN : if ( proxy . isWarnEnabled ( ) ) { if ( proxy instanceof LocationAwareLogger ) { ( ( LocationAwareLogger ) proxy ) . log ( null , FQCN , LocationAwareLogger . WARN_INT , msg , null , throwable ) ; } else { proxy . warn ( msg , throwable ) ; } } break ; case INFO : if ( proxy . isInfoEnabled ( ) ) { if ( proxy instanceof LocationAwareLogger ) { ( ( LocationAwareLogger ) proxy ) . log ( null , FQCN , LocationAwareLogger . INFO_INT , msg , null , throwable ) ; } else { proxy . info ( msg , throwable ) ; } } break ; case DEBUG : if ( proxy . isDebugEnabled ( ) ) { if ( proxy instanceof LocationAwareLogger ) { ( ( LocationAwareLogger ) proxy ) . log ( null , FQCN , LocationAwareLogger . DEBUG_INT , msg , null , throwable ) ; } else { proxy . debug ( msg , throwable ) ; } } break ; case TRACE : if ( proxy . isTraceEnabled ( ) ) { if ( proxy instanceof LocationAwareLogger ) { ( ( LocationAwareLogger ) proxy ) . log ( null , FQCN , LocationAwareLogger . TRACE_INT , msg , null , throwable ) ; } else { proxy . trace ( msg , throwable ) ; } } break ; default : throw new IllegalStateException ( "Logging level [" + level + "] is invalid" ) ; } } | Logs the specified message with the specified logging level and throwable . | 453 | 14 |
24,940 | public void log ( final Level level , final String msg , final Object ... args ) { String message = msg ; if ( null != args && 0 < args . length ) { // Is it a java.text style format? // Ideally we could match with Pattern.compile("\\{\\d").matcher(format).find()) // However the cost is 14% higher, so we cheaply check for 1 of the first 4 parameters if ( msg . indexOf ( "{0" ) >= 0 || msg . indexOf ( "{1" ) >= 0 || msg . indexOf ( "{2" ) >= 0 || msg . indexOf ( "{3" ) >= 0 ) { message = java . text . MessageFormat . format ( msg , args ) ; } } switch ( level ) { case ERROR : if ( proxy . isErrorEnabled ( ) ) { if ( proxy instanceof LocationAwareLogger ) { ( ( LocationAwareLogger ) proxy ) . log ( null , FQCN , LocationAwareLogger . ERROR_INT , message , null , null ) ; } else { proxy . error ( message ) ; } } break ; case WARN : if ( proxy . isWarnEnabled ( ) ) { if ( proxy instanceof LocationAwareLogger ) { ( ( LocationAwareLogger ) proxy ) . log ( null , FQCN , LocationAwareLogger . WARN_INT , message , null , null ) ; } else { proxy . warn ( message ) ; } } break ; case INFO : if ( proxy . isInfoEnabled ( ) ) { if ( proxy instanceof LocationAwareLogger ) { ( ( LocationAwareLogger ) proxy ) . log ( null , FQCN , LocationAwareLogger . INFO_INT , message , null , null ) ; } else { proxy . info ( message ) ; } } break ; case DEBUG : if ( proxy . isDebugEnabled ( ) ) { if ( proxy instanceof LocationAwareLogger ) { ( ( LocationAwareLogger ) proxy ) . log ( null , FQCN , LocationAwareLogger . DEBUG_INT , message , null , null ) ; } else { proxy . debug ( message ) ; } } break ; case TRACE : if ( proxy . isTraceEnabled ( ) ) { if ( proxy instanceof LocationAwareLogger ) { ( ( LocationAwareLogger ) proxy ) . log ( null , FQCN , LocationAwareLogger . TRACE_INT , message , null , null ) ; } else { proxy . trace ( message ) ; } } break ; default : throw new IllegalStateException ( "Logging level [" + level + "] is invalid" ) ; } } | Logs the specified message with the specified logging level and arguments . | 572 | 13 |
24,941 | public boolean isLoggable ( final Level level ) { switch ( level ) { case TRACE : return isTraceEnabled ( ) ; case DEBUG : return isDebugEnabled ( ) ; case INFO : return isInfoEnabled ( ) ; case WARN : return isWarnEnabled ( ) ; case ERROR : return isErrorEnabled ( ) ; default : throw new IllegalStateException ( "Logging level [" + level + "] is invalid" ) ; } } | Checks if a message of the given level would actually be logged by this logger . | 95 | 17 |
24,942 | public static < T > Publisher < T > publisher ( Observable < T > observable ) { return observable . toFlowable ( BackpressureStrategy . BUFFER ) ; } | Convert an Observable to a reactive - streams Publisher | 36 | 11 |
24,943 | public static < T > ReactiveSeq < T > connectToReactiveSeq ( Observable < T > observable ) { return Spouts . async ( s -> { observable . subscribe ( s :: onNext , e -> { s . onError ( e ) ; s . onComplete ( ) ; } , s :: onComplete ) ; } ) ; } | Convert an Observable to a cyclops - react ReactiveSeq | 75 | 15 |
24,944 | public static < T > Observable < T > observable ( Publisher < T > publisher ) { return Flowable . fromPublisher ( publisher ) . toObservable ( ) ; } | Convert a Publisher to an observable | 37 | 7 |
24,945 | public static < T > AnyMSeq < observable , T > anyM ( Observable < T > obs ) { return AnyM . ofSeq ( ObservableReactiveSeq . reactiveSeq ( obs ) , observable . INSTANCE ) ; } | Construct an AnyM type from an Observable . This allows the Observable to be manipulated according to a standard interface along with a vast array of other Java Monad implementations | 54 | 34 |
24,946 | public static MutableChar fromExternal ( final Supplier < Character > s , final Consumer < Character > c ) { return new MutableChar ( ) { @ Override public char getAsChar ( ) { return s . get ( ) ; } @ Override public Character get ( ) { return getAsChar ( ) ; } @ Override public MutableChar set ( final char value ) { c . accept ( value ) ; return this ; } } ; } | Construct a MutableChar that gets and sets an external value using the provided Supplier and Consumer | 96 | 19 |
24,947 | public static MutableDouble fromExternal ( final DoubleSupplier s , final DoubleConsumer c ) { return new MutableDouble ( ) { @ Override public double getAsDouble ( ) { return s . getAsDouble ( ) ; } @ Override public Double get ( ) { return getAsDouble ( ) ; } @ Override public MutableDouble set ( final double value ) { c . accept ( value ) ; return this ; } } ; } | Construct a MutableDouble that gets and sets an external value using the provided Supplier and Consumer | 94 | 19 |
24,948 | public static < T1 , T2 , R > Maybe < R > combine ( Maybe < ? extends T1 > maybe , Maybe < ? extends T2 > app , BiFunction < ? super T1 , ? super T2 , ? extends R > fn ) { return narrow ( Single . fromPublisher ( Future . fromPublisher ( maybe . toFlowable ( ) ) . zip ( Future . fromPublisher ( app . toFlowable ( ) ) , fn ) ) . toMaybe ( ) ) ; } | Lazily combine this Maybe with the supplied Maybe via the supplied BiFunction | 104 | 15 |
24,949 | public static < T > Maybe < T > fromIterable ( Iterable < T > t ) { return narrow ( Single . fromPublisher ( Future . fromIterable ( t ) ) . toMaybe ( ) ) ; } | Construct a Maybe from Iterable by taking the first value from Iterable | 46 | 14 |
24,950 | public < R1 , R2 , R4 > Writer < W , R4 > forEach3 ( Function < ? super T , ? extends Writer < W , R1 > > value2 , BiFunction < ? super T , ? super R1 , ? extends Writer < W , R2 > > value3 , Function3 < ? super T , ? super R1 , ? super R2 , ? extends R4 > yieldingFunction ) { return this . flatMap ( in -> { Writer < W , R1 > a = value2 . apply ( in ) ; return a . flatMap ( ina -> { Writer < W , R2 > b = value3 . apply ( in , ina ) ; return b . map ( in2 -> { return yieldingFunction . apply ( in , ina , in2 ) ; } ) ; } ) ; } ) ; } | Perform a For Comprehension over a Writer accepting 2 generating function . This results in a three level nested internal iteration over the provided Writers . | 182 | 29 |
24,951 | public < R1 , R4 > Writer < W , R4 > forEach2 ( Function < ? super T , Writer < W , R1 > > value2 , BiFunction < ? super T , ? super R1 , ? extends R4 > yieldingFunction ) { return this . flatMap ( in -> { Writer < W , R1 > a = value2 . apply ( in ) ; return a . map ( in2 -> { return yieldingFunction . apply ( in , in2 ) ; } ) ; } ) ; } | Perform a For Comprehension over a Writer accepting a generating function . This results in a two level nested internal iteration over the provided Writers . | 111 | 29 |
24,952 | public static < R > FluentFunctions . FluentSupplier < R > of ( final Supplier < R > supplier ) { return new FluentSupplier <> ( supplier ) ; } | Construct a FluentSupplier from a Supplier | 41 | 10 |
24,953 | public static < T , R > FluentFunctions . FluentFunction < T , R > ofChecked ( final CheckedFunction < T , R > fn ) { return FluentFunctions . of ( ExceptionSoftener . softenFunction ( fn ) ) ; } | Construct a FluentFunction from a CheckedFunction | 56 | 10 |
24,954 | public static < T , R > FluentFunctions . FluentFunction < T , R > of ( final Function < T , R > fn ) { return new FluentFunction <> ( fn ) ; } | Construct a FluentFunction from a Function | 44 | 8 |
24,955 | public static < T1 , T2 , R > FluentFunctions . FluentBiFunction < T1 , T2 , R > ofChecked ( final CheckedBiFunction < T1 , T2 , R > fn ) { return FluentFunctions . of ( ExceptionSoftener . softenBiFunction ( fn ) ) ; } | Construct a FluentBiFunction from a CheckedBiFunction | 71 | 12 |
24,956 | public static < T1 , T2 > FluentFunctions . FluentBiFunction < T1 , T2 , Tuple2 < T1 , T2 > > checkedExpression ( final CheckedBiConsumer < T1 , T2 > action ) { final BiConsumer < T1 , T2 > toUse = ExceptionSoftener . softenBiConsumer ( action ) ; return FluentFunctions . of ( ( t1 , t2 ) -> { toUse . accept ( t1 , t2 ) ; return Tuple . tuple ( t1 , t2 ) ; } ) ; } | Convert a CheckedBiConsumer into a FluentBiConsumer that returns it s input in a tuple | 125 | 21 |
24,957 | public boolean isSatisfiedBy ( final Date date ) { final Calendar testDateCal = Calendar . getInstance ( getTimeZone ( ) ) ; testDateCal . setTime ( date ) ; testDateCal . set ( Calendar . MILLISECOND , 0 ) ; final Date originalDate = testDateCal . getTime ( ) ; testDateCal . add ( Calendar . SECOND , - 1 ) ; final Date timeAfter = getTimeAfter ( testDateCal . getTime ( ) ) ; return timeAfter != null && timeAfter . equals ( originalDate ) ; } | Indicates whether the given date satisfies the cron expression . Note that milliseconds are ignored so two Dates falling on different milliseconds of the same second will always have the same result here . | 121 | 36 |
24,958 | public static < CRE , C2 > Compose < CRE , C2 > compose ( Functor < CRE > f , Functor < C2 > g ) { return new Compose <> ( f , g ) ; } | Compose two functors | 47 | 5 |
24,959 | public static < T1 , T2 , T3 , R1 , R2 , R3 , R > Stream < R > forEach4 ( Stream < ? extends T1 > value1 , Function < ? super T1 , ? extends Stream < R1 > > value2 , BiFunction < ? super T1 , ? super R1 , ? extends Stream < R2 > > value3 , Function3 < ? super T1 , ? super R1 , ? super R2 , ? extends Stream < R3 > > value4 , Function4 < ? super T1 , ? super R1 , ? super R2 , ? super R3 , ? extends R > yieldingFunction ) { return value1 . flatMap ( in -> { Stream < R1 > a = value2 . apply ( in ) ; return a . flatMap ( ina -> { Stream < R2 > b = value3 . apply ( in , ina ) ; return b . flatMap ( inb -> { Stream < R3 > c = value4 . apply ( in , ina , inb ) ; return c . map ( in2 -> yieldingFunction . apply ( in , ina , inb , in2 ) ) ; } ) ; } ) ; } ) ; } | Perform a For Comprehension over a Stream accepting 3 generating arrow . This results in a four level nested internal iteration over the provided Publishers . | 263 | 29 |
24,960 | public final static < T > Optional < Seq < T > > streamToOptional ( final Stream < T > stream ) { final List < T > collected = stream . collect ( java . util . stream . Collectors . toList ( ) ) ; if ( collected . size ( ) == 0 ) return Optional . empty ( ) ; return Optional . of ( Seq . fromIterable ( collected ) ) ; } | Create an Optional containing a List materialized from a Stream | 86 | 11 |
24,961 | public final static < T > Stream < T > optionalToStream ( final Optional < T > optional ) { if ( optional . isPresent ( ) ) return Stream . of ( optional . get ( ) ) ; return Stream . of ( ) ; } | Convert an Optional to a Stream | 51 | 7 |
24,962 | public final static < T > CompletableFuture < List < T > > streamToCompletableFuture ( final Stream < T > stream ) { return CompletableFuture . completedFuture ( stream . collect ( Collectors . toList ( ) ) ) ; } | Create a CompletableFuture containing a List materialized from a Stream | 55 | 14 |
24,963 | public final static < T > Stream < T > completableFutureToStream ( final CompletableFuture < T > future ) { return Stream . of ( future . join ( ) ) ; } | Convert a CompletableFuture to a Stream | 40 | 10 |
24,964 | @ SuppressWarnings ( "unchecked" ) public final static < T > Tuple4 < Stream < T > , Stream < T > , Stream < T > , Stream < T > > quadruplicate ( final Stream < T > stream ) { final Stream < Stream < T > > its = Streams . toBufferingCopier ( stream . iterator ( ) , 4 ) . stream ( ) . map ( it -> Streams . stream ( it ) ) ; final Iterator < Stream < T > > it = its . iterator ( ) ; return new Tuple4 ( it . next ( ) , it . next ( ) , it . next ( ) , it . next ( ) ) ; } | Makes four copies of a Stream Buffers intermediate values leaders may change positions so a limit can be safely applied to the leading stream . Not thread - safe . | 148 | 32 |
24,965 | public static final < T > Stream < T > appendStream ( final Stream < T > stream1 , final Stream < T > append ) { return Stream . concat ( stream1 , append ) ; } | Append Stream to this Stream | 42 | 6 |
24,966 | public static final < T > Stream < T > prependStream ( final Stream < T > stream1 , final Stream < T > prepend ) { return Stream . concat ( prepend , stream1 ) ; } | Prepend Stream to this Stream | 45 | 6 |
24,967 | public static < U > Stream < U > dropWhile ( final Stream < U > stream , final Predicate < ? super U > predicate ) { return StreamSupport . stream ( new SkipWhileSpliterator < U > ( stream . spliterator ( ) , predicate ) , stream . isParallel ( ) ) ; } | skip elements in a Stream while Predicate holds true | 65 | 10 |
24,968 | public static < U > Stream < U > cycle ( final Stream < U > s ) { return cycle ( Streamable . fromStream ( s ) ) ; } | Create a new Stream that infiniteable cycles the provided Stream | 33 | 11 |
24,969 | @ SuppressWarnings ( { "rawtypes" , "unchecked" } ) public static < R > Seq < R > reduce ( final Stream < R > stream , final Iterable < ? extends Monoid < R > > reducers ) { return Seq . fromIterable ( new MultiReduceOperator < R > ( stream ) . reduce ( reducers ) ) ; } | Simultaneously reduce a stream with multiple reducers | 83 | 10 |
24,970 | @ SuppressWarnings ( { "rawtypes" , "unchecked" } ) public static < R > Seq < R > reduce ( final Stream < R > stream , final Stream < ? extends Monoid < R > > reducers ) { return reduce ( stream , Seq . fromIterable ( ( List ) reducers . collect ( java . util . stream . Collectors . toList ( ) ) ) ) ; } | Simultanously reduce a stream with multiple reducers | 91 | 10 |
24,971 | public final static < T > Stream < T > cycleUntil ( final Stream < T > stream , final Predicate < ? super T > predicate ) { return Streams . takeUntil ( Streams . cycle ( stream ) , predicate ) ; } | Repeat in a Stream until specified predicate holds | 50 | 8 |
24,972 | public final static < T , S , R > Stream < R > zipSequence ( final Stream < T > stream , final Stream < ? extends S > second , final BiFunction < ? super T , ? super S , ? extends R > zipper ) { final Iterator < T > left = stream . iterator ( ) ; final Iterator < ? extends S > right = second . iterator ( ) ; return Streams . stream ( new Iterator < R > ( ) { @ Override public boolean hasNext ( ) { return left . hasNext ( ) && right . hasNext ( ) ; } @ Override public R next ( ) { return zipper . apply ( left . next ( ) , right . next ( ) ) ; } } ) ; } | Generic zip function . E . g . Zipping a Stream and a Sequence | 156 | 15 |
24,973 | public final static < T > Stream < Vector < T > > grouped ( final Stream < T > stream , final int groupSize ) { return StreamSupport . stream ( new GroupingSpliterator <> ( stream . spliterator ( ) , ( ) -> Vector . empty ( ) , c -> Vector . fromIterable ( c ) , groupSize ) , stream . isParallel ( ) ) ; } | Group elements in a Stream by size | 83 | 7 |
24,974 | public final static < T > Stream < T > scanLeft ( final Stream < T > stream , final Monoid < T > monoid ) { final Iterator < T > it = stream . iterator ( ) ; return Streams . stream ( new Iterator < T > ( ) { boolean init = false ; T next = monoid . zero ( ) ; @ Override public boolean hasNext ( ) { if ( ! init ) return true ; return it . hasNext ( ) ; } @ Override public T next ( ) { if ( ! init ) { init = true ; return monoid . zero ( ) ; } return next = monoid . apply ( next , it . next ( ) ) ; } } ) ; } | Scan left using supplied Monoid | 151 | 6 |
24,975 | public static < T > boolean xMatch ( final Stream < T > stream , final int num , final Predicate < ? super T > c ) { return stream . filter ( t -> c . test ( t ) ) . collect ( java . util . stream . Collectors . counting ( ) ) == num ; } | Check that there are specified number of matches of predicate in the Stream | 65 | 13 |
24,976 | public final static < T , R > R foldMap ( final Stream < T > stream , final Function < ? super T , ? extends R > mapper , final Monoid < R > reducer ) { return reducer . foldLeft ( stream . map ( mapper ) ) ; } | Attempt to transform this Stream to the same type as the supplied Monoid using supplied function Then use Monoid to reduce values | 60 | 24 |
24,977 | public static < T > Stream < T > intersperse ( final Stream < T > stream , final T value ) { return stream . flatMap ( t -> Stream . of ( value , t ) ) . skip ( 1 ) ; } | Returns a stream with a given value interspersed between any two values of this stream . | 49 | 18 |
24,978 | @ SuppressWarnings ( "unchecked" ) public static < T , U > Stream < U > ofType ( final Stream < T > stream , final Class < ? extends U > type ) { return stream . filter ( type :: isInstance ) . map ( t -> ( U ) t ) ; } | Keep only those elements in a stream that are of a given type . | 65 | 14 |
24,979 | public final static < T > Stream < Character > flatMapCharSequence ( final Stream < T > stream , final Function < ? super T , CharSequence > fn ) { return stream . flatMap ( fn . andThen ( CharSequence :: chars ) . andThen ( s -> s . mapToObj ( i -> Character . toChars ( i ) [ 0 ] ) ) ) ; } | rename - flatMapCharSequence | 84 | 8 |
24,980 | public final static < T > Stream < String > flatMapFile ( final Stream < T > stream , final Function < ? super T , File > fn ) { return stream . flatMap ( fn . andThen ( f -> ExceptionSoftener . softenSupplier ( ( ) -> Files . lines ( Paths . get ( f . getAbsolutePath ( ) ) ) ) . get ( ) ) ) ; } | Perform a flatMap operation where the result will be a flattened stream of Strings from the text loaded from the supplied files . | 85 | 26 |
24,981 | public final static < T > Stream < String > flatMapURL ( final Stream < T > stream , final Function < ? super T , URL > fn ) { return stream . flatMap ( fn . andThen ( url -> ExceptionSoftener . softenSupplier ( ( ) -> { final BufferedReader in = new BufferedReader ( new InputStreamReader ( url . openStream ( ) ) ) ; return in . lines ( ) ; } ) . get ( ) ) ) ; } | Perform a flatMap operation where the result will be a flattened stream of Strings from the text loaded from the supplied URLs | 100 | 25 |
24,982 | public final static < T > Stream < String > flatMapBufferedReader ( final Stream < T > stream , final Function < ? super T , BufferedReader > fn ) { return stream . flatMap ( fn . andThen ( in -> ExceptionSoftener . softenSupplier ( ( ) -> { return in . lines ( ) ; } ) . get ( ) ) ) ; } | Perform a flatMap operation where the result will be a flattened stream of Strings from the text loaded from the supplied BufferedReaders | 79 | 28 |
24,983 | public final static < T > Stream < Seq < T > > groupedStatefullyUntil ( final Stream < T > stream , final BiPredicate < Seq < ? super T > , ? super T > predicate ) { return StreamSupport . stream ( new GroupedStatefullySpliterator <> ( stream . spliterator ( ) , ( ) -> Seq . of ( ) , Function . identity ( ) , predicate . negate ( ) ) , stream . isParallel ( ) ) ; } | Group data in a Stream using knowledge of the current batch and the next entry to determing grouping limits | 102 | 20 |
24,984 | public final static < T > Stream < Seq < T > > groupedUntil ( final Stream < T > stream , final Predicate < ? super T > predicate ) { return groupedWhile ( stream , predicate . negate ( ) ) ; } | Group a Stream until the supplied predicate holds | 49 | 8 |
24,985 | public final static < T > Stream < T > debounce ( final Stream < T > stream , final long time , final TimeUnit t ) { return new DebounceOperator <> ( stream ) . debounce ( time , t ) ; } | Allow one element through per time period drop all other elements in that time period | 51 | 15 |
24,986 | public final static < T > Stream < T > onePer ( final Stream < T > stream , final long time , final TimeUnit t ) { return new OnePerOperator <> ( stream ) . onePer ( time , t ) ; } | emit one element per time period | 51 | 7 |
24,987 | public static MutableLong fromExternal ( final LongSupplier s , final LongConsumer c ) { return new MutableLong ( ) { @ Override public long getAsLong ( ) { return s . getAsLong ( ) ; } @ Override public Long get ( ) { return getAsLong ( ) ; } @ Override public MutableLong set ( final long value ) { c . accept ( value ) ; return this ; } } ; } | Construct a MutableLong that gets and sets an external value using the provided Supplier and Consumer | 94 | 19 |
24,988 | public < R > R submit ( final Function < RS , R > fn ) { return submit ( ( ) -> fn . apply ( this . results ) ) ; } | This method allows the SimpleReact Executor to be reused by JDK parallel streams . It is best used when collectResults and block are called explicitly for finer grained control over the blocking conditions . | 34 | 40 |
24,989 | public < T > T submit ( final Callable < T > callable ) { if ( taskExecutor instanceof ForkJoinPool ) { try { return ( ( ForkJoinPool ) taskExecutor ) . submit ( callable ) . get ( ) ; } catch ( final ExecutionException e ) { throw ExceptionSoftener . throwSoftenedException ( e ) ; } catch ( final InterruptedException e ) { Thread . currentThread ( ) . interrupt ( ) ; throw ExceptionSoftener . throwSoftenedException ( e ) ; } } try { return callable . call ( ) ; } catch ( final Exception e ) { throw new RuntimeException ( e ) ; } } | This method allows the SimpleReact Executor to be reused by JDK parallel streams | 139 | 17 |
24,990 | public static < R > Function0 < R > memoizeSupplierAsync ( final Supplier < R > fn , ScheduledExecutorService ex , long updateRateInMillis ) { return ( ) -> Memoize . memoizeFunctionAsync ( a -> fn . get ( ) , ex , updateRateInMillis ) . apply ( "k" ) ; } | Memoize a Supplier and update the cached values asynchronously using the provided Scheduled Executor Service Does not support null keys | 77 | 27 |
24,991 | public static < T1 , T2 , R > Function2 < T1 , T2 , R > memoizeBiFunction ( final BiFunction < T1 , T2 , R > fn ) { Function1 < Tuple2 < T1 , T2 > , R > memoise2 = memoizeFunction ( ( final Tuple2 < T1 , T2 > pair ) -> fn . apply ( pair . _1 ( ) , pair . _2 ( ) ) ) ; return ( t1 , t2 ) -> memoise2 . apply ( tuple ( t1 , t2 ) ) ; } | Convert a BiFunction into one that caches it s result | 127 | 12 |
24,992 | public static < T1 , T2 , T3 , R > Function3 < T1 , T2 , T3 , R > memoizeTriFunction ( final Function3 < T1 , T2 , T3 , R > fn , final Cacheable < R > cache ) { Function1 < Tuple3 < T1 , T2 , T3 > , R > memoise2 = memoizeFunction ( ( final Tuple3 < T1 , T2 , T3 > triple ) -> fn . apply ( triple . _1 ( ) , triple . _2 ( ) , triple . _3 ( ) ) , cache ) ; return ( t1 , t2 , t3 ) -> memoise2 . apply ( tuple ( t1 , t2 , t3 ) ) ; } | Convert a TriFunction into one that caches it s result | 165 | 12 |
24,993 | public static < T1 , T2 , T3 , T4 , R > Function4 < T1 , T2 , T3 , T4 , R > memoizeQuadFunction ( final Function4 < T1 , T2 , T3 , T4 , R > fn ) { Function1 < Tuple4 < T1 , T2 , T3 , T4 > , R > memoise2 = memoizeFunction ( ( final Tuple4 < T1 , T2 , T3 , T4 > quad ) -> fn . apply ( quad . _1 ( ) , quad . _2 ( ) , quad . _3 ( ) , quad . _4 ( ) ) ) ; return ( t1 , t2 , t3 , t4 ) -> memoise2 . apply ( tuple ( t1 , t2 , t3 , t4 ) ) ; } | Convert a QuadFunction into one that caches it s result | 184 | 12 |
24,994 | public static < T > Predicate < T > memoizePredicate ( final Predicate < T > p , final Cacheable < Boolean > cache ) { final Function < T , Boolean > memoised = memoizeFunction ( ( Function < T , Boolean > ) t -> p . test ( t ) , cache ) ; LazyImmutable < Boolean > nullR = LazyImmutable . def ( ) ; return ( t ) - > t == null ? nullR . computeIfAbsent ( ( ) -> p . test ( null ) ) : memoised . apply ( t ) ; } | Convert a Predicate into one that caches it s result | 123 | 12 |
24,995 | public static < T > Mono < T > anyOf ( Mono < T > ... fts ) { return Mono . from ( Future . anyOf ( futures ( fts ) ) ) ; } | Select the first Mono to complete | 40 | 6 |
24,996 | public static < T1 , T2 , R1 , R2 , R > Mono < R > forEach3 ( Mono < ? extends T1 > value1 , Function < ? super T1 , ? extends Mono < R1 > > value2 , BiFunction < ? super T1 , ? super R1 , ? extends Mono < R2 > > value3 , Function3 < ? super T1 , ? super R1 , ? super R2 , ? extends R > yieldingFunction ) { Future < ? extends R > res = Future . fromPublisher ( value1 ) . flatMap ( in -> { Future < R1 > a = Future . fromPublisher ( value2 . apply ( in ) ) ; return a . flatMap ( ina -> { Future < R2 > b = Future . fromPublisher ( value3 . apply ( in , ina ) ) ; return b . map ( in2 -> yieldingFunction . apply ( in , ina , in2 ) ) ; } ) ; } ) ; return Mono . from ( res ) ; } | Perform a For Comprehension over a Mono accepting 2 generating functions . This results in a three level nested internal iteration over the provided Monos . | 219 | 30 |
24,997 | public static < T , R1 , R > Mono < R > forEach ( Mono < ? extends T > value1 , Function < ? super T , Mono < R1 > > value2 , BiFunction < ? super T , ? super R1 , ? extends R > yieldingFunction ) { Future < R > res = Future . fromPublisher ( value1 ) . flatMap ( in -> { Future < R1 > a = Future . fromPublisher ( value2 . apply ( in ) ) ; return a . map ( ina -> yieldingFunction . apply ( in , ina ) ) ; } ) ; return Mono . from ( res ) ; } | Perform a For Comprehension over a Mono accepting a generating function . This results in a two level nested internal iteration over the provided Monos . | 135 | 30 |
24,998 | public static < T > Mono < T > fromIterable ( Iterable < T > t ) { return Mono . from ( Flux . fromIterable ( t ) ) ; } | Construct a Mono from Iterable by taking the first value from Iterable | 38 | 14 |
24,999 | public static MutableShort fromExternal ( final Supplier < Short > s , final Consumer < Short > c ) { return new MutableShort ( ) { @ Override public short getAsShort ( ) { return s . get ( ) ; } @ Override public Short get ( ) { return getAsShort ( ) ; } @ Override public MutableShort set ( final short value ) { c . accept ( value ) ; return this ; } } ; } | Construct a MutableShort that gets and sets an external value using the provided Supplier and Consumer | 96 | 19 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.