idx int64 0 165k | question stringlengths 73 4.15k | target stringlengths 5 918 | len_question int64 21 890 | len_target int64 3 255 |
|---|---|---|---|---|
9,100 | void configureEndpoints ( Reflections reflections ) { // [Re]initialise the api: api = new HashMap <> ( ) ; log . info ( "Scanning for endpoint classes.." ) ; Set < Class < ? > > endpoints = reflections . getTypesAnnotatedWith ( Api . class ) ; // log.info(reflections.getConfiguration().getUrls()); log . info ( "Found {} endpoint classes." , endpoints . size ( ) ) ; log . info ( "Examining endpoint class methods:" ) ; // Configure the classes: for ( Class < ? > endpointClass : endpoints ) { Route route = getEndpoint ( endpointClass ) ; route . endpointClass = endpointClass ; for ( Method method : endpointClass . getMethods ( ) ) { // Skip Object methods if ( method . getDeclaringClass ( ) == Object . class ) { continue ; } // Find public methods: if ( Modifier . isPublic ( method . getModifiers ( ) ) ) { // Which HTTP method(s) will this method respond to? annotation : for ( Annotation annotation : method . getAnnotations ( ) ) { HttpMethod httpMethod = HttpMethod . method ( annotation ) ; if ( httpMethod != null ) { log . info ( "Http method: {}" , httpMethod ) ; RequestHandler requestHandler = new RequestHandler ( ) ; requestHandler . handlerMethod = method ; log . info ( "Java method: {}" , method . getName ( ) ) ; // Look for an optional Json message type parameter: for ( Class < ? > parameterType : method . getParameterTypes ( ) ) { if ( ! HttpServletRequest . class . isAssignableFrom ( parameterType ) && ! HttpServletResponse . class . isAssignableFrom ( parameterType ) ) { if ( requestHandler . requestMessageType != null ) { log . error ( "Too many parameters on {} method {}. " + "Message type already set to {} but also found a {} parameter." , httpMethod , method . getName ( ) , requestHandler . requestMessageType . getSimpleName ( ) , parameterType . getSimpleName ( ) ) ; break annotation ; } requestHandler . requestMessageType = parameterType ; log . info ( "request Json: {}" , requestHandler . requestMessageType . getSimpleName ( ) ) ; } } // Check the response Json message type: if ( method . getReturnType ( ) != void . class ) { requestHandler . responseMessageType = method . getReturnType ( ) ; log . info ( "Response Json: {}" , requestHandler . responseMessageType . getSimpleName ( ) ) ; } route . requestHandlers . put ( httpMethod , requestHandler ) ; } } } } } } | Searches for and configures all your lovely endpoints . | 594 | 13 |
9,101 | void configureNotFound ( Reflections reflections ) { log . info ( "Checking for a not-found endpoint.." ) ; NotFound notFound = getEndpoint ( NotFound . class , "not-found" , reflections ) ; if ( notFound == null ) notFound = new DefaultNotFound ( ) ; printEndpoint ( notFound , "not-found" ) ; this . notFound = notFound ; } | Searches for and configures the not found endpoint . | 90 | 12 |
9,102 | void configureServerError ( Reflections reflections ) { log . info ( "Checking for an error endpoint.." ) ; ServerError serverError = getEndpoint ( ServerError . class , "error" , reflections ) ; if ( serverError == null ) serverError = new DefaultServerError ( ) ; printEndpoint ( serverError , "error" ) ; this . serverError = serverError ; } | Searches for and configures the not error endpoint . | 84 | 12 |
9,103 | private static < E > E getEndpoint ( Class < E > type , String name , Reflections reflections ) { E result = null ; // Get concrete subclasses: Set < Class < ? extends E > > foundClasses = reflections . getSubTypesOf ( type ) ; Set < Class < ? extends E > > endpointClasses = new HashSet <> ( ) ; for ( Class < ? extends E > clazz : foundClasses ) { if ( ! Modifier . isAbstract ( clazz . getModifiers ( ) ) ) { endpointClasses . add ( clazz ) ; } } // Filter out any default routes: //log.info("Filtering " + type.getName()); Iterator < Class < ? extends E > > iterator = endpointClasses . iterator ( ) ; while ( iterator . hasNext ( ) ) { Class < ? extends E > next = iterator . next ( ) ; if ( StringUtils . startsWithIgnoreCase ( next . getName ( ) , "com.github.davidcarboni.restolino.routes." ) ) { //log.info("Filtered out " + next.getName()); iterator . remove ( ) ; } //else { //log.info("Filtered in " + next.getName()); //} } //log.info("Filtered."); if ( endpointClasses . size ( ) != 0 ) { // Dump multiple endpoints: if ( endpointClasses . size ( ) > 1 ) { log . info ( "Warning: found multiple candidates for {} endpoint: {}" , name , endpointClasses ) ; } // Instantiate the endpoint if possible: try { result = endpointClasses . iterator ( ) . next ( ) . newInstance ( ) ; } catch ( Exception e ) { log . info ( "Error: cannot instantiate {} endpoint class {}" , name , endpointClasses . iterator ( ) . next ( ) ) ; e . printStackTrace ( ) ; } } return result ; } | Locates a single endpoint class . | 424 | 7 |
9,104 | public String mapRequestPath ( HttpServletRequest request ) { String endpointName = Path . newInstance ( request ) . firstSegment ( ) ; return StringUtils . lowerCase ( endpointName ) ; } | Determines the route name for the path of the given request . | 45 | 14 |
9,105 | @ Override public E apply ( Iterator < E > consumable ) { dbc . precondition ( consumable != null , "consuming a null iterator" ) ; dbc . precondition ( consumable . hasNext ( ) , "no element to consume" ) ; return consumable . next ( ) ; } | Consumes the first element from the passed iterator . | 68 | 10 |
9,106 | public static void start ( Path root , WatchService watcher ) { Scanner . watcher = watcher ; Scanner . root = root ; log . info ( "Monitoring changes under {}" , root ) ; Thread t = new Thread ( new Scanner ( ) , "Directory scanner" ) ; t . setDaemon ( true ) ; t . start ( ) ; } | Starts the scanning thread . | 79 | 6 |
9,107 | @ Override public E apply ( Iterator < E > consumable ) { dbc . precondition ( consumable != null , "consuming a null iterator" ) ; dbc . precondition ( consumable . hasNext ( ) , "no element to consume" ) ; E value = consumable . next ( ) ; while ( consumable . hasNext ( ) ) { value = consumable . next ( ) ; } return value ; } | Consumes the iterator and yields the last element contained in it . | 94 | 13 |
9,108 | @ Override public R apply ( T former , U latter ) { return function . apply ( latter , former ) ; } | Performs on the nested function swapping former and latter formal parameters . | 25 | 13 |
9,109 | public static String serialise ( Object object ) { Gson gson = getBuilder ( ) . create ( ) ; return gson . toJson ( object ) ; } | Serialises the given object to Json . | 36 | 9 |
9,110 | public static < O > O deserialise ( String json , Class < O > type ) { Gson gson = getBuilder ( ) . create ( ) ; return gson . fromJson ( json , type ) ; } | Deserialises the given json String . | 48 | 8 |
9,111 | public boolean foundPomXml ( final File directory , final int depth ) { LOG . debug ( "Directory: {}" , directory ) ; if ( depth == - 1 || directory == null || ! directory . isDirectory ( ) ) { return false ; } else { File [ ] pomFiles = directory . listFiles ( new FileFilter ( ) { @ Override public boolean accept ( final File pathname ) { return "pom.xml" . equals ( pathname . getName ( ) ) ; } } ) ; if ( pomFiles . length == 1 ) { pathToPomXml = pomFiles [ 0 ] ; return true ; } else { return foundPomXml ( directory . getParentFile ( ) , depth - 1 ) ; } } } | Tries to find the pom recursively by going up in the directory tree . | 164 | 18 |
9,112 | @ Override public void link ( NGScope scope , JQElement element , JSON attrs ) { IsWidget widget = scope . get ( getName ( ) ) ; String id = "gwt-widget-" + counter ++ ; element . attr ( "id" , id ) ; RootPanel . get ( id ) . add ( widget ) ; } | Replaces the element body with the GWT widget passed via gwt - widget attribute . GWT widget must implement IsWidget interface . | 74 | 27 |
9,113 | @ Override public Pair < Optional < E1 > , Optional < E2 > > next ( ) { return Pair . of ( former . next ( ) , latter . next ( ) ) ; } | iterating over the longest iterator gives a Pair of Optional . nothing indefinitely no matter how many times you try you can t shoot the dog | 41 | 27 |
9,114 | public void createXMLData ( final String classname ) { data = new Kopemedata ( ) ; data . setTestcases ( new Testcases ( ) ) ; final Testcases tc = data . getTestcases ( ) ; tc . setClazz ( classname ) ; storeData ( ) ; } | Initializes XML - Data . | 64 | 6 |
9,115 | public static void parseFieldsMap ( final Reader inputReader , final Map < String , String > defaultsMap , final Map < String , Optional < JsonPointer > > pathsMap ) throws IOException , CSVStreamException { CSVStream . parse ( inputReader , h -> { // TODO: Validate the headers as expected } , ( h , l ) -> { defaultsMap . put ( l . get ( h . indexOf ( FIELD ) ) , l . get ( h . indexOf ( DEFAULT ) ) ) ; String relativePath = l . get ( h . indexOf ( RELATIVE_PATH ) ) . trim ( ) ; pathsMap . put ( l . get ( h . indexOf ( FIELD ) ) , relativePath . isEmpty ( ) ? Optional . empty ( ) : Optional . of ( JsonPointer . compile ( relativePath ) ) ) ; return l ; } , l -> { } , null , CSVStream . DEFAULT_HEADER_COUNT ) ; } | Parse field definitions from the input reader into the defaults map and the paths map . | 211 | 17 |
9,116 | public static TriFunction < JsonNode , List < String > , List < String > , List < String > > getSummaryFunctionWithStartTime ( final JDefaultDict < String , AtomicInteger > emptyCounts , final JDefaultDict < String , AtomicInteger > nonEmptyCounts , final JDefaultDict < String , AtomicBoolean > possibleIntegerFields , final JDefaultDict < String , AtomicBoolean > possibleDoubleFields , final JDefaultDict < String , JDefaultDict < String , AtomicInteger > > valueCounts , final AtomicInteger rowCount , final long startTime ) { return ( node , header , line ) -> { int nextLineNumber = rowCount . incrementAndGet ( ) ; if ( nextLineNumber % 10000 == 0 ) { double secondsSinceStart = ( System . currentTimeMillis ( ) - startTime ) / 1000.0d ; System . out . printf ( "%d\tSeconds since start: %f\tRecords per second: %f%n" , nextLineNumber , secondsSinceStart , nextLineNumber / secondsSinceStart ) ; } for ( int i = 0 ; i < header . size ( ) ; i ++ ) { if ( line . get ( i ) . trim ( ) . isEmpty ( ) ) { emptyCounts . get ( header . get ( i ) ) . incrementAndGet ( ) ; } else { nonEmptyCounts . get ( header . get ( i ) ) . incrementAndGet ( ) ; valueCounts . get ( header . get ( i ) ) . get ( line . get ( i ) ) . incrementAndGet ( ) ; try { Integer . parseInt ( line . get ( i ) ) ; } catch ( NumberFormatException nfe ) { possibleIntegerFields . get ( header . get ( i ) ) . set ( false ) ; } try { Double . parseDouble ( line . get ( i ) ) ; } catch ( NumberFormatException nfe ) { possibleDoubleFields . get ( header . get ( i ) ) . set ( false ) ; } } } return line ; } ; } | Returns a function that can be used as a summary function using the given start time for timing analysis . | 450 | 20 |
9,117 | @ Override public Map < String , Object > toMap ( ) { Map < String , Object > map = new HashMap <> ( ) ; map . put ( "chatDienst" , getChatDienst ( ) ) ; map . put ( "dienstName" , getDienstName ( ) ) ; map . put ( "account" , getAccount ( ) ) ; return map ; } | Liefert die einzelnen Attribute eines ChatAccounts als Map . | 89 | 19 |
9,118 | public AnalysisResults < SolutionType > merge ( AnalysisResults < SolutionType > otherResults ) { otherResults . results . keySet ( ) . forEach ( problemID -> { otherResults . results . get ( problemID ) . keySet ( ) . forEach ( searchID -> { List < SearchRunResults < SolutionType >> runs = otherResults . results . get ( problemID ) . get ( searchID ) ; runs . forEach ( run -> { // deep copy run SearchRunResults < SolutionType > runCopy = new SearchRunResults <> ( run ) ; // register in this results object registerSearchRun ( problemID , searchID , runCopy ) ; } ) ; } ) ; } ) ; return this ; } | Merge the given results into this results object . A copy of the newly added search runs is made . | 152 | 21 |
9,119 | public void registerSearchRun ( String problemID , String searchID , SearchRunResults < SolutionType > run ) { if ( ! results . containsKey ( problemID ) ) { results . put ( problemID , new HashMap <> ( ) ) ; } if ( ! results . get ( problemID ) . containsKey ( searchID ) ) { results . get ( problemID ) . put ( searchID , new ArrayList <> ( ) ) ; } results . get ( problemID ) . get ( searchID ) . add ( run ) ; } | Register results of a search run specifying the IDs of the problem being solved and the applied search . If no runs have been registered before for this combination of problem and search new entries are created . Else this run is appended to the existing runs . | 116 | 49 |
9,120 | public int getNumSearches ( String problemID ) { if ( ! results . containsKey ( problemID ) ) { throw new UnknownIDException ( "Unknown problem ID " + problemID + "." ) ; } return results . get ( problemID ) . size ( ) ; } | Get the number of different searches that have been applied to solve the problem with the given ID . | 60 | 19 |
9,121 | public int getNumRuns ( String problemID , String searchID ) { if ( ! results . containsKey ( problemID ) ) { throw new UnknownIDException ( "Unknown problem ID " + problemID + "." ) ; } if ( ! results . get ( problemID ) . containsKey ( searchID ) ) { throw new UnknownIDException ( "Unknown search ID " + searchID + " for problem " + problemID + "." ) ; } return results . get ( problemID ) . get ( searchID ) . size ( ) ; } | Get the number of performed runs of the given search when solving the given problem . | 116 | 16 |
9,122 | public SearchRunResults < SolutionType > getRun ( String problemID , String searchID , int i ) { if ( ! results . containsKey ( problemID ) ) { throw new UnknownIDException ( "Unknown problem ID " + problemID + "." ) ; } if ( ! results . get ( problemID ) . containsKey ( searchID ) ) { throw new UnknownIDException ( "Unknown search ID " + searchID + " for problem " + problemID + "." ) ; } return results . get ( problemID ) . get ( searchID ) . get ( i ) ; } | Get the results of the i - th performed run of the given search when solving the given problem . | 124 | 20 |
9,123 | @ Override public void addToContainer ( Element container , Element element ) throws DocumentException , VectorPrintException { if ( container instanceof TextElementArray ) { if ( element instanceof Image ) { ( ( TextElementArray ) container ) . add ( new Chunk ( ( Image ) element , 0 , 0 , true ) ) ; } else { ( ( TextElementArray ) container ) . add ( element ) ; } } else if ( container instanceof PdfPTable ) { if ( element instanceof PdfPCell ) { ( ( PdfPTable ) container ) . addCell ( ( PdfPCell ) element ) ; } else if ( element instanceof Phrase ) { ( ( PdfPTable ) container ) . addCell ( ( Phrase ) element ) ; } else if ( element instanceof PdfPTable ) { ( ( PdfPTable ) container ) . addCell ( ( PdfPTable ) element ) ; } else if ( element instanceof Image ) { ( ( PdfPTable ) container ) . addCell ( ( Image ) element ) ; } else { throw new VectorPrintException ( String . format ( "don't know how to add %s to %s" , ( element == null ) ? "null" : element . getClass ( ) . getName ( ) , ( container == null ) ? "null" : container . getClass ( ) . getName ( ) ) ) ; } } else if ( container instanceof PdfPCell ) { if ( element instanceof PdfPTable ) { throw new VectorPrintException ( String . format ( "use %s.%s if you want to nest tables" , CONTAINER_ELEMENT . class . getName ( ) , CONTAINER_ELEMENT . NESTED_TABLE ) ) ; } ( ( PdfPCell ) container ) . addElement ( element ) ; } else if ( container instanceof ColumnText ) { ( ( ColumnText ) container ) . addElement ( element ) ; } else { throw new VectorPrintException ( String . format ( "don't know how to add %s to %s" , ( element == null ) ? "null" : element . getClass ( ) . getName ( ) , ( container == null ) ? "null" : container . getClass ( ) . getName ( ) ) ) ; } } | attempts to add an element to a container | 499 | 10 |
9,124 | public static BooleanSupplier spy ( BooleanSupplier proposition , Box < Boolean > result ) { return new CapturingProposition ( proposition , result ) ; } | Proxies a proposition spying for result . | 32 | 9 |
9,125 | public static < R > Supplier < R > spy ( Supplier < R > supplier , Box < R > result ) { return new CapturingSupplier < R > ( supplier , result ) ; } | Proxies a supplier spying for result . | 42 | 9 |
9,126 | public static < T , R > Function < T , R > spy ( Function < T , R > function , Box < R > result , Box < T > param ) { return new CapturingFunction <> ( function , result , param ) ; } | Proxies a function spying for result and parameter . | 52 | 11 |
9,127 | public static < T1 , T2 , R > BiFunction < T1 , T2 , R > spy ( BiFunction < T1 , T2 , R > function , Box < R > result , Box < T1 > param1 , Box < T2 > param2 ) { return new BinaryCapturingFunction <> ( function , result , param1 , param2 ) ; } | Proxies a binary function spying for result and parameters . | 81 | 12 |
9,128 | public static < T1 , T2 , T3 , R > TriFunction < T1 , T2 , T3 , R > spy ( TriFunction < T1 , T2 , T3 , R > function , Box < R > result , Box < T1 > param1 , Box < T2 > param2 , Box < T3 > param3 ) { return new TernaryCapturingFunction < T1 , T2 , T3 , R > ( function , result , param1 , param2 , param3 ) ; } | Proxies a ternary function spying for result and parameters . | 113 | 14 |
9,129 | public static < T > Predicate < T > spy ( Predicate < T > predicate , Box < Boolean > result , Box < T > param ) { return new CapturingPredicate < T > ( predicate , result , param ) ; } | Proxies a predicate spying for result and parameter . | 50 | 11 |
9,130 | public static < T1 , T2 > BiPredicate < T1 , T2 > spy ( BiPredicate < T1 , T2 > predicate , Box < Boolean > result , Box < T1 > param1 , Box < T2 > param2 ) { return new BinaryCapturingPredicate < T1 , T2 > ( predicate , result , param1 , param2 ) ; } | Proxies a binary predicate spying for result and parameters . | 83 | 12 |
9,131 | public static < T1 , T2 , T3 > TriPredicate < T1 , T2 , T3 > spy ( TriPredicate < T1 , T2 , T3 > predicate , Box < Boolean > result , Box < T1 > param1 , Box < T2 > param2 , Box < T3 > param3 ) { return new TernaryCapturingPredicate < T1 , T2 , T3 > ( predicate , result , param1 , param2 , param3 ) ; } | Proxies a ternary predicate spying for result and parameters . | 108 | 14 |
9,132 | public static < T > Consumer < T > spy ( Consumer < T > consumer , Box < T > param ) { return new CapturingConsumer < T > ( consumer , param ) ; } | Proxies an consumer spying for parameter . | 39 | 9 |
9,133 | public static < T1 , T2 > BiConsumer < T1 , T2 > spy ( BiConsumer < T1 , T2 > consumer , Box < T1 > param1 , Box < T2 > param2 ) { return new BinaryCapturingConsumer < T1 , T2 > ( consumer , param1 , param2 ) ; } | Proxies a binary consumer spying for parameters . | 72 | 10 |
9,134 | public static < T1 , T2 , T3 > TriConsumer < T1 , T2 , T3 > spy ( TriConsumer < T1 , T2 , T3 > consumer , Box < T1 > param1 , Box < T2 > param2 , Box < T3 > param3 ) { return new TernaryCapturingConsumer < T1 , T2 , T3 > ( consumer , param1 , param2 , param3 ) ; } | Proxies a ternary consumer spying for parameters . | 97 | 12 |
9,135 | public static < T1 , T2 , T3 , R > TriFunction < T1 , T2 , T3 , R > spyRes ( TriFunction < T1 , T2 , T3 , R > function , Box < R > result ) { return spy ( function , result , Box . < T1 > empty ( ) , Box . < T2 > empty ( ) , Box . < T3 > empty ( ) ) ; } | Proxies a ternary function spying for result . | 93 | 12 |
9,136 | public static < T1 , T2 , T3 , R > TriFunction < T1 , T2 , T3 , R > spy1st ( TriFunction < T1 , T2 , T3 , R > function , Box < T1 > param1 ) { return spy ( function , Box . < R > empty ( ) , param1 , Box . < T2 > empty ( ) , Box . < T3 > empty ( ) ) ; } | Proxies a ternary function spying for first parameter . | 96 | 13 |
9,137 | public static < T1 , T2 , T3 , R > TriFunction < T1 , T2 , T3 , R > spy2nd ( TriFunction < T1 , T2 , T3 , R > function , Box < T2 > param2 ) { return spy ( function , Box . < R > empty ( ) , Box . < T1 > empty ( ) , param2 , Box . < T3 > empty ( ) ) ; } | Proxies a ternary function spying for second parameter | 96 | 12 |
9,138 | public static < T1 , T2 , T3 , R > TriFunction < T1 , T2 , T3 , R > spy3rd ( TriFunction < T1 , T2 , T3 , R > function , Box < T3 > param3 ) { return spy ( function , Box . < R > empty ( ) , Box . < T1 > empty ( ) , Box . < T2 > empty ( ) , param3 ) ; } | Proxies a ternary function spying for third parameter . | 96 | 13 |
9,139 | public static < T1 , T2 , R > BiFunction < T1 , T2 , R > spyRes ( BiFunction < T1 , T2 , R > function , Box < R > result ) { return spy ( function , result , Box . < T1 > empty ( ) , Box . < T2 > empty ( ) ) ; } | Proxies a binary function spying for result . | 74 | 10 |
9,140 | public static < T1 , T2 , R > BiFunction < T1 , T2 , R > spy1st ( BiFunction < T1 , T2 , R > function , Box < T1 > param1 ) { return spy ( function , Box . < R > empty ( ) , param1 , Box . < T2 > empty ( ) ) ; } | Proxies a binary function spying for first parameter . | 77 | 11 |
9,141 | public static < T1 , T2 , R > BiFunction < T1 , T2 , R > spy2nd ( BiFunction < T1 , T2 , R > function , Box < T2 > param2 ) { return spy ( function , Box . < R > empty ( ) , Box . < T1 > empty ( ) , param2 ) ; } | Proxies a binary function spying for second parameter . | 77 | 11 |
9,142 | public static < R , T > Function < T , R > spyRes ( Function < T , R > function , Box < R > result ) { return spy ( function , result , Box . < T > empty ( ) ) ; } | Proxies a function spying for result . | 49 | 9 |
9,143 | public static < R , T > Function < T , R > spy1st ( Function < T , R > function , Box < T > param ) { return spy ( function , Box . < R > empty ( ) , param ) ; } | Proxies a function spying for parameter . | 50 | 9 |
9,144 | public static < T1 , T2 , T3 > TriConsumer < T1 , T2 , T3 > spy1st ( TriConsumer < T1 , T2 , T3 > consumer , Box < T1 > param1 ) { return spy ( consumer , param1 , Box . < T2 > empty ( ) , Box . < T3 > empty ( ) ) ; } | Proxies a ternary consumer spying for first parameter . | 81 | 13 |
9,145 | public static < T1 , T2 , T3 > TriConsumer < T1 , T2 , T3 > spy2nd ( TriConsumer < T1 , T2 , T3 > consumer , Box < T2 > param2 ) { return spy ( consumer , Box . < T1 > empty ( ) , param2 , Box . < T3 > empty ( ) ) ; } | Proxies a ternary consumer spying for second parameter . | 81 | 13 |
9,146 | public static < T1 , T2 , T3 > TriConsumer < T1 , T2 , T3 > spy3rd ( TriConsumer < T1 , T2 , T3 > consumer , Box < T3 > param3 ) { return spy ( consumer , Box . < T1 > empty ( ) , Box . < T2 > empty ( ) , param3 ) ; } | Proxies a ternary consumer spying for third parameter . | 81 | 13 |
9,147 | public static < T1 , T2 > BiConsumer < T1 , T2 > spy2nd ( BiConsumer < T1 , T2 > consumer , Box < T2 > param2 ) { return spy ( consumer , Box . < T1 > empty ( ) , param2 ) ; } | Proxies a binary consumer spying for second parameter . | 62 | 11 |
9,148 | public static < T1 , T2 , T3 > TriPredicate < T1 , T2 , T3 > spyRes ( TriPredicate < T1 , T2 , T3 > predicate , Box < Boolean > result ) { return spy ( predicate , result , Box . < T1 > empty ( ) , Box . < T2 > empty ( ) , Box . < T3 > empty ( ) ) ; } | Proxies a ternary predicate spying for result . | 89 | 12 |
9,149 | public static < T1 , T2 , T3 > TriPredicate < T1 , T2 , T3 > spy1st ( TriPredicate < T1 , T2 , T3 > predicate , Box < T1 > param1 ) { return spy ( predicate , Box . < Boolean > empty ( ) , param1 , Box . < T2 > empty ( ) , Box . < T3 > empty ( ) ) ; } | Proxies a ternary predicate spying for first parameter . | 92 | 13 |
9,150 | public static < T1 , T2 , T3 > TriPredicate < T1 , T2 , T3 > spy2nd ( TriPredicate < T1 , T2 , T3 > predicate , Box < T2 > param2 ) { return spy ( predicate , Box . < Boolean > empty ( ) , Box . < T1 > empty ( ) , param2 , Box . < T3 > empty ( ) ) ; } | Proxies a ternary predicate spying for second parameter . | 92 | 13 |
9,151 | public static < T1 , T2 , T3 > TriPredicate < T1 , T2 , T3 > spy3rd ( TriPredicate < T1 , T2 , T3 > predicate , Box < T3 > param3 ) { return spy ( predicate , Box . < Boolean > empty ( ) , Box . < T1 > empty ( ) , Box . < T2 > empty ( ) , param3 ) ; } | Proxies a ternary predicate spying for third parameter . | 92 | 13 |
9,152 | public static < T1 , T2 > BiPredicate < T1 , T2 > spyRes ( BiPredicate < T1 , T2 > predicate , Box < Boolean > result ) { return spy ( predicate , result , Box . < T1 > empty ( ) , Box . < T2 > empty ( ) ) ; } | Proxies a binary predicate spying for result . | 70 | 10 |
9,153 | public static < T1 , T2 > BiPredicate < T1 , T2 > spy1st ( BiPredicate < T1 , T2 > predicate , Box < T1 > param1 ) { return spy ( predicate , Box . < Boolean > empty ( ) , param1 , Box . < T2 > empty ( ) ) ; } | Proxies a binary predicate spying for first parameter | 73 | 10 |
9,154 | public static < T1 , T2 > BiPredicate < T1 , T2 > spy2nd ( BiPredicate < T1 , T2 > predicate , Box < T2 > param2 ) { return spy ( predicate , Box . < Boolean > empty ( ) , Box . < T1 > empty ( ) , param2 ) ; } | Proxies a binary predicate spying for second parameter . | 73 | 11 |
9,155 | public static < T > Predicate < T > spyRes ( Predicate < T > predicate , Box < Boolean > result ) { return spy ( predicate , result , Box . < T > empty ( ) ) ; } | Proxies a predicate spying for result . | 45 | 9 |
9,156 | public static < T > Predicate < T > spy1st ( Predicate < T > predicate , Box < T > param ) { return spy ( predicate , Box . < Boolean > empty ( ) , param ) ; } | Proxies a predicate spying for parameter . | 46 | 9 |
9,157 | public static < T > Consumer < T > monitor ( Consumer < T > consumer , AtomicLong calls ) { return new MonitoringConsumer < T > ( consumer , calls ) ; } | Monitors calls to an consumer . | 36 | 7 |
9,158 | public static < T , R > Function < T , R > monitor ( Function < T , R > function , AtomicLong calls ) { return new MonitoringFunction <> ( function , calls ) ; } | Monitors calls to a function . | 41 | 7 |
9,159 | public static < T > Predicate < T > monitor ( Predicate < T > predicate , AtomicLong calls ) { return new MonitoringPredicate < T > ( predicate , calls ) ; } | Monitors calls to a predicate . | 39 | 7 |
9,160 | public static < R > Supplier < R > monitor ( Supplier < R > supplier , AtomicLong calls ) { return new MonitoringSupplier <> ( supplier , calls ) ; } | Monitors calls to a supplier . | 38 | 7 |
9,161 | public static < T1 , T2 > BiConsumer < T1 , T2 > monitor ( BiConsumer < T1 , T2 > consumer , AtomicLong calls ) { return new BinaryMonitoringConsumer < T1 , T2 > ( consumer , calls ) ; } | Monitors calls to a binary consumer . | 56 | 8 |
9,162 | public static < T1 , T2 , R > BiFunction < T1 , T2 , R > monitor ( BiFunction < T1 , T2 , R > function , AtomicLong calls ) { return new BinaryMonitoringFunction <> ( function , calls ) ; } | Monitors calls to a binary function . | 57 | 8 |
9,163 | public static < T1 , T2 > BiPredicate < T1 , T2 > monitor ( BiPredicate < T1 , T2 > predicate , AtomicLong calls ) { return new BinaryMonitoringPredicate < T1 , T2 > ( predicate , calls ) ; } | Monitors calls to a binary predicate | 59 | 7 |
9,164 | public static < T1 , T2 , T3 > TriConsumer < T1 , T2 , T3 > monitor ( TriConsumer < T1 , T2 , T3 > consumer , AtomicLong calls ) { return new TernaryMonitoringConsumer < T1 , T2 , T3 > ( consumer , calls ) ; } | Monitors calls to a ternary consumer . | 70 | 10 |
9,165 | public static < T1 , T2 , T3 , R > TriFunction < T1 , T2 , T3 , R > monitor ( TriFunction < T1 , T2 , T3 , R > function , AtomicLong calls ) { return new TernaryMonitoringFunction < T1 , T2 , T3 , R > ( function , calls ) ; } | Monitors calls to a ternary function . | 78 | 10 |
9,166 | public static < T1 , T2 , T3 > TriPredicate < T1 , T2 , T3 > monitor ( TriPredicate < T1 , T2 , T3 > predicate , AtomicLong calls ) { return new TernaryMonitoringPredicate < T1 , T2 , T3 > ( predicate , calls ) ; } | Monitors calls to a ternary predicate . | 73 | 10 |
9,167 | protected final void addDataCollector ( final Class collectorName ) { if ( ! DataCollector . class . isAssignableFrom ( collectorName ) ) { throw new RuntimeException ( "Class must be subclass of DataCollector!" ) ; } collectors . add ( collectorName ) ; } | Adds a DataCollector to the given list . | 61 | 10 |
9,168 | public final Map < String , DataCollector > getDataCollectors ( ) { final Map < String , DataCollector > collectorsRet = new HashMap <> ( ) ; for ( final Class < DataCollector > c : collectors ) { DataCollector dc ; try { dc = c . newInstance ( ) ; collectorsRet . put ( dc . getName ( ) , dc ) ; } catch ( final InstantiationException e ) { e . printStackTrace ( ) ; } catch ( final IllegalAccessException e ) { e . printStackTrace ( ) ; } } return collectorsRet ; } | Returns new DataCollectors which are saved in the current DataCollectorList . Every time this method is called there are new DataCollectors instanciated . | 127 | 33 |
9,169 | @ Override public void accept ( E value ) { for ( Consumer < E > consumer : consumers ) { consumer . accept ( value ) ; } } | performs every composed consumer | 31 | 5 |
9,170 | public Promise < String > getGreeting ( ) { Promise < String > p = q . all ( getSalutation ( ) , getName ( ) ) . then ( new Continue < String , JSArray < ? > > ( ) { // Formats the greeting when salutation and name are delivered. @ Override public String call ( JSArray < ? > value ) { return value . get ( 0 ) + ", " + value . get ( 1 ) + "!" ; } } ) ; return p ; } | Given the promises of name and salutation returns a promise of greeting . | 107 | 14 |
9,171 | public Promise < String > getSalutation ( ) { final Deferred < String > d = q . defer ( ) ; Timer timer = new Timer ( ) { @ Override public void run ( ) { d . progress ( new TimerProgress ( "Loaded salutation" , this ) ) ; d . resolve ( "Hello" ) ; } } ; d . progress ( new TimerProgress ( "Loading salutation..." , timer ) ) ; timer . schedule ( 1000 ) ; return d . promise ( ) ; } | Returns a promise of salutation by simulating an asynchronous call with a time - out . | 110 | 18 |
9,172 | public Range < T > rightHalfOpen ( T lower , Optional < T > upper ) { return new DenseRange < T > ( sequencer , comparator , Endpoint . Include , lower , upper , Endpoint . Exclude ) ; } | returns [ lower upper ) | 51 | 6 |
9,173 | public Range < T > leftHalfOpen ( T lower , T upper ) { return new DenseRange < T > ( sequencer , comparator , Endpoint . Exclude , lower , Optional . of ( upper ) , Endpoint . Include ) ; } | returns ( lower upper ] | 53 | 6 |
9,174 | public static Boolean [ ] box ( boolean [ ] array ) { dbc . precondition ( array != null , "cannot box a null boolean array" ) ; final Boolean [ ] result = new Boolean [ array . length ] ; for ( int i = 0 ; i != result . length ; ++ i ) { result [ i ] = array [ i ] ; } return result ; } | Converts an array of booleans to an array of Booleans . | 81 | 15 |
9,175 | public static float round ( float f , int decimalPlace ) { return BigDecimal . valueOf ( ( double ) f ) . setScale ( decimalPlace , BigDecimal . ROUND_HALF_UP ) . floatValue ( ) ; } | Round to certain number of decimals | 53 | 8 |
9,176 | public static < E extends BaseStyler > List < E > getStylers ( Collection < ? extends BaseStyler > stylers , Class < E > clazz ) throws VectorPrintException { List < E > st = new ArrayList <> ( 1 ) ; for ( BaseStyler s : stylers ) { if ( clazz . isAssignableFrom ( s . getClass ( ) ) ) { st . add ( ( E ) s ) ; } } return st ; } | get stylers with a certain baseclass from a collection of stylers . | 102 | 15 |
9,177 | public static void delayedStyle ( Chunk c , String tag , Collection < ? extends Advanced > stylers , EventHelper eventHelper , Image img ) { // add to pagehelper and set generic tag eventHelper . addDelayedStyler ( tag , stylers , c , img ) ; c . setGenericTag ( tag ) ; } | register advanced stylers with the EventHelper to do the styling later | 70 | 13 |
9,178 | public Domainname getLevelDomain ( int level ) { String [ ] parts = this . getCode ( ) . split ( "\\." ) ; int firstPart = parts . length - level ; if ( ( firstPart < 0 ) || ( level < 1 ) ) { throw new LocalizedIllegalArgumentException ( level , "level" , Range . between ( 1 , parts . length ) ) ; } StringBuilder name = new StringBuilder ( parts [ firstPart ] ) ; for ( int i = firstPart + 1 ; i < parts . length ; i ++ ) { name . append ( ' ' ) ; name . append ( parts [ i ] ) ; } return new Domainname ( name . toString ( ) ) ; } | Waehrend die Top - Level - Domain die oberste Ebende wie de ist ist die 2nd - Level - Domain von www . jfachwert . de die Domain jfachwert . de und die 3rd - Level - Domain ist in diesem Beispiel die komplette Domain . | 153 | 72 |
9,179 | @ Override public List < Move < ? super SolutionType > > getAllMoves ( SolutionType solution ) { return neighs . stream ( ) . flatMap ( neigh -> neigh . getAllMoves ( solution ) . stream ( ) ) // flatten to one stream of all moves . collect ( Collectors . toList ( ) ) ; // collect in one list } | Creates and returns the union of all moves generated by each of the contained neighbourhoods . The returned list may be empty if none of the contained neighbourhoods can generate any move . | 78 | 34 |
9,180 | public AbstractNumber multiply ( Bruch operand ) { BigInteger z = getZaehler ( ) . multiply ( operand . getZaehler ( ) ) ; BigInteger n = getNenner ( ) . multiply ( operand . getNenner ( ) ) ; return Bruch . of ( z , n ) . kuerzen ( ) ; } | Multiplikation zweier Brueche . | 77 | 11 |
9,181 | public AbstractNumber add ( Bruch operand ) { BigInteger n = getNenner ( ) . multiply ( operand . getNenner ( ) ) ; BigInteger z1 = getZaehler ( ) . multiply ( operand . getNenner ( ) ) ; BigInteger z2 = operand . getZaehler ( ) . multiply ( getNenner ( ) ) ; return Bruch . of ( z1 . add ( z2 ) , n ) . kuerzen ( ) ; } | Addition zweier Brueche . | 110 | 9 |
9,182 | @ Override public int compareTo ( Bruch other ) { BigInteger thisZaehlerErweitert = this . zaehler . multiply ( other . nenner ) ; BigInteger otherZaehlerErweitert = other . zaehler . multiply ( this . nenner ) ; return thisZaehlerErweitert . compareTo ( otherZaehlerErweitert ) ; } | Vergleicht den anderen Bruch mit dem aktuellen Bruch . | 89 | 19 |
9,183 | protected final PdfContentByte getPreparedCanvas ( float opacity ) { needRestore = false ; PdfContentByte canvas = ( tableForeground != null ) ? tableForeground : ( isBg ( ) ) ? getWriter ( ) . getDirectContentUnder ( ) : getWriter ( ) . getDirectContent ( ) ; String layerName = getLayerName ( ) ; BLENDMODE blend = getBlend ( ) ; if ( getWriter ( ) . getPDFXConformance ( ) == PdfWriter . PDFX1A2001 ) { // check blend, opacity, layers if ( ! PdfGState . BM_NORMAL . equals ( blend . getBlend ( ) ) && ! PdfGState . BM_COMPATIBLE . equals ( blend . getBlend ( ) ) ) { throw new VectorPrintRuntimeException ( "blend not supported in PDF/X-1a: " + blend ) ; } if ( layerName != null ) { throw new VectorPrintRuntimeException ( "layers not supported in PDF/X-1a: " + layerName ) ; } if ( opacity < 1 ) { throw new VectorPrintRuntimeException ( "opacity not supported in PDF/X-1a: " + opacity ) ; } } if ( layerName != null ) { layerManager . startLayerInGroup ( layerName , canvas ) ; } // pgs.setAlphaIsShape(true); if ( opacity <= 1 ) { // PdfShading shading = PdfShading.simpleAxial(getWriter(), 0, 0, getDocument().right() - getDocument().getPageSize().getWidth() * 0.6f, getDocument().top() - getDocument().getPageSize().getHeight() * 0.6f, Color.green, Color.orange,true,true); // canvas.paintShading(shading); canvas . saveState ( ) ; needRestore = true ; PdfGState pgs = new PdfGState ( ) ; pgs . setFillOpacity ( opacity ) ; pgs . setStrokeOpacity ( opacity ) ; canvas . setGState ( pgs ) ; } if ( ! BLENDMODE . NORMAL . equals ( blend ) ) { if ( ! needRestore ) { canvas . saveState ( ) ; needRestore = true ; } PdfGState pgs = new PdfGState ( ) ; pgs . setBlendMode ( blend . getBlend ( ) ) ; canvas . setGState ( pgs ) ; } if ( getTransform ( ) != null && ! ( this instanceof Image ) ) { canvas . transform ( new AffineTransform ( getTransform ( ) ) ) ; } return canvas ; } | get a canvas for drawing prepared according to settings | 583 | 9 |
9,184 | public static < E , R > R reduce ( E [ ] array , BiFunction < R , E , R > function , R init ) { return new Reductor <> ( function , init ) . apply ( new ArrayIterator < E > ( array ) ) ; } | Reduces an array of elements using the passed function . | 56 | 11 |
9,185 | public static < E > boolean every ( Iterable < E > iterable , Predicate < E > predicate ) { dbc . precondition ( iterable != null , "cannot call every with a null iterable" ) ; return new Every < E > ( predicate ) . test ( iterable . iterator ( ) ) ; } | Yields true if EVERY predicate application on the given iterable yields true . | 70 | 16 |
9,186 | public static < E > boolean every ( Iterator < E > iterator , Predicate < E > predicate ) { return new Every < E > ( predicate ) . test ( iterator ) ; } | Yields true if EVERY predicate application on the given iterator yields true . | 39 | 15 |
9,187 | public static < E > boolean every ( E [ ] array , Predicate < E > predicate ) { return new Every < E > ( predicate ) . test ( new ArrayIterator < E > ( array ) ) ; } | Yields true if EVERY predicate application on the given array yields true . | 45 | 15 |
9,188 | public static < E > int counti ( Iterator < E > iterator ) { final long value = reduce ( iterator , new Count < E > ( ) , 0l ) ; dbc . state ( value <= Integer . MAX_VALUE , "iterator size overflows an integer" ) ; return ( int ) value ; } | Counts elements contained in the iterator . | 67 | 8 |
9,189 | public void updateBestSolution ( long time , double value , SolutionType newBestSolution ) { times . add ( time ) ; values . add ( value ) ; bestSolution = newBestSolution ; } | Update the best found solution . The update time and newly obtained value are added to the list of updates and the final best solution is overwritten . | 41 | 29 |
9,190 | public static < T , U , R > Function < Pair < T , U > , R > tupled ( BiFunction < T , U , R > function ) { dbc . precondition ( function != null , "cannot apply a pair to a null function" ) ; return pair -> function . apply ( pair . first ( ) , pair . second ( ) ) ; } | Adapts a binary function to a function accepting a pair . | 80 | 12 |
9,191 | public static < T , U > Predicate < Pair < T , U > > tupled ( BiPredicate < T , U > predicate ) { dbc . precondition ( predicate != null , "cannot apply a pair to a null predicate" ) ; return pair -> predicate . test ( pair . first ( ) , pair . second ( ) ) ; } | Adapts a binary predicate to a predicate accepting a pair . | 76 | 12 |
9,192 | public static < T , U > Consumer < Pair < T , U > > tupled ( BiConsumer < T , U > consumer ) { dbc . precondition ( consumer != null , "cannot apply a pair to a null consumer" ) ; return pair -> consumer . accept ( pair . first ( ) , pair . second ( ) ) ; } | Adapts a binary consumer to an consumer accepting a pair . | 74 | 12 |
9,193 | public static < T , U , V , R > Function < Triple < T , U , V > , R > tupled ( TriFunction < T , U , V , R > function ) { dbc . precondition ( function != null , "cannot apply a triple to a null function" ) ; return triple -> function . apply ( triple . first ( ) , triple . second ( ) , triple . third ( ) ) ; } | Adapts a ternary function to a function accepting a triple . | 92 | 14 |
9,194 | public static < T , U , V > Predicate < Triple < T , U , V > > tupled ( TriPredicate < T , U , V > predicate ) { dbc . precondition ( predicate != null , "cannot apply a triple to a null predicate" ) ; return triple -> predicate . test ( triple . first ( ) , triple . second ( ) , triple . third ( ) ) ; } | Adapts a ternary predicate to a predicate accepting a triple . | 88 | 14 |
9,195 | public static < T , U , V > Consumer < Triple < T , U , V > > tupled ( TriConsumer < T , U , V > consumer ) { dbc . precondition ( consumer != null , "cannot apply a triple to a null consumer" ) ; return triple -> consumer . accept ( triple . first ( ) , triple . second ( ) , triple . third ( ) ) ; } | Adapts a ternary consumer to an consumer accepting a triple . | 86 | 14 |
9,196 | public ConnectorDescriptor removeAllNamespaces ( ) { List < String > nameSpaceKeys = new ArrayList < String > ( ) ; java . util . Map < String , String > attributes = model . getAttributes ( ) ; for ( Entry < String , String > e : attributes . entrySet ( ) ) { final String name = e . getKey ( ) ; final String value = e . getValue ( ) ; if ( value != null && value . startsWith ( "http://" ) ) { nameSpaceKeys . add ( name ) ; } } for ( String name : nameSpaceKeys ) { model . removeAttribute ( name ) ; } return this ; } | Removes all existing namespaces . | 141 | 7 |
9,197 | private void around ( final CtMethod m , final String before , final String after , final List < VarDeclarationData > declarations ) throws CannotCompileException , NotFoundException { String signature = Modifier . toString ( m . getModifiers ( ) ) + " " + m . getReturnType ( ) . getName ( ) + " " + m . getLongName ( ) ; LOG . info ( "--- Instrumenting " + signature ) ; for ( VarDeclarationData declaration : declarations ) { m . addLocalVariable ( declaration . getName ( ) , pool . get ( declaration . getType ( ) ) ) ; } m . insertBefore ( before ) ; m . insertAfter ( after ) ; } | Method introducing code before and after a given javassist method . | 150 | 14 |
9,198 | public static < T > Iterable < T > oneTime ( Iterator < T > iterator ) { return new OneTimeIterable < T > ( iterator ) ; } | Creates an iterable usable only ONE TIME from an iterator . | 35 | 13 |
9,199 | public static < T > Iterator < T > iterator ( T first , T second ) { return ArrayIterator . of ( first , second ) ; } | Creates an iterator from the passed values . | 31 | 9 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.