idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
9,000
public static < T > Pair < Integer , List < T > > page ( long start , long howMany , Iterable < T > iterable ) { dbc . precondition ( iterable != null , "cannot call page with a null iterable" ) ; return Pagination . page ( start , howMany , iterable . iterator ( ) ) ; }
Creates a page view of an iterable .
9,001
public static < T , C extends Collection < T > > Pair < Integer , C > page ( long start , long howMany , Iterable < T > iterable , C collection ) { dbc . precondition ( iterable != null , "cannot call page with a null iterable" ) ; return Pagination . page ( start , howMany , iterable . iterator ( ) , collection ) ; }
Creates a page view of an iterable adding elements to the collection .
9,002
public static < T > Pair < Integer , List < T > > page ( long start , long howMany , T [ ] array ) { return Pagination . page ( start , howMany , new ArrayIterator < T > ( array ) ) ; }
Creates a page view of an array .
9,003
public static < T , C extends Collection < T > > Pair < Integer , C > page ( long start , long howMany , T [ ] array , C collection ) { return Pagination . page ( start , howMany , new ArrayIterator < T > ( array ) , collection ) ; }
Creates a page view of an array adding elements to the collection .
9,004
public static < T > Pair < Integer , List < T > > page ( long start , long howMany , Collection < T > collection ) { return Pair . of ( collection . size ( ) , Consumers . all ( Filtering . slice ( start , howMany , collection ) ) ) ; }
Creates a page view of a collection .
9,005
public static < T , C extends Collection < T > > Pair < Integer , C > page ( long start , long howMany , Collection < T > in , C out ) { return Pair . of ( in . size ( ) , Consumers . all ( Filtering . slice ( start , howMany , in ) , out ) ) ; }
Creates a page view of a collection adding elements to the out collection .
9,006
public static Primzahl after ( int zahl ) { List < Primzahl > primzahlen = getPrimzahlen ( ) ; for ( Primzahl p : primzahlen ) { if ( zahl < p . intValue ( ) ) { return p ; } } for ( int n = primzahlen . get ( primzahlen . size ( ) - 1 ) . intValue ( ) + 2 ; n <= zahl ; n += 2 ) { if ( ! hasTeiler ( n ) ) { primzahlen . add ( new Primzahl ( n ) ) ; } } int n = primzahlen . get ( primzahlen . size ( ) - 1 ) . intValue ( ) + 2 ; while ( hasTeiler ( n ) ) { n += 2 ; } Primzahl nextPrimzahl = new Primzahl ( n ) ; primzahlen . add ( nextPrimzahl ) ; return nextPrimzahl ; }
Liefert die naechste Primzahl nach der angegebenen Zahl .
9,007
public static void annotate ( String floatName , float floatValue ) { TracyThreadContext ctx = threadContext . get ( ) ; if ( isValidContext ( ctx ) ) { ctx . annotate ( floatName , floatValue ) ; } }
Annotate a float value
9,008
public static void annotate ( String doubleName , double doubleValue ) { TracyThreadContext ctx = threadContext . get ( ) ; if ( isValidContext ( ctx ) ) { ctx . annotate ( doubleName , doubleValue ) ; } }
Annotate a double value
9,009
public static void annotateRoot ( String ... keyValueSequence ) { TracyThreadContext ctx = threadContext . get ( ) ; if ( isValidContext ( ctx ) ) { ctx . annotateRoot ( keyValueSequence ) ; } }
Annotate String values at the root Tracy frame
9,010
public static void annotateRoot ( String intName , int intValue ) { TracyThreadContext ctx = threadContext . get ( ) ; if ( isValidContext ( ctx ) ) { ctx . annotateRoot ( intName , intValue ) ; } }
Annotate an integer value at the root Tracy frame
9,011
public static void annotateRoot ( String longName , long longValue ) { TracyThreadContext ctx = threadContext . get ( ) ; if ( isValidContext ( ctx ) ) { ctx . annotateRoot ( longName , longValue ) ; } }
Annotate a long value at the root Tracy frame
9,012
public static void annotateRoot ( String booleanName , boolean booleanValue ) { TracyThreadContext ctx = threadContext . get ( ) ; if ( isValidContext ( ctx ) ) { ctx . annotateRoot ( booleanName , booleanValue ) ; } }
Annotate a boolean value at the root Tracy frame
9,013
public static List < TracyEvent > getEvents ( ) { TracyThreadContext ctx = threadContext . get ( ) ; List < TracyEvent > events = EMPTY_TRACY_EVENT_LIST ; if ( isValidContext ( ctx ) ) { events = ctx . getPoppedList ( ) ; } return events ; }
Once all work has been done and TracyEvents are ready to be collected you can collect them using this method
9,014
public static List < String > getEventsAsJson ( ) { List < String > list = Tracy . EMPTY_STRING_LIST ; TracyThreadContext ctx = threadContext . get ( ) ; if ( isValidContext ( ctx ) ) { list = new ArrayList < String > ( 20 ) ; for ( TracyEvent event : ctx . getPoppedList ( ) ) { list . add ( event . toJsonString ( ) ) ; } } return list ; }
Gets List of Tracy events in JSON format
9,015
public static String getEventsAsJsonTracySegment ( ) { final int TRACY_SEGMENT_CHAR_SIZE = 2048 ; String jsonArrayString = null ; int frameCounter = 0 ; TracyThreadContext ctx = threadContext . get ( ) ; if ( isValidContext ( ctx ) && ctx . getPoppedList ( ) . size ( ) > 0 ) { StringBuilder sb = new StringBuilder ( TRACY_SEGMENT_CHAR_SIZE ) ; sb . append ( "{\"tracySegment\":[" ) ; for ( TracyEvent event : ctx . getPoppedList ( ) ) { if ( frameCounter > 0 ) { sb . append ( "," ) ; } sb . append ( event . toJsonString ( ) ) ; frameCounter ++ ; } sb . append ( "]}" ) ; jsonArrayString = sb . toString ( ) ; } return jsonArrayString ; }
Collects JSON Tracy Events array packaged as a value of tracySegment
9,016
public static void mergeWorkerContext ( TracyThreadContext workerTracyThreadContext ) { TracyThreadContext ctx = threadContext . get ( ) ; if ( isValidContext ( ctx ) ) { ctx . mergeChildContext ( workerTracyThreadContext ) ; } }
When called from the requester thread will merge worker TracyThreadContext into the requester TracyThreadContext
9,017
public static void frameErrorWithoutPopping ( String error ) { TracyThreadContext ctx = threadContext . get ( ) ; if ( isValidContext ( ctx ) ) { ctx . annotateFrameError ( error ) ; } }
In case where an error occurs but the user does not want to raise an exception and the user takes responsibility of ensuring Tracy . after is guaranteed to be called then frameErrorWithoutPoping can be called to simply create an error annotation
9,018
public static < E > List < E > search ( Iterator < E > iterator , Predicate < E > predicate ) { final Function < Iterator < E > , ArrayList < E > > consumer = new ConsumeIntoCollection < > ( new ArrayListFactory < E > ( ) ) ; final FilteringIterator < E > filtered = new FilteringIterator < E > ( iterator , predicate ) ; return consumer . apply ( filtered ) ; }
Searches the iterator consuming it yielding every value matching the predicate .
9,019
public static < C extends Collection < E > , E > C search ( Iterator < E > iterator , C collection , Predicate < E > predicate ) { final Function < Iterator < E > , C > consumer = new ConsumeIntoCollection < > ( new ConstantSupplier < C > ( collection ) ) ; final FilteringIterator < E > filtered = new FilteringIterator < E > ( iterator , predicate ) ; return consumer . apply ( filtered ) ; }
Searches the iterator consuming it adding every value matching the predicate to the passed collection .
9,020
public static < C extends Collection < E > , E > C search ( Iterable < E > iterable , C collection , Predicate < E > predicate ) { dbc . precondition ( iterable != null , "cannot search a null iterable" ) ; final Function < Iterator < E > , C > consumer = new ConsumeIntoCollection < > ( new ConstantSupplier < C > ( collection ) ) ; final FilteringIterator < E > filtered = new FilteringIterator < E > ( iterable . iterator ( ) , predicate ) ; return consumer . apply ( filtered ) ; }
Searches the iterable adding every value matching the predicate to the passed collection .
9,021
public static < C extends Collection < E > , E > C search ( E [ ] array , Supplier < C > supplier , Predicate < E > predicate ) { final Function < Iterator < E > , C > consumer = new ConsumeIntoCollection < > ( supplier ) ; final FilteringIterator < E > filtered = new FilteringIterator < E > ( new ArrayIterator < E > ( array ) , predicate ) ; return consumer . apply ( filtered ) ; }
Searches the array adding every value matching the predicate to the collection yielded by the passed supplier .
9,022
public static < E > List < E > find ( Iterator < E > iterator , Predicate < E > predicate ) { final Function < Iterator < E > , ArrayList < E > > consumer = new ConsumeIntoCollection < > ( new ArrayListFactory < E > ( ) ) ; final FilteringIterator < E > filtered = new FilteringIterator < E > ( iterator , predicate ) ; final ArrayList < E > found = consumer . apply ( filtered ) ; dbc . precondition ( ! found . isEmpty ( ) , "no element matched" ) ; return found ; }
Searches the iterator consuming it yielding every value matching the predicate . An IllegalStateException is thrown if no element matches .
9,023
public void measureBefore ( ) { if ( ! CTRLINST . isMonitoringEnabled ( ) ) { return ; } hostname = VMNAME ; sessionId = SESSIONREGISTRY . recallThreadLocalSessionId ( ) ; traceId = CFREGISTRY . recallThreadLocalTraceId ( ) ; if ( traceId == - 1 ) { entrypoint = true ; traceId = CFREGISTRY . getAndStoreUniqueThreadLocalTraceId ( ) ; CFREGISTRY . storeThreadLocalEOI ( 0 ) ; CFREGISTRY . storeThreadLocalESS ( 1 ) ; eoi = 0 ; ess = 0 ; } else { entrypoint = false ; eoi = CFREGISTRY . incrementAndRecallThreadLocalEOI ( ) ; ess = CFREGISTRY . recallAndIncrementThreadLocalESS ( ) ; if ( ( eoi == - 1 ) || ( ess == - 1 ) ) { LOG . error ( "eoi and/or ess have invalid values:" + " eoi == " + eoi + " ess == " + ess ) ; CTRLINST . terminateMonitoring ( ) ; } } tin = TIME . getTime ( ) ; }
Will be called to register the time when the method has started .
9,024
public void apply ( PermutationSolution solution ) { int start = from ; int stop = to ; int n = solution . size ( ) ; int reversedLength ; if ( start < stop ) { reversedLength = stop - start + 1 ; } else { reversedLength = n - ( start - stop - 1 ) ; } int numSwaps = reversedLength / 2 ; for ( int k = 0 ; k < numSwaps ; k ++ ) { solution . swap ( start , stop ) ; start = ( start + 1 ) % n ; stop = ( stop - 1 + n ) % n ; } }
Reverse the subsequence by performing a series of swaps in the given permutation solution .
9,025
public static < T > T access ( T [ ] array , int n ) { int max = array . length - 1 ; if ( ( n < 0 ) || ( n > max ) ) { throw new InvalidValueException ( n , "n" , Range . between ( 0 , max ) ) ; } return array [ n ] ; }
Liefert das n - te Element des uebergebenen Arrays zurueck falls ein korrekter Index uebergaben wird
9,026
public static void precondition ( boolean assertion , String format , Object ... params ) { if ( ! assertion ) { throw new IllegalArgumentException ( String . format ( format , params ) ) ; } }
Enforces a state precondition throwing an IllegalArgumentException if the assertion fails .
9,027
public static void state ( boolean assertion , String format , Object ... params ) { if ( ! assertion ) { throw new IllegalStateException ( String . format ( format , params ) ) ; } }
Enforces a state precondition throwing an IllegalStateException if the assertion fails .
9,028
@ SuppressWarnings ( "unchecked" ) public < T extends MonetaryAmount > MonetaryAmountFactory < T > getAmountFactory ( Class < T > amountType ) { if ( Geldbetrag . class . equals ( amountType ) ) { return ( MonetaryAmountFactory < T > ) new GeldbetragFactory ( ) ; } MonetaryAmountFactoryProviderSpi < T > f = MonetaryAmountFactoryProviderSpi . class . cast ( factories . get ( amountType ) ) ; if ( Objects . nonNull ( f ) ) { return f . createMonetaryAmountFactory ( ) ; } throw new MonetaryException ( "no MonetaryAmountFactory found for " + amountType ) ; }
save cast since members are managed by this instance
9,029
private DebugStyler debugStylers ( String ... names ) throws VectorPrintException { if ( settings . getBooleanProperty ( false , DEBUG ) ) { DebugStyler dst = new DebugStyler ( ) ; StylerFactoryHelper . initStylingObject ( dst , writer , document , null , layerManager , settings ) ; try { ParamAnnotationProcessorImpl . PAP . initParameters ( dst ) ; } catch ( NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException ex ) { throw new VectorPrintException ( ex ) ; } for ( String n : names ) { dst . getStyleSetup ( ) . add ( n ) ; styleSetup . put ( n , SettingsBindingService . getInstance ( ) . getFactory ( ) . getBindingHelper ( ) . serializeValue ( settings . getStringProperties ( null , n ) ) ) ; } return dst ; } return null ; }
return a debug styler that will be appended to the stylers for providing debugging info in reports
9,030
public static < K , V > MapAdapter < K , V > mapAdapter ( final Map < K , V > map ) { return key -> Optional . ofNullable ( map . get ( key ) ) ; }
Produces a MapAdapter for the given Map .
9,031
public static < T > Optional < T > firstInList ( List < T > list ) { return list . isEmpty ( ) ? Optional . empty ( ) : Optional . ofNullable ( list . get ( 0 ) ) ; }
Adapter to create an Optional out of the first element of a List . If the list is empty we get an empty optional . Also if the first element is null return an empty optional .
9,032
public static < K , V > Optional < V > getOpt ( Map < K , V > map , K key ) { return Optional . ofNullable ( map . get ( key ) ) ; }
Get an item from a map wrapping it in an Optional
9,033
public GeldbetragFactory setNumber ( Number number ) { this . number = number ; this . context = getMonetaryContextOf ( number ) ; return this ; }
Setzt die Nummer fuer den Geldbetrag .
9,034
public final void onOpenDocument ( PdfWriter writer , Document document ) { super . onOpenDocument ( writer , document ) ; template = writer . getDirectContent ( ) . createTemplate ( document . getPageSize ( ) . getWidth ( ) , document . getPageSize ( ) . getHeight ( ) ) ; if ( ! getSettings ( ) . containsKey ( PAGEFOOTERSTYLEKEY ) ) { getSettings ( ) . put ( PAGEFOOTERSTYLEKEY , PAGEFOOTERSTYLE ) ; } if ( ! getSettings ( ) . containsKey ( PAGEFOOTERTABLEKEY ) ) { float tot = ItextHelper . ptsToMm ( document . getPageSize ( ) . getWidth ( ) - document . leftMargin ( ) - document . rightMargin ( ) ) ; getSettings ( ) . put ( PAGEFOOTERTABLEKEY , new StringBuilder ( "Table(columns=3,widths=" ) . append ( Math . round ( tot * getSettings ( ) . getFloatProperty ( 0.85f , "footerleftwidthpercentage" ) ) ) . append ( '|' ) . append ( Math . round ( tot * getSettings ( ) . getFloatProperty ( 0.14f , "footermiddlewidthpercentage" ) ) ) . append ( '|' ) . append ( Math . round ( tot * getSettings ( ) . getFloatProperty ( 0.01f , "footerrightwidthpercentage" ) ) ) . append ( ')' ) . toString ( ) ) ; } }
prepares template for printing header and footer
9,035
protected void printFailureHeader ( PdfTemplate template , float x , float y ) { Font f = DebugHelper . debugFontLink ( template , getSettings ( ) ) ; Chunk c = new Chunk ( getSettings ( ) . getProperty ( "failures in report, see end of report" , "failureheader" ) , f ) ; ColumnText . showTextAligned ( template , Element . ALIGN_LEFT , new Phrase ( c ) , x , y , 0 ) ; }
when failure information is appended to the report a header on each page will be printed refering to this information .
9,036
protected void renderFooter ( PdfWriter writer , Document document ) throws DocumentException , VectorPrintException , InstantiationException , IllegalAccessException { if ( ! debugHereAfter && ! failuresHereAfter ) { PdfPTable footerTable = elementProducer . createElement ( null , PdfPTable . class , getStylers ( PAGEFOOTERTABLEKEY ) ) ; footerTable . addCell ( createFooterCell ( ValueHelper . createDate ( new Date ( ) ) ) ) ; String pageText = writer . getPageNumber ( ) + getSettings ( ) . getProperty ( " of " , UPTO ) ; PdfPCell c = createFooterCell ( pageText ) ; c . setHorizontalAlignment ( Element . ALIGN_RIGHT ) ; footerTable . addCell ( c ) ; footerTable . addCell ( createFooterCell ( new Chunk ( ) ) ) ; footerTable . writeSelectedRows ( 0 , - 1 , document . getPageSize ( ) . getLeft ( ) + document . leftMargin ( ) , document . getPageSize ( ) . getBottom ( document . bottomMargin ( ) ) , writer . getDirectContentUnder ( ) ) ; footerBottom = document . bottom ( ) - footerTable . getTotalHeight ( ) ; } }
prints a footer table with a line at the top a date and page numbering second cell will be right aligned
9,037
protected Image getTemplateImage ( PdfTemplate template ) throws BadElementException { if ( templateImage == null ) { templateImage = Image . getInstance ( template ) ; templateImage . setAbsolutePosition ( 0 , 0 ) ; } return templateImage ; }
this image will be used for painting the total number of pages and for a failure header when failures are printed inside the report .
9,038
public static Collection < BaseStyler > findForCssName ( String cssName , boolean required ) throws ClassNotFoundException , IOException , InstantiationException , IllegalAccessException , NoSuchMethodException , InvocationTargetException { Collection < BaseStyler > stylers = new ArrayList < > ( 1 ) ; for ( Class < ? > c : ClassHelper . fromPackage ( Font . class . getPackage ( ) ) ) { if ( ! Modifier . isAbstract ( c . getModifiers ( ) ) && BaseStyler . class . isAssignableFrom ( c ) ) { BaseStyler bs = ( BaseStyler ) c . newInstance ( ) ; if ( bs . findForCssProperty ( cssName ) != null && ! bs . findForCssProperty ( cssName ) . isEmpty ( ) ) { stylers . add ( bs ) ; if ( LOGGER . isLoggable ( Level . FINE ) ) { LOGGER . fine ( String . format ( "found %s supporting css property %s" , cssName , bs . getClass ( ) . getName ( ) ) ) ; } } } } if ( stylers . isEmpty ( ) ) { if ( required ) { throw new IllegalArgumentException ( String . format ( "no styler supports css property %s" , cssName ) ) ; } else { LOGGER . warning ( String . format ( "no styler supports css property %s" , cssName ) ) ; } } return stylers ; }
find BaseStylers that implements a css property .
9,039
public static Waehrung of ( Currency currency ) { String key = currency . getCurrencyCode ( ) ; return CACHE . computeIfAbsent ( key , t -> new Waehrung ( currency ) ) ; }
Gibt die entsprechende Currency als Waehrung zurueck . Da die Anzahl der Waehrungen ueberschaubar ist werden sie in einem dauerhaften Cache vorgehalten .
9,040
public static Waehrung of ( CurrencyUnit currencyUnit ) { if ( currencyUnit instanceof Waehrung ) { return ( Waehrung ) currencyUnit ; } else { return of ( currencyUnit . getCurrencyCode ( ) ) ; } }
Gibt die entsprechende Currency als Waehrung zurueck .
9,041
public static String validate ( String code ) { try { toCurrency ( code ) ; } catch ( IllegalArgumentException ex ) { throw new InvalidValueException ( code , "currency" ) ; } return code ; }
Validiert den uebergebenen Waehrungscode .
9,042
public static String getSymbol ( CurrencyUnit cu ) { try { return Waehrung . of ( cu ) . getSymbol ( ) ; } catch ( IllegalArgumentException ex ) { LOG . log ( Level . WARNING , "Cannot get symbol for '" + cu + "':" , ex ) ; return cu . getCurrencyCode ( ) ; } }
Lieft das Waehrungssymbol der uebergebenen Waehrungseinheit .
9,043
public static synchronized boolean compareMetricsCacheValuesByKey ( String deployment , String key , ArrayList < Object > valuesToCompare ) { boolean isEqual = true ; ArrayList < Object > cacheValues ; cacheValues = getMetricsCache ( deployment ) . get ( key ) ; for ( Object valueComp : valuesToCompare ) { for ( Object value : cacheValues ) { if ( value . toString ( ) . compareTo ( valueComp . toString ( ) ) == 0 ) { isEqual = true ; break ; } isEqual = false ; } } return isEqual ; }
Dummy comparison for test cases .
9,044
public static < T , R > R widen ( T value ) { return new Vary < T , R > ( ) . apply ( value ) ; }
Performs a downcast on a value .
9,045
public static < T extends R , R > R narrow ( T value ) { return new Vary < T , R > ( ) . apply ( value ) ; }
Performs an upcast on a value .
9,046
public static < T , R > R vary ( T value ) { return new Vary < T , R > ( ) . apply ( value ) ; }
Performs a reinterpret cast on a value .
9,047
public static String validate ( String code ) { String plz = normalize ( code ) ; if ( hasLandeskennung ( plz ) ) { validateNumberOf ( plz ) ; } else { plz = LengthValidator . validate ( plz , 3 , 10 ) ; } return plz ; }
Eine Postleitahl muss zwischen 3 und 10 Ziffern lang sein . Eventuell kann noch die Laenderkennung vorangestellt werden . Dies wird hier ueberprueft .
9,048
public Locale getLand ( ) { String kennung = this . getLandeskennung ( ) ; switch ( kennung ) { case "D" : return new Locale ( "de" , "DE" ) ; case "A" : return new Locale ( "de" , "AT" ) ; case "CH" : return new Locale ( "de" , "CH" ) ; default : throw new UnsupportedOperationException ( "unbekannte Landeskennung '" + kennung + "'" ) ; } }
Liefert das Land die der Landeskennung entspricht .
9,049
public List < File > getFiles ( File dir , FileFilter filter ) { List < File > files = new LinkedList < File > ( ) ; for ( File f : dir . listFiles ( ) ) { if ( f . isFile ( ) ) { if ( filter . accept ( f ) ) files . add ( f ) ; } else { files . addAll ( getFiles ( f , filter ) ) ; } } return files ; }
Returns a list with all files in the given Directory matching the given Filter
9,050
public void execute ( ) throws MojoExecutionException { getLog ( ) . info ( "Start, BS: " + System . getProperty ( "os.name" ) ) ; if ( System . getProperty ( "os.name" ) . contains ( "indows" ) ) { CPPATHSEPERATOR = ";" ; PATHSEPERATOR = "\\" ; } else { CPPATHSEPERATOR = ":" ; PATHSEPERATOR = "/" ; } System . out . println ( "Execute: " + standardoutput ) ; tests = 0 ; failure = 0 ; error = 0 ; if ( standardoutput != null ) { File output = new File ( standardoutput ) ; try { bw = new BufferedWriter ( new FileWriter ( output ) ) ; } catch ( IOException e1 ) { e1 . printStackTrace ( ) ; } } else { File output = new File ( "stdout.txt" ) ; try { bw = new BufferedWriter ( new FileWriter ( output ) ) ; } catch ( IOException e1 ) { e1 . printStackTrace ( ) ; } } File dir = new File ( "src/test/java/" ) ; FileFilter fileFilter = new RegexFileFilter ( "[A-z/]*.java$" ) ; project = project . getExecutionProject ( ) ; runTestFile ( dir , fileFilter ) ; getLog ( ) . info ( "Tests: " + tests + " Fehlschläge: " ailure + " Fehler: " + error ) ; }
Main - method that is executed when the tests are executed
9,051
public void addEvaluation ( Objective obj , Evaluation eval , double weight ) { evaluations . put ( obj , eval ) ; weightedSum += weight * eval . getValue ( ) ; }
Add an evaluation produced by an objective specifying its weight .
9,052
private void loadData ( ) throws JAXBException { if ( file . exists ( ) ) { final JAXBContext jc = JAXBContext . newInstance ( Kopemedata . class ) ; final Unmarshaller unmarshaller = jc . createUnmarshaller ( ) ; data = ( Kopemedata ) unmarshaller . unmarshal ( file ) ; LOG . trace ( "Daten geladen, Daten: " + data ) ; } else { LOG . info ( "Datei {} existiert nicht" , file . getAbsolutePath ( ) ) ; data = new Kopemedata ( ) ; data . setTestcases ( new Testcases ( ) ) ; final Testcases tc = data . getTestcases ( ) ; LOG . trace ( "TC: " + tc ) ; tc . setClazz ( file . getName ( ) ) ; } }
Loads the data .
9,053
public Map < String , Map < Date , Long > > getData ( final String collectorName ) { final Map < String , Map < Date , Long > > map = new HashMap < > ( ) ; final Testcases testcases = data . getTestcases ( ) ; for ( final TestcaseType tct : testcases . getTestcase ( ) ) { final Map < Date , Long > measures = new HashMap < > ( ) ; final List < Datacollector > collectorMap = tct . getDatacollector ( ) ; Datacollector collector = null ; for ( final Datacollector dc : collectorMap ) { if ( dc . getName ( ) . equals ( collectorName ) ) { collector = dc ; } } if ( collector == null ) { LOG . error ( "Achtung: Datenkollektor " + collectorName + " nicht vorhanden" ) ; } else { for ( final Result s : collector . getResult ( ) ) { measures . put ( new Date ( s . getDate ( ) ) , ( long ) s . getValue ( ) ) ; } map . put ( tct . getName ( ) , measures ) ; } } return map ; }
Returns a mapping from all testcases to their results for a certain collectorName .
9,054
public Set < String > getCollectors ( ) { final Set < String > collectors = new HashSet < String > ( ) ; final Testcases testcases = data . getTestcases ( ) ; for ( final TestcaseType tct : testcases . getTestcase ( ) ) { for ( final Datacollector collector : tct . getDatacollector ( ) ) { collectors . add ( collector . getName ( ) ) ; } } return collectors ; }
Returns all datacollectors that are used in the resultfile .
9,055
public static < T > T max ( T lhs , T rhs , Comparator < T > comparator ) { return BinaryOperator . maxBy ( comparator ) . apply ( lhs , rhs ) ; }
Evaluates max of two elements .
9,056
public static < T extends Comparable < T > > T max ( T lhs , T rhs ) { return BinaryOperator . maxBy ( new ComparableComparator < T > ( ) ) . apply ( lhs , rhs ) ; }
Evaluates max of two comparable elements .
9,057
public static < T > T min ( T lhs , T rhs , Comparator < T > comparator ) { return BinaryOperator . minBy ( comparator ) . apply ( lhs , rhs ) ; }
Evaluates min of two elements .
9,058
public static < T extends Comparable < T > > T min ( T lhs , T rhs ) { return BinaryOperator . minBy ( new ComparableComparator < T > ( ) ) . apply ( lhs , rhs ) ; }
Evaluates min of two comparable elements .
9,059
public static < T > Pair < T , T > ordered ( T lhs , T rhs , Comparator < T > comparator ) { return new MakeOrder < T > ( comparator ) . apply ( lhs , rhs ) ; }
Returns the two elements ordered in a pair .
9,060
public static < T extends Comparable < T > > Pair < T , T > ordered ( T lhs , T rhs ) { return new MakeOrder < T > ( new ComparableComparator < T > ( ) ) . apply ( lhs , rhs ) ; }
Returns the two comparable elements ordered in a pair .
9,061
public void swap ( int i , int j ) { try { Collections . swap ( order , i , j ) ; } catch ( IndexOutOfBoundsException ex ) { throw new SolutionModificationException ( "Error while modifying permutation solution: swapped positions should be positive " + "and smaller than the number of items in the permutation." , this ) ; } }
Swap the items at position i and j in the permutation . Both positions should be positive and smaller than the number of items in the permutation .
9,062
public static void validate ( BigInteger nummer , Ort ort ) { if ( nummer . compareTo ( BigInteger . ONE ) < 0 ) { throw new InvalidValueException ( nummer , "number" ) ; } validate ( ort ) ; }
Validiert das uebergebene Postfach auf moegliche Fehler .
9,063
public final boolean execute ( ) throws Exception { boolean finished = false ; mainThread . start ( ) ; mainThread . setUncaughtExceptionHandler ( new UncaughtExceptionHandler ( ) { public void uncaughtException ( final Thread arg0 , final Throwable arg1 ) { LOG . error ( "Uncaught exception in {}: {}" , arg0 . getName ( ) , arg1 . getClass ( ) ) ; testError = arg1 ; } } ) ; LOG . debug ( "Warte: " + timeout ) ; mainThread . join ( timeout ) ; if ( mainThread . isAlive ( ) ) { mainThread . setFinished ( true ) ; LOG . error ( "Test " + type + " " + mainThread . getName ( ) + " timed out!" ) ; for ( int i = 0 ; i < 5 ; i ++ ) { mainThread . interrupt ( ) ; Thread . sleep ( 5 ) ; } } else { finished = true ; } mainThread . join ( 1000 ) ; if ( mainThread . isAlive ( ) ) { LOG . error ( "Test timed out and was not able to save his data after 10 seconds - is killed hard now." ) ; mainThread . stop ( ) ; } if ( testError != null ) { LOG . trace ( "Test error != null" ) ; if ( testError instanceof Exception ) { throw ( Exception ) testError ; } else if ( testError instanceof Error ) { throw ( Error ) testError ; } else { LOG . error ( "Unexpected behaviour" ) ; testError . printStackTrace ( ) ; } } return finished ; }
Executes the TimeBoundedExecution .
9,064
public static Geldbetrag parse ( CharSequence text , MonetaryAmountFormat formatter ) { return from ( formatter . parse ( text ) ) ; }
Erzeugt einen Geldbetrag anhand des uebergebenen Textes und mittels des uebergebenen Formatters .
9,065
public static String validate ( String zahl ) { try { return Geldbetrag . valueOf ( zahl ) . toString ( ) ; } catch ( IllegalArgumentException ex ) { throw new InvalidValueException ( zahl , "money_amount" , ex ) ; } }
Validiert die uebergebene Zahl ob sie sich als Geldbetrag eignet .
9,066
public static BigDecimal validate ( BigDecimal zahl , CurrencyUnit currency ) { if ( zahl . scale ( ) == 0 ) { return zahl . setScale ( currency . getDefaultFractionDigits ( ) , RoundingMode . HALF_UP ) ; } return zahl ; }
Validiert die uebergebene Zahl .
9,067
public < R > R query ( MonetaryQuery < R > query ) { Objects . requireNonNull ( query ) ; try { return query . queryFrom ( this ) ; } catch ( MonetaryException ex ) { throw ex ; } catch ( RuntimeException ex ) { throw new LocalizedMonetaryException ( "query failed" , query , ex ) ; } }
Fraegt einen Wert an .
9,068
public String toLongString ( ) { NumberFormat formatter = DecimalFormat . getInstance ( ) ; formatter . setMinimumFractionDigits ( context . getMaxScale ( ) ) ; formatter . setMinimumFractionDigits ( context . getMaxScale ( ) ) ; return formatter . format ( betrag ) + " " + currency ; }
Hier wird der Geldbetrag mit voller Genauigkeit ausgegeben .
9,069
public static < T2 , T1 , R > Function < T1 , R > compose ( Function < T2 , R > f , Function < T1 , T2 > g ) { dbc . precondition ( f != null , "cannot compose a null function" ) ; dbc . precondition ( g != null , "cannot compose a null function" ) ; return f . compose ( g ) ; }
Composes a function with another function .
9,070
public static < T1 , T2 , T3 , R > BiFunction < T1 , T2 , R > compose ( Function < T3 , R > unary , BiFunction < T1 , T2 , T3 > binary ) { dbc . precondition ( unary != null , "cannot compose a null unary function" ) ; dbc . precondition ( binary != null , "cannot compose a null binary function" ) ; return binary . andThen ( unary ) ; }
Composes a function with a binary function .
9,071
public static < T1 , T2 , T3 , T4 , R > TriFunction < T1 , T2 , T3 , R > compose ( Function < T4 , R > unary , TriFunction < T1 , T2 , T3 , T4 > ternary ) { dbc . precondition ( unary != null , "cannot compose a null unary function" ) ; dbc . precondition ( ternary != null , "cannot compose a null ternary function" ) ; return ternary . andThen ( unary ) ; }
Composes a function with a ternary function .
9,072
public static < T > UnaryOperator < T > compose ( Iterator < Function < T , T > > endodelegates ) { return new UnaryOperatorsComposer < T > ( ) . apply ( endodelegates ) ; }
Composes an iterator of endofunctions .
9,073
public static < T1 , T2 > BiPredicate < T1 , T2 > or ( BiPredicate < T1 , T2 > first , BiPredicate < T1 , T2 > second , BiPredicate < T1 , T2 > third ) { dbc . precondition ( first != null , "first predicate is null" ) ; dbc . precondition ( second != null , "second predicate is null" ) ; dbc . precondition ( third != null , "third predicate is null" ) ; return Logic . Binary . or ( Iterations . iterable ( first , second , third ) ) ; }
Creates a composite OR predicate from the given predicates .
9,074
@ SuppressWarnings ( "unchecked" ) private void parse ( ) throws ParseException { _argValues = new HashMap < Argument , String > ( ) ; _varargValues = new ArrayList < String > ( ) ; List < String > argList = _commandLine . getArgList ( ) ; int required = 0 ; boolean hasOptional = false ; boolean hasVarargs = false ; for ( Argument argument : _arguments . getArguments ( ) ) { if ( argument . isRequired ( ) ) { required ++ ; } else { hasOptional = true ; } if ( argument . isVararg ( ) ) { hasVarargs = true ; } } int allowed = hasOptional ? required + 1 : required ; if ( argList . size ( ) < required ) { throw new ParseException ( "Not enough arguments provided. " + required + " required, but only " + argList . size ( ) + " provided." ) ; } if ( ! hasVarargs ) { if ( argList . size ( ) > allowed ) { throw new ParseException ( "Too many arguments provided. Only " + allowed + " allowed, but " + argList . size ( ) + " provided." ) ; } } int index = 0 ; boolean finalArgEncountered = false ; for ( Argument argument : _arguments . getArguments ( ) ) { if ( finalArgEncountered ) throw new IllegalStateException ( "Illegal arguments defined. No additional arguments may be defined after first optional or vararg argument." ) ; if ( argument . isRequired ( ) && ! argument . isVararg ( ) ) { if ( index <= argList . size ( ) ) { _argValues . put ( argument , argList . get ( index ) ) ; } else { throw new IllegalStateException ( "not enough arguments" ) ; } } else { finalArgEncountered = true ; if ( argument . isVararg ( ) ) { _varargValues = argList . subList ( Math . min ( index , argList . size ( ) ) , argList . size ( ) ) ; if ( argument . isRequired ( ) && _varargValues . size ( ) < 1 ) { throw new IllegalStateException ( "not enough arguments" ) ; } } else { if ( index < argList . size ( ) ) { _argValues . put ( argument , argList . get ( index ) ) ; } } } index ++ ; } }
Parses and verifies the command line options .
9,075
public String normalize ( String value ) { if ( ! value . matches ( "[\\d,.]+([eE]\\d+)?" ) ) { throw new InvalidValueException ( value , NUMBER ) ; } Locale locale = guessLocale ( value ) ; DecimalFormat df = ( DecimalFormat ) DecimalFormat . getInstance ( locale ) ; df . setParseBigDecimal ( true ) ; try { return df . parse ( value ) . toString ( ) ; } catch ( ParseException ex ) { throw new InvalidValueException ( value , NUMBER , ex ) ; } }
Normalisiert einen String sodass er zur Generierung einer Zahl herangezogen werden kann .
9,076
public boolean isValid ( String wert ) { if ( StringUtils . length ( wert ) < 1 ) { return false ; } else { return getPruefziffer ( wert ) . equals ( berechnePruefziffer ( wert . substring ( 0 , wert . length ( ) - 1 ) ) ) ; } }
Liefert true zurueck wenn der uebergebene Wert gueltig ist .
9,077
public boolean isBruch ( ) { String s = toString ( ) ; if ( s . contains ( "/" ) ) { try { Bruch . of ( s ) ; return true ; } catch ( IllegalArgumentException ex ) { LOG . fine ( s + " is not a fraction: " + ex ) ; return false ; } } else { return false ; } }
Liefert true zurueck wenn die Zahl als Bruch angegeben ist .
9,078
public PackedDecimal movePointLeft ( int n ) { BigDecimal result = toBigDecimal ( ) . movePointLeft ( n ) ; return PackedDecimal . valueOf ( result ) ; }
Verschiebt den Dezimalpunkt um n Stellen nach links .
9,079
public PackedDecimal movePointRight ( int n ) { BigDecimal result = toBigDecimal ( ) . movePointRight ( n ) ; return PackedDecimal . valueOf ( result ) ; }
Verschiebt den Dezimalpunkt um n Stellen nach rechts .
9,080
public PackedDecimal setScale ( int n , RoundingMode mode ) { BigDecimal result = toBigDecimal ( ) . setScale ( n , mode ) ; return PackedDecimal . valueOf ( result ) ; }
Setzt die Anzahl der Nachkommastellen .
9,081
public static < T > Runnable curry ( Consumer < T > consumer , T value ) { dbc . precondition ( consumer != null , "cannot bind parameter of a null consumer" ) ; return ( ) -> consumer . accept ( value ) ; }
Partial application of the first parameter to an consumer .
9,082
public static < T1 , T2 > Consumer < T2 > curry ( BiConsumer < T1 , T2 > consumer , T1 first ) { dbc . precondition ( consumer != null , "cannot bind parameter of a null consumer" ) ; return second -> consumer . accept ( first , second ) ; }
Partial application of the first parameter to a binary consumer .
9,083
public static < T > BooleanSupplier curry ( Predicate < T > predicate , T value ) { dbc . precondition ( predicate != null , "cannot bind parameter of a null predicate" ) ; return ( ) -> predicate . test ( value ) ; }
Partial application of the parameter to a predicate .
9,084
public static < T1 , T2 , T3 > BiPredicate < T2 , T3 > curry ( TriPredicate < T1 , T2 , T3 > predicate , T1 first ) { dbc . precondition ( predicate != null , "cannot bind parameter of a null predicate" ) ; return ( second , third ) -> predicate . test ( first , second , third ) ; }
Partial application of the first parameter to a ternary predicate .
9,085
public static < T , R > Supplier < R > curry ( Function < T , R > function , T value ) { dbc . precondition ( function != null , "cannot bind parameter of a null function" ) ; return ( ) -> function . apply ( value ) ; }
Partial application of the parameter to a function .
9,086
public static < T1 , T2 , R > Function < T2 , R > curry ( BiFunction < T1 , T2 , R > function , T1 first ) { dbc . precondition ( function != null , "cannot bind parameter of a null function" ) ; return second -> function . apply ( first , second ) ; }
Partial application of the first parameter to a binary function .
9,087
public static < T1 , T2 , T3 , R > BiFunction < T2 , T3 , R > curry ( TriFunction < T1 , T2 , T3 , R > function , T1 first ) { dbc . precondition ( function != null , "cannot bind parameter of a null function" ) ; return ( second , third ) -> function . apply ( first , second , third ) ; }
Partial application of the first parameter to a ternary function .
9,088
public static < T > Predicate < T > ignore ( BooleanSupplier proposition , Class < T > ignored ) { dbc . precondition ( proposition != null , "cannot ignore parameter of a null proposition" ) ; return t -> proposition . getAsBoolean ( ) ; }
Adapts a proposition to a predicate by ignoring the passed parameter .
9,089
public static < T1 , T2 > BiPredicate < T1 , T2 > ignore2nd ( Predicate < T1 > predicate , Class < T2 > ignored ) { dbc . precondition ( predicate != null , "cannot ignore parameter of a null predicate" ) ; return ( first , second ) -> predicate . test ( first ) ; }
Adapts a predicate to a binary predicate by ignoring second parameter .
9,090
public static < T1 , T2 , T3 > TriPredicate < T1 , T2 , T3 > ignore2nd ( BiPredicate < T1 , T3 > predicate , Class < T2 > ignored ) { dbc . precondition ( predicate != null , "cannot ignore parameter of a null predicate" ) ; return ( first , second , third ) -> predicate . test ( first , third ) ; }
Adapts a binary predicate to a ternary predicate by ignoring second parameter .
9,091
public static < T > Consumer < T > ignore ( Runnable runnable , Class < T > ignored ) { dbc . precondition ( runnable != null , "cannot ignore parameter of a null runnable" ) ; return first -> runnable . run ( ) ; }
Adapts a runnable to an consumer by ignoring the parameter .
9,092
public static < T1 , T2 > BiConsumer < T1 , T2 > ignore1st ( Consumer < T2 > consumer , Class < T1 > ignored ) { dbc . precondition ( consumer != null , "cannot ignore parameter of a null consumer" ) ; return ( first , second ) -> consumer . accept ( second ) ; }
Adapts an consumer to a binary consumer by ignoring the first parameter .
9,093
public static < T1 , T2 , T3 > TriConsumer < T1 , T2 , T3 > ignore3rd ( BiConsumer < T1 , T2 > consumer , Class < T3 > ignored ) { dbc . precondition ( consumer != null , "cannot ignore parameter of a null consumer" ) ; return ( first , second , third ) -> consumer . accept ( first , second ) ; }
Adapts a binary consumer to a ternary consumer by ignoring the third parameter .
9,094
public static < T , R > Function < T , R > ignore ( Supplier < R > supplier , Class < T > ignored ) { dbc . precondition ( supplier != null , "cannot ignore parameter of a null supplier" ) ; return first -> supplier . get ( ) ; }
Adapts a supplier to a function by ignoring the passed parameter .
9,095
public static < T1 , T2 , R > BiFunction < T1 , T2 , R > ignore1st ( Function < T2 , R > function , Class < T1 > ignored ) { dbc . precondition ( function != null , "cannot ignore parameter of a null function" ) ; return ( first , second ) -> function . apply ( second ) ; }
Adapts a function to a binary function by ignoring the first parameter .
9,096
public static < T1 , T2 , T3 , R > TriFunction < T1 , T2 , T3 , R > ignore1st ( BiFunction < T2 , T3 , R > function , Class < T1 > ignored ) { dbc . precondition ( function != null , "cannot ignore parameter of a null function" ) ; return ( first , second , third ) -> function . apply ( second , third ) ; }
Adapts a binary function to a ternary function by ignoring the first parameter .
9,097
public static < T > Supplier < Optional < T > > supplier ( Iterator < T > adaptee ) { return new IteratingSupplier < T > ( adaptee ) ; }
Adapts an iterator to a supplier .
9,098
public static Supplier < Void > supplier ( Runnable adaptee ) { dbc . precondition ( adaptee != null , "cannot adapt a null runnable" ) ; return ( ) -> { adaptee . run ( ) ; return null ; } ; }
Adapts a runnable to a supplier .
9,099
public static Supplier < Boolean > supplier ( BooleanSupplier adaptee ) { dbc . precondition ( adaptee != null , "cannot adapt a null boolean supplier" ) ; return ( ) -> adaptee . getAsBoolean ( ) ; }
Adapts a proposition to a supplier .