idx int64 0 41.2k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
31,300 | protected Map < String , String > prepareRequiredParameters ( final FunctionTemplate template , final BindingTemplate bindingTemplate ) throws MojoFailureException { info ( "" ) ; info ( PREPARE_PARAMS ) ; prepareFunctionName ( ) ; preparePackageName ( ) ; final Map < String , String > params = new HashMap < > ( ) ; params . put ( "functionName" , getFunctionName ( ) ) ; params . put ( "className" , getClassName ( ) ) ; params . put ( "packageName" , getFunctionPackageName ( ) ) ; prepareTemplateParameters ( template , bindingTemplate , params ) ; displayParameters ( params ) ; return params ; } | region Prepare parameters |
31,301 | protected String substituteParametersInTemplate ( final FunctionTemplate template , final Map < String , String > params ) { String ret = template . getFiles ( ) . get ( "function.java" ) ; for ( final Map . Entry < String , String > entry : params . entrySet ( ) ) { ret = ret . replace ( String . format ( "$%s$" , entry . getKey ( ) ) , entry . getValue ( ) ) ; } return ret ; } | region Substitute parameters |
31,302 | protected void saveNewFunctionToFile ( final String newFunctionClass ) throws Exception { info ( "" ) ; info ( SAVE_FILE ) ; final File packageDir = getPackageDir ( ) ; final File targetFile = getTargetFile ( packageDir ) ; createPackageDirIfNotExist ( packageDir ) ; saveToTargetFile ( targetFile , newFunctionClass ) ; info ( SAVE_FILE_DONE + targetFile . getAbsolutePath ( ) ) ; } | region Save function to file |
31,303 | protected void createOrUpdateFunctionApp ( ) throws Exception { final FunctionApp app = getFunctionApp ( ) ; if ( app == null ) { createFunctionApp ( ) ; } else { updateFunctionApp ( app ) ; } } | region Create or update Azure Functions |
31,304 | protected Authenticated getAuthObjFromServerId ( final Settings settings , final String serverId ) { if ( StringUtils . isEmpty ( serverId ) ) { getLog ( ) . debug ( SERVER_ID_NOT_CONFIG ) ; return null ; } final Server server = Utils . getServer ( settings , serverId ) ; try { assureServerExist ( server , serverId ) ; } catch ( MojoExecutionException ex ) { getLog ( ) . error ( ex . getMessage ( ) ) ; return null ; } final ApplicationTokenCredentials credential = getAppTokenCredentialsFromServer ( server ) ; if ( credential == null ) { getLog ( ) . error ( AZURE_AUTH_INVALID + serverId ) ; return null ; } final Authenticated auth = azureConfigure ( ) . authenticate ( credential ) ; if ( auth != null ) { getLog ( ) . info ( AUTH_WITH_SERVER_ID + serverId ) ; } return auth ; } | Get Authenticated object by referencing server definition in Maven settings . xml |
31,305 | protected Authenticated getAuthObjFromFile ( final File authFile ) { if ( authFile == null ) { getLog ( ) . debug ( AUTH_FILE_NOT_CONFIG ) ; return null ; } if ( ! authFile . exists ( ) ) { getLog ( ) . error ( AUTH_FILE_NOT_EXIST + authFile . getAbsolutePath ( ) ) ; return null ; } try { final Authenticated auth = azureConfigure ( ) . authenticate ( authFile ) ; if ( auth != null ) { getLog ( ) . info ( AUTH_WITH_FILE + authFile . getAbsolutePath ( ) ) ; } return auth ; } catch ( Exception e ) { getLog ( ) . error ( AUTH_FILE_READ_FAIL + authFile . getAbsolutePath ( ) ) ; getLog ( ) . error ( e ) ; } return null ; } | Get Authenticated object using file . |
31,306 | protected Authenticated getAuthObjFromAzureCli ( ) { try { final Azure . Configurable azureConfigurable = azureConfigure ( ) ; final Authenticated auth ; if ( isInCloudShell ( ) ) { getLog ( ) . info ( AUTH_WITH_MSI ) ; auth = azureConfigurable . authenticate ( new MSICredentials ( ) ) ; } else { getLog ( ) . info ( AUTH_WITH_AZURE_CLI ) ; auth = azureConfigurable . authenticate ( AzureCliCredentials . create ( ) ) ; } return auth ; } catch ( Exception e ) { getLog ( ) . debug ( AZURE_CLI_AUTH_FAIL ) ; getLog ( ) . debug ( e ) ; } return null ; } | Get Authenticated object using authentication file from Azure CLI 2 . 0 |
31,307 | protected ApplicationTokenCredentials getAppTokenCredentialsFromServer ( Server server ) { if ( server == null ) { return null ; } final String clientId = Utils . getValueFromServerConfiguration ( server , CLIENT_ID ) ; if ( StringUtils . isEmpty ( clientId ) ) { getLog ( ) . debug ( CLIENT_ID_NOT_CONFIG ) ; return null ; } final String tenantId = Utils . getValueFromServerConfiguration ( server , TENANT_ID ) ; if ( StringUtils . isEmpty ( tenantId ) ) { getLog ( ) . debug ( TENANT_ID_NOT_CONFIG ) ; return null ; } final String environment = Utils . getValueFromServerConfiguration ( server , ENVIRONMENT ) ; final AzureEnvironment azureEnvironment = getAzureEnvironment ( environment ) ; getLog ( ) . debug ( "Azure Management Endpoint: " + azureEnvironment . managementEndpoint ( ) ) ; final String key = Utils . getValueFromServerConfiguration ( server , KEY ) ; if ( ! StringUtils . isEmpty ( key ) ) { getLog ( ) . debug ( USE_KEY_TO_AUTH ) ; return new ApplicationTokenCredentials ( clientId , tenantId , key , azureEnvironment ) ; } else { getLog ( ) . debug ( KEY_NOT_CONFIG ) ; } final String certificate = Utils . getValueFromServerConfiguration ( server , CERTIFICATE ) ; if ( StringUtils . isEmpty ( certificate ) ) { getLog ( ) . debug ( CERTIFICATE_FILE_NOT_CONFIG ) ; return null ; } final String certificatePassword = Utils . getValueFromServerConfiguration ( server , CERTIFICATE_PASSWORD ) ; try { final byte [ ] cert ; cert = Files . readAllBytes ( Paths . get ( certificate , new String [ 0 ] ) ) ; getLog ( ) . debug ( USE_CERTIFICATE_TO_AUTH + certificate ) ; return new ApplicationTokenCredentials ( clientId , tenantId , cert , certificatePassword , azureEnvironment ) ; } catch ( Exception e ) { getLog ( ) . debug ( CERTIFICATE_FILE_READ_FAIL + certificate ) ; } return null ; } | Get ApplicationTokenCredentials from server definition in Maven settings . xml |
31,308 | @ FunctionName ( "EventHubTriggerJava" ) public void run ( @ EventHubTrigger ( name = "message" , eventHubName = "trigger" , connection = "CIEventHubConnection" , consumerGroup = "$Default" ) String message , @ EventHubOutput ( name = "result" , eventHubName = "output" , connection = "CIEventHubConnection" ) OutputBinding < String > result , final ExecutionContext context ) { if ( message . contains ( "CIInput" ) ) { result . setValue ( "CITest" ) ; } } | This function will be invoked when an event is received from Event Hub . |
31,309 | public static Server getServer ( final Settings settings , final String serverId ) { if ( settings == null || StringUtils . isEmpty ( serverId ) ) { return null ; } return settings . getServer ( serverId ) ; } | Get server credential from Maven settings by server Id . |
31,310 | public static void assureServerExist ( final Server server , final String serverId ) throws MojoExecutionException { if ( server == null ) { throw new MojoExecutionException ( String . format ( "Server not found in settings.xml. ServerId=%s" , serverId ) ) ; } } | Assure the server with specified id does exist in settings . xml . It could be the server used for azure authentication . Or the server used for docker hub authentication of runtime configuration . |
31,311 | public static String getValueFromServerConfiguration ( final Server server , final String key ) { if ( server == null ) { return null ; } final Xpp3Dom configuration = ( Xpp3Dom ) server . getConfiguration ( ) ; if ( configuration == null ) { return null ; } final Xpp3Dom node = configuration . getChild ( key ) ; if ( node == null ) { return null ; } return node . getValue ( ) ; } | Get string value from server configuration section in settings . xml . |
31,312 | public static void copyResources ( final MavenProject project , final MavenSession session , final MavenResourcesFiltering filtering , final List < Resource > resources , final String targetDirectory ) throws IOException { for ( final Resource resource : resources ) { final String targetPath = resource . getTargetPath ( ) == null ? "" : resource . getTargetPath ( ) ; resource . setTargetPath ( Paths . get ( targetDirectory , targetPath ) . toString ( ) ) ; resource . setFiltering ( false ) ; } final MavenResourcesExecution mavenResourcesExecution = new MavenResourcesExecution ( resources , new File ( targetDirectory ) , project , "UTF-8" , null , Collections . EMPTY_LIST , session ) ; mavenResourcesExecution . setEscapeWindowsPaths ( true ) ; mavenResourcesExecution . setInjectProjectBuildFilters ( false ) ; mavenResourcesExecution . setOverwrite ( true ) ; mavenResourcesExecution . setIncludeEmptyDirs ( false ) ; mavenResourcesExecution . setSupportMultiLineFiltering ( false ) ; try { filtering . filterResources ( mavenResourcesExecution ) ; } catch ( MavenFilteringException ex ) { throw new IOException ( "Failed to copy resources" , ex ) ; } } | Copy resources to target directory using Maven resource filtering so that we don t have to handle recursive directory listing and pattern matching . In order to disable filtering the filtering property is force set to False . |
31,313 | private void prepareJavaSERuntime ( final List < File > artifacts ) throws MojoExecutionException { final File artifact = getProjectJarArtifact ( artifacts ) ; if ( artifact == null ) { return ; } switch ( runtimeSetting . getOsEnum ( ) ) { case Windows : try { WebAppUtils . generateWebConfigFile ( artifact . getName ( ) , log , stagingDirectoryPath , this . getClass ( ) ) ; } catch ( IOException e ) { throw new MojoExecutionException ( "Failed to generate web.config file" ) ; } break ; case Linux : log . info ( String . format ( RENAMING_MESSAGE , artifact . getAbsolutePath ( ) , DEFAULT_LINUX_JAR_NAME ) ) ; artifact . renameTo ( new File ( artifact . getParent ( ) , DEFAULT_LINUX_JAR_NAME ) ) ; break ; default : return ; } } | Rename project jar to app . jar for linux app service or generate web . config for windows javase app service |
31,314 | public void uploadDirectoryWithRetries ( final String ftpServer , final String username , final String password , final String sourceDirectory , final String targetDirectory , final int maxRetryCount ) throws MojoExecutionException { int retryCount = 0 ; while ( retryCount < maxRetryCount ) { retryCount ++ ; log . info ( UPLOAD_START + ftpServer ) ; if ( uploadDirectory ( ftpServer , username , password , sourceDirectory , targetDirectory ) ) { log . info ( UPLOAD_SUCCESS + ftpServer ) ; return ; } else { log . warn ( String . format ( UPLOAD_FAILURE , retryCount , maxRetryCount ) ) ; } } throw new MojoExecutionException ( String . format ( UPLOAD_RETRY_FAILURE , maxRetryCount ) ) ; } | Upload directory to specified FTP server with retries . |
31,315 | protected boolean uploadDirectory ( final String ftpServer , final String username , final String password , final String sourceDirectoryPath , final String targetDirectoryPath ) { log . debug ( "FTP username: " + username ) ; try { final FTPClient ftpClient = getFTPClient ( ftpServer , username , password ) ; log . info ( String . format ( UPLOAD_DIR_START , sourceDirectoryPath , targetDirectoryPath ) ) ; uploadDirectory ( ftpClient , sourceDirectoryPath , targetDirectoryPath , "" ) ; log . info ( String . format ( UPLOAD_DIR_FINISH , sourceDirectoryPath , targetDirectoryPath ) ) ; ftpClient . disconnect ( ) ; return true ; } catch ( Exception e ) { log . debug ( e ) ; log . error ( String . format ( UPLOAD_DIR_FAILURE , sourceDirectoryPath , targetDirectoryPath ) ) ; } return false ; } | Upload directory to specified FTP server without retries . |
31,316 | protected void uploadDirectory ( final FTPClient ftpClient , final String sourceDirectoryPath , final String targetDirectoryPath , final String logPrefix ) throws IOException { log . info ( String . format ( UPLOAD_DIR , logPrefix , sourceDirectoryPath , targetDirectoryPath ) ) ; final File sourceDirectory = new File ( sourceDirectoryPath ) ; final File [ ] files = sourceDirectory . listFiles ( ) ; if ( files == null || files . length == 0 ) { log . info ( String . format ( "%sEmpty directory at %s" , logPrefix , sourceDirectoryPath ) ) ; return ; } final boolean isTargetDirectoryExist = ftpClient . changeWorkingDirectory ( targetDirectoryPath ) ; if ( ! isTargetDirectoryExist ) { ftpClient . makeDirectory ( targetDirectoryPath ) ; } final String nextLevelPrefix = logPrefix + ".." ; for ( final File file : files ) { if ( file . isFile ( ) ) { uploadFile ( ftpClient , file . getAbsolutePath ( ) , targetDirectoryPath , nextLevelPrefix ) ; } else { uploadDirectory ( ftpClient , Paths . get ( sourceDirectoryPath , file . getName ( ) ) . toString ( ) , targetDirectoryPath + "/" + file . getName ( ) , nextLevelPrefix ) ; } } } | Recursively upload a directory to FTP server with the provided FTP client object . |
31,317 | protected void uploadFile ( final FTPClient ftpClient , final String sourceFilePath , final String targetFilePath , final String logPrefix ) throws IOException { log . info ( String . format ( UPLOAD_FILE , logPrefix , sourceFilePath , targetFilePath ) ) ; final File sourceFile = new File ( sourceFilePath ) ; try ( final InputStream is = new FileInputStream ( sourceFile ) ) { ftpClient . changeWorkingDirectory ( targetFilePath ) ; ftpClient . storeFile ( sourceFile . getName ( ) , is ) ; final int replyCode = ftpClient . getReplyCode ( ) ; final String replyMessage = ftpClient . getReplyString ( ) ; if ( isCommandFailed ( replyCode ) ) { log . error ( String . format ( UPLOAD_FILE_REPLY , logPrefix , replyMessage ) ) ; throw new IOException ( "Failed to upload file: " + sourceFilePath ) ; } else { log . info ( String . format ( UPLOAD_FILE_REPLY , logPrefix , replyMessage ) ) ; } } } | Upload a single file to FTP server with the provided FTP client object . |
31,318 | private Element getMavenPluginElement ( ) { try { final Element pluginsRoot = document . getRootElement ( ) . element ( "build" ) . element ( "plugins" ) ; for ( final Element element : pluginsRoot . elements ( ) ) { final String groupId = XMLUtils . getChildValue ( "groupId" , element ) ; final String artifactId = XMLUtils . getChildValue ( "artifactId" , element ) ; if ( PLUGIN_GROUPID . equals ( groupId ) && PLUGIN_ARTIFACTID . equals ( artifactId ) ) { return element ; } } } catch ( NullPointerException e ) { return null ; } return null ; } | get webapp maven plugin node from pom |
31,319 | private com . microsoft . applicationinsights . TelemetryConfiguration readConfigurationFromFile ( ) { final com . microsoft . applicationinsights . TelemetryConfiguration telemetryConfiguration = new com . microsoft . applicationinsights . TelemetryConfiguration ( ) ; final Map < String , String > channelProperties = new HashMap < > ( ) ; channelProperties . put ( TelemetryChannelBase . FLUSH_BUFFER_TIMEOUT_IN_SECONDS_NAME , "1" ) ; final TelemetryChannel channel = new InProcessTelemetryChannel ( channelProperties ) ; telemetryConfiguration . setChannel ( channel ) ; telemetryConfiguration . setInstrumentationKey ( readInstrumentationKeyFromConfiguration ( ) ) ; TelemetryConfigurationFactory . INSTANCE . initialize ( telemetryConfiguration ) ; return telemetryConfiguration ; } | use ai sdk to read configuration file once the issue is fixed |
31,320 | private String readInstrumentationKeyFromConfiguration ( ) { try ( final InputStream inputStream = this . getClass ( ) . getClassLoader ( ) . getResourceAsStream ( CONFIGURATION_FILE ) ) { final String configuration = IOUtils . toString ( inputStream ) ; final Matcher matcher = INSTRUMENTATION_KEY_PATTERN . matcher ( configuration ) ; if ( matcher . find ( ) ) { return matcher . group ( 1 ) ; } else { return StringUtils . EMPTY ; } } catch ( IOException exception ) { return StringUtils . EMPTY ; } } | Get instrumentation key from ApplicationInsights . xml |
31,321 | protected Map < String , FunctionConfiguration > getFunctionConfigurations ( final AnnotationHandler handler , final Set < Method > methods ) throws Exception { info ( "" ) ; info ( GENERATE_CONFIG ) ; final Map < String , FunctionConfiguration > configMap = handler . generateConfigurations ( methods ) ; if ( configMap . size ( ) == 0 ) { info ( GENERATE_SKIP ) ; } else { final String scriptFilePath = getScriptFilePath ( ) ; configMap . values ( ) . forEach ( config -> config . setScriptFile ( scriptFilePath ) ) ; info ( GENERATE_DONE ) ; } return configMap ; } | region Generate function configurations |
31,322 | protected void validateFunctionConfigurations ( final Map < String , FunctionConfiguration > configMap ) { info ( "" ) ; info ( VALIDATE_CONFIG ) ; if ( configMap . size ( ) == 0 ) { info ( VALIDATE_SKIP ) ; } else { configMap . values ( ) . forEach ( config -> config . validate ( ) ) ; info ( VALIDATE_DONE ) ; } } | region Validate function configurations |
31,323 | protected void copyJarsToStageDirectory ( ) throws IOException { final String stagingDirectory = getDeploymentStagingDirectoryPath ( ) ; info ( "" ) ; info ( COPY_JARS + stagingDirectory ) ; Utils . copyResources ( getProject ( ) , getSession ( ) , getMavenResourcesFiltering ( ) , getResources ( ) , stagingDirectory ) ; info ( COPY_SUCCESS ) ; } | region Copy Jars to stage directory |
31,324 | public String getAuthType ( ) { final AuthenticationSetting authSetting = getAuthenticationSetting ( ) ; if ( authSetting == null ) { return "AzureCLI" ; } if ( StringUtils . isNotEmpty ( authSetting . getServerId ( ) ) ) { return "ServerId" ; } if ( authSetting . getFile ( ) != null ) { return "AuthFile" ; } return "Unknown" ; } | Add AuthType ENUM and move to AzureAuthHelper . |
31,325 | public static SlidrInterface replace ( final View oldScreen , final SlidrConfig config ) { ViewGroup parent = ( ViewGroup ) oldScreen . getParent ( ) ; ViewGroup . LayoutParams params = oldScreen . getLayoutParams ( ) ; parent . removeView ( oldScreen ) ; final SliderPanel panel = new SliderPanel ( oldScreen . getContext ( ) , oldScreen , config ) ; panel . setId ( R . id . slidable_panel ) ; oldScreen . setId ( R . id . slidable_content ) ; panel . addView ( oldScreen ) ; parent . addView ( panel , 0 , params ) ; panel . setOnPanelSlideListener ( new FragmentPanelSlideListener ( oldScreen , config ) ) ; return panel . getDefaultInterface ( ) ; } | Attach a slider mechanism to a fragment view replacing an internal view |
31,326 | public static License read ( final String license ) { final String trimmedLicense = license . trim ( ) ; if ( sLicenses . containsKey ( trimmedLicense ) ) { return sLicenses . get ( trimmedLicense ) ; } else { throw new IllegalStateException ( String . format ( "no such license available: %s, did you forget to register it?" , trimmedLicense ) ) ; } } | Get a license by name |
31,327 | public final Tuple4 < T1 , T2 , T3 , T4 > limit4 ( ) { return new Tuple4 < > ( v1 , v2 , v3 , v4 ) ; } | Limit this tuple to degree 4 . |
31,328 | public final Tuple5 < T1 , T2 , T3 , T4 , T5 > limit5 ( ) { return new Tuple5 < > ( v1 , v2 , v3 , v4 , v5 ) ; } | Limit this tuple to degree 5 . |
31,329 | public final Tuple6 < T1 , T2 , T3 , T4 , T5 , T6 > limit6 ( ) { return new Tuple6 < > ( v1 , v2 , v3 , v4 , v5 , v6 ) ; } | Limit this tuple to degree 6 . |
31,330 | public final Tuple7 < T1 , T2 , T3 , T4 , T5 , T6 , T7 > limit7 ( ) { return new Tuple7 < > ( v1 , v2 , v3 , v4 , v5 , v6 , v7 ) ; } | Limit this tuple to degree 7 . |
31,331 | public final Tuple10 < T1 , T2 , T3 , T4 , T5 , T6 , T7 , T8 , T9 , T10 > limit10 ( ) { return this ; } | Limit this tuple to degree 10 . |
31,332 | public final Tuple2 < Tuple0 , Tuple6 < T1 , T2 , T3 , T4 , T5 , T6 > > split0 ( ) { return new Tuple2 < > ( limit0 ( ) , skip0 ( ) ) ; } | Split this tuple into two tuples of degree 0 and 6 . |
31,333 | public final Tuple2 < Tuple1 < T1 > , Tuple5 < T2 , T3 , T4 , T5 , T6 > > split1 ( ) { return new Tuple2 < > ( limit1 ( ) , skip1 ( ) ) ; } | Split this tuple into two tuples of degree 1 and 5 . |
31,334 | public final Tuple2 < Tuple2 < T1 , T2 > , Tuple4 < T3 , T4 , T5 , T6 > > split2 ( ) { return new Tuple2 < > ( limit2 ( ) , skip2 ( ) ) ; } | Split this tuple into two tuples of degree 2 and 4 . |
31,335 | public final Tuple2 < Tuple6 < T1 , T2 , T3 , T4 , T5 , T6 > , Tuple0 > split6 ( ) { return new Tuple2 < > ( limit6 ( ) , skip6 ( ) ) ; } | Split this tuple into two tuples of degree 6 and 0 . |
31,336 | public final Tuple2 < Tuple9 < T1 , T2 , T3 , T4 , T5 , T6 , T7 , T8 , T9 > , Tuple2 < T10 , T11 > > split9 ( ) { return new Tuple2 < > ( limit9 ( ) , skip9 ( ) ) ; } | Split this tuple into two tuples of degree 9 and 2 . |
31,337 | public final Tuple2 < Tuple7 < T1 , T2 , T3 , T4 , T5 , T6 , T7 > , Tuple6 < T8 , T9 , T10 , T11 , T12 , T13 > > split7 ( ) { return new Tuple2 < > ( limit7 ( ) , skip7 ( ) ) ; } | Split this tuple into two tuples of degree 7 and 6 . |
31,338 | public final Tuple2 < Tuple8 < T1 , T2 , T3 , T4 , T5 , T6 , T7 , T8 > , Tuple5 < T9 , T10 , T11 , T12 , T13 > > split8 ( ) { return new Tuple2 < > ( limit8 ( ) , skip8 ( ) ) ; } | Split this tuple into two tuples of degree 8 and 5 . |
31,339 | public final Tuple2 < Tuple10 < T1 , T2 , T3 , T4 , T5 , T6 , T7 , T8 , T9 , T10 > , Tuple5 < T11 , T12 , T13 , T14 , T15 > > split10 ( ) { return new Tuple2 < > ( limit10 ( ) , skip10 ( ) ) ; } | Split this tuple into two tuples of degree 10 and 5 . |
31,340 | public final Tuple2 < Tuple11 < T1 , T2 , T3 , T4 , T5 , T6 , T7 , T8 , T9 , T10 , T11 > , Tuple4 < T12 , T13 , T14 , T15 > > split11 ( ) { return new Tuple2 < > ( limit11 ( ) , skip11 ( ) ) ; } | Split this tuple into two tuples of degree 11 and 4 . |
31,341 | public final Tuple2 < Tuple12 < T1 , T2 , T3 , T4 , T5 , T6 , T7 , T8 , T9 , T10 , T11 , T12 > , Tuple3 < T13 , T14 , T15 > > split12 ( ) { return new Tuple2 < > ( limit12 ( ) , skip12 ( ) ) ; } | Split this tuple into two tuples of degree 12 and 3 . |
31,342 | public final Tuple2 < Tuple13 < T1 , T2 , T3 , T4 , T5 , T6 , T7 , T8 , T9 , T10 , T11 , T12 , T13 > , Tuple2 < T14 , T15 > > split13 ( ) { return new Tuple2 < > ( limit13 ( ) , skip13 ( ) ) ; } | Split this tuple into two tuples of degree 13 and 2 . |
31,343 | public final Tuple2 < Tuple0 , Tuple5 < T1 , T2 , T3 , T4 , T5 > > split0 ( ) { return new Tuple2 < > ( limit0 ( ) , skip0 ( ) ) ; } | Split this tuple into two tuples of degree 0 and 5 . |
31,344 | public final Tuple2 < Tuple1 < T1 > , Tuple4 < T2 , T3 , T4 , T5 > > split1 ( ) { return new Tuple2 < > ( limit1 ( ) , skip1 ( ) ) ; } | Split this tuple into two tuples of degree 1 and 4 . |
31,345 | public final Tuple2 < Tuple2 < T1 , T2 > , Tuple3 < T3 , T4 , T5 > > split2 ( ) { return new Tuple2 < > ( limit2 ( ) , skip2 ( ) ) ; } | Split this tuple into two tuples of degree 2 and 3 . |
31,346 | public final Tuple2 < Tuple5 < T1 , T2 , T3 , T4 , T5 > , Tuple0 > split5 ( ) { return new Tuple2 < > ( limit5 ( ) , skip5 ( ) ) ; } | Split this tuple into two tuples of degree 5 and 0 . |
31,347 | public final Tuple2 < Tuple2 < T1 , T2 > , Tuple10 < T3 , T4 , T5 , T6 , T7 , T8 , T9 , T10 , T11 , T12 > > split2 ( ) { return new Tuple2 < > ( limit2 ( ) , skip2 ( ) ) ; } | Split this tuple into two tuples of degree 2 and 10 . |
31,348 | public final Tuple2 < Tuple3 < T1 , T2 , T3 > , Tuple9 < T4 , T5 , T6 , T7 , T8 , T9 , T10 , T11 , T12 > > split3 ( ) { return new Tuple2 < > ( limit3 ( ) , skip3 ( ) ) ; } | Split this tuple into two tuples of degree 3 and 9 . |
31,349 | public final Tuple2 < Tuple4 < T1 , T2 , T3 , T4 > , Tuple8 < T5 , T6 , T7 , T8 , T9 , T10 , T11 , T12 > > split4 ( ) { return new Tuple2 < > ( limit4 ( ) , skip4 ( ) ) ; } | Split this tuple into two tuples of degree 4 and 8 . |
31,350 | public final Tuple2 < Tuple5 < T1 , T2 , T3 , T4 , T5 > , Tuple7 < T6 , T7 , T8 , T9 , T10 , T11 , T12 > > split5 ( ) { return new Tuple2 < > ( limit5 ( ) , skip5 ( ) ) ; } | Split this tuple into two tuples of degree 5 and 7 . |
31,351 | public final Tuple2 < Tuple6 < T1 , T2 , T3 , T4 , T5 , T6 > , Tuple6 < T7 , T8 , T9 , T10 , T11 , T12 > > split6 ( ) { return new Tuple2 < > ( limit6 ( ) , skip6 ( ) ) ; } | Split this tuple into two tuples of degree 6 and 6 . |
31,352 | public final Tuple12 < T1 , T2 , T3 , T4 , T5 , T6 , T7 , T8 , T9 , T10 , T11 , T12 > limit12 ( ) { return this ; } | Limit this tuple to degree 12 . |
31,353 | public final Tuple2 < Tuple2 < T1 , T2 > , Tuple5 < T3 , T4 , T5 , T6 , T7 > > split2 ( ) { return new Tuple2 < > ( limit2 ( ) , skip2 ( ) ) ; } | Split this tuple into two tuples of degree 2 and 5 . |
31,354 | public final Tuple2 < Tuple0 , Tuple3 < T1 , T2 , T3 > > split0 ( ) { return new Tuple2 < > ( limit0 ( ) , skip0 ( ) ) ; } | Split this tuple into two tuples of degree 0 and 3 . |
31,355 | public final Tuple2 < Tuple2 < T1 , T2 > , Tuple1 < T3 > > split2 ( ) { return new Tuple2 < > ( limit2 ( ) , skip2 ( ) ) ; } | Split this tuple into two tuples of degree 2 and 1 . |
31,356 | public final Tuple2 < Tuple3 < T1 , T2 , T3 > , Tuple0 > split3 ( ) { return new Tuple2 < > ( limit3 ( ) , skip3 ( ) ) ; } | Split this tuple into two tuples of degree 3 and 0 . |
31,357 | public final Tuple2 < Tuple0 , Tuple4 < T1 , T2 , T3 , T4 > > split0 ( ) { return new Tuple2 < > ( limit0 ( ) , skip0 ( ) ) ; } | Split this tuple into two tuples of degree 0 and 4 . |
31,358 | public final Tuple2 < Tuple1 < T1 > , Tuple3 < T2 , T3 , T4 > > split1 ( ) { return new Tuple2 < > ( limit1 ( ) , skip1 ( ) ) ; } | Split this tuple into two tuples of degree 1 and 3 . |
31,359 | public final Tuple2 < Tuple4 < T1 , T2 , T3 , T4 > , Tuple0 > split4 ( ) { return new Tuple2 < > ( limit4 ( ) , skip4 ( ) ) ; } | Split this tuple into two tuples of degree 4 and 0 . |
31,360 | public final < U4 > Tuple4 < T1 , T2 , T3 , U4 > map4 ( Function < ? super T4 , ? extends U4 > function ) { return Tuple . tuple ( v1 , v2 , v3 , function . apply ( v4 ) ) ; } | Apply attribute 4 as argument to a function and return a new tuple with the substituted argument . |
31,361 | public final Tuple4 < T13 , T14 , T15 , T16 > skip12 ( ) { return new Tuple4 < > ( v13 , v14 , v15 , v16 ) ; } | Skip 12 degrees from this tuple . |
31,362 | public final Tuple9 < T1 , T2 , T3 , T4 , T5 , T6 , T7 , T8 , T9 > limit9 ( ) { return this ; } | Limit this tuple to degree 9 . |
31,363 | public final Tuple2 < Tuple1 < T1 > , Tuple7 < T2 , T3 , T4 , T5 , T6 , T7 , T8 > > split1 ( ) { return new Tuple2 < > ( limit1 ( ) , skip1 ( ) ) ; } | Split this tuple into two tuples of degree 1 and 7 . |
31,364 | public final Tuple8 < T1 , T2 , T3 , T4 , T5 , T6 , T7 , T8 > limit8 ( ) { return this ; } | Limit this tuple to degree 8 . |
31,365 | public < K > StreamEx < T > filterBy ( Function < ? super T , ? extends K > mapper , K value ) { return value == null ? filter ( t -> mapper . apply ( t ) == null ) : filter ( t -> value . equals ( mapper . apply ( t ) ) ) ; } | Returns a stream consisting of the elements of this stream for which the supplied mapper function returns the given value . |
31,366 | @ SuppressWarnings ( "unchecked" ) public < A > A [ ] toArray ( Class < A > elementClass ) { return stream ( ) . toArray ( size -> ( A [ ] ) Array . newInstance ( elementClass , size ) ) ; } | Returns an array containing all the stream elements using the supplied element type class to allocate an array . |
31,367 | @ SuppressWarnings ( "unchecked" ) public < A > A [ ] toArray ( A [ ] emptyArray ) { if ( emptyArray . length != 0 ) { throw new IllegalArgumentException ( "Empty array must be supplied" ) ; } return stream ( ) . toArray ( size -> size == 0 ? emptyArray : ( A [ ] ) Array . newInstance ( emptyArray . getClass ( ) . getComponentType ( ) , size ) ) ; } | Returns an array containing all the stream elements . If the stream happens to contain no elements the supplied empty array is returned instead . Otherwise the new array is allocated which element type is the same as the element type of supplied empty array . |
31,368 | public < U , C extends Collection < U > > C toFlatCollection ( Function < ? super T , ? extends Collection < U > > mapper , Supplier < C > supplier ) { return map ( mapper ) . collect ( supplier , Collection :: addAll , Collection :: addAll ) ; } | Returns a collection created by provided supplier function which contains all the elements of the collections generated by provided mapper from each element of this stream . |
31,369 | public < C extends Collection < ? super T > > C into ( C collection ) { if ( isParallel ( ) ) { @ SuppressWarnings ( "unchecked" ) List < T > list = Arrays . asList ( ( T [ ] ) toArray ( ) ) ; collection . addAll ( list ) ; } else { Spliterator < T > spltr = spliterator ( ) ; if ( collection instanceof ArrayList ) { long size = spltr . getExactSizeIfKnown ( ) ; if ( size >= 0 && size < Integer . MAX_VALUE - collection . size ( ) ) ( ( ArrayList < ? > ) collection ) . ensureCapacity ( ( int ) ( collection . size ( ) + size ) ) ; } spltr . forEachRemaining ( collection :: add ) ; } return collection ; } | Drains the stream content into the supplied collection . |
31,370 | public final StreamEx < T > ifEmpty ( T ... values ) { return ifEmpty ( null , Spliterators . spliterator ( values , Spliterator . ORDERED ) ) ; } | Returns a stream which contents is the same as this stream except the case when this stream is empty . In this case its contents is replaced with supplied values . |
31,371 | public StreamEx < T > without ( T value ) { if ( value == null ) return filter ( Objects :: nonNull ) ; return remove ( value :: equals ) ; } | Returns a stream consisting of the elements of this stream that don t equal to the given value . |
31,372 | public void forPairs ( BiConsumer < ? super T , ? super T > action ) { pairMap ( ( a , b ) -> { action . accept ( a , b ) ; return null ; } ) . reduce ( null , selectFirst ( ) ) ; } | Performs an action for each adjacent pair of elements of this stream . |
31,373 | public StreamEx < T > collapse ( BiPredicate < ? super T , ? super T > collapsible ) { return collapse ( collapsible , selectFirst ( ) ) ; } | Returns a stream consisting of elements of this stream where every series of elements matched the predicate is replaced with first element from the series . |
31,374 | public StreamEx < List < T > > groupRuns ( BiPredicate < ? super T , ? super T > sameGroup ) { return collapseInternal ( sameGroup , Collections :: singletonList , ( acc , t ) -> { if ( ! ( acc instanceof ArrayList ) ) { T old = acc . get ( 0 ) ; acc = new ArrayList < > ( ) ; acc . add ( old ) ; } acc . add ( t ) ; return acc ; } , ( acc1 , acc2 ) -> { if ( ! ( acc1 instanceof ArrayList ) ) { T old = acc1 . get ( 0 ) ; acc1 = new ArrayList < > ( ) ; acc1 . add ( old ) ; } acc1 . addAll ( acc2 ) ; return acc1 ; } ) ; } | Returns a stream consisting of lists of elements of this stream where adjacent elements are grouped according to supplied predicate . |
31,375 | public < U > StreamEx < U > intervalMap ( BiPredicate < ? super T , ? super T > sameInterval , BiFunction < ? super T , ? super T , ? extends U > mapper ) { return collapseInternal ( sameInterval , PairBox :: single , ( box , t ) -> { box . b = t ; return box ; } , ( left , right ) -> { left . b = right . b ; return left ; } ) . map ( pair -> mapper . apply ( pair . a , pair . b ) ) ; } | Returns a stream consisting of results of applying the given function to the intervals created from the source elements . |
31,376 | public < R > StreamEx < R > withFirst ( BiFunction < ? super T , ? super T , ? extends R > mapper ) { WithFirstSpliterator < T , R > spliterator = new WithFirstSpliterator < > ( spliterator ( ) , mapper ) ; return new StreamEx < > ( spliterator , context ) ; } | Returns a stream consisting of the results of applying the given function to the the first element and every other element of this stream . |
31,377 | public static StreamEx < String > split ( CharSequence str , Pattern pattern ) { if ( str . length ( ) == 0 ) return of ( "" ) ; return new StreamEx < > ( pattern . splitAsStream ( str ) , StreamContext . SEQUENTIAL ) ; } | Creates a stream from the given input sequence around matches of the given pattern . |
31,378 | public static StreamEx < String > split ( CharSequence str , String regex ) { if ( str . length ( ) == 0 ) return of ( "" ) ; if ( regex . isEmpty ( ) ) { return IntStreamEx . ofChars ( str ) . mapToObj ( ch -> new String ( new char [ ] { ( char ) ch } ) ) ; } char ch = regex . charAt ( 0 ) ; if ( regex . length ( ) == 1 && ".$|()[{^?*+\\" . indexOf ( ch ) == - 1 ) { return split ( str , ch ) ; } else if ( regex . length ( ) == 2 && ch == '\\' ) { ch = regex . charAt ( 1 ) ; if ( ( ch < '0' || ch > '9' ) && ( ch < 'A' || ch > 'Z' ) && ( ch < 'a' || ch > 'z' ) && ( ch < Character . MIN_HIGH_SURROGATE || ch > Character . MAX_LOW_SURROGATE ) ) { return split ( str , ch ) ; } } return new StreamEx < > ( Pattern . compile ( regex ) . splitAsStream ( str ) , StreamContext . SEQUENTIAL ) ; } | Creates a stream from the given input sequence around matches of the given pattern represented as String . |
31,379 | public boolean put ( T t ) { if ( initial ) { if ( size == data . length ) { if ( size < limit * 2 ) { @ SuppressWarnings ( "unchecked" ) T [ ] newData = ( T [ ] ) new Object [ Math . min ( limit , size ) * 2 ] ; System . arraycopy ( data , 0 , newData , 0 , size ) ; data = newData ; } else { Arrays . sort ( data , comparator ) ; initial = false ; size = limit ; } put ( t ) ; } else { data [ size ++ ] = t ; } return true ; } if ( size == data . length ) { sortTail ( ) ; } if ( comparator . compare ( t , data [ limit - 1 ] ) < 0 ) { data [ size ++ ] = t ; return true ; } return false ; } | Accumulate new element |
31,380 | public < R > StreamEx < R > mapPartial ( Function < ? super T , ? extends Optional < ? extends R > > mapper ) { return new StreamEx < > ( stream ( ) . map ( value -> mapper . apply ( value ) . orElse ( null ) ) . filter ( Objects :: nonNull ) , context ) ; } | Performs a mapping of the stream content to a partial function removing the elements to which the function is not applicable . |
31,381 | public Optional < T > minByLong ( ToLongFunction < ? super T > keyExtractor ) { return Box . asOptional ( reduce ( null , ( ObjLongBox < T > acc , T t ) -> { long val = keyExtractor . applyAsLong ( t ) ; if ( acc == null ) return new ObjLongBox < > ( t , val ) ; if ( val < acc . b ) { acc . b = val ; acc . a = t ; } return acc ; } , ( ObjLongBox < T > acc1 , ObjLongBox < T > acc2 ) -> ( acc1 == null || acc2 != null && acc1 . b > acc2 . b ) ? acc2 : acc1 ) ) ; } | Returns the minimum element of this stream according to the long values extracted by provided function . This is a special case of a reduction . |
31,382 | public Optional < T > minByDouble ( ToDoubleFunction < ? super T > keyExtractor ) { return Box . asOptional ( reduce ( null , ( ObjDoubleBox < T > acc , T t ) -> { double val = keyExtractor . applyAsDouble ( t ) ; if ( acc == null ) return new ObjDoubleBox < > ( t , val ) ; if ( Double . compare ( val , acc . b ) < 0 ) { acc . b = val ; acc . a = t ; } return acc ; } , ( ObjDoubleBox < T > acc1 , ObjDoubleBox < T > acc2 ) -> ( acc1 == null || acc2 != null && Double . compare ( acc1 . b , acc2 . b ) > 0 ) ? acc2 : acc1 ) ) ; } | Returns the minimum element of this stream according to the double values extracted by provided function . This is a special case of a reduction . |
31,383 | public < V extends Comparable < ? super V > > Optional < T > maxBy ( Function < ? super T , ? extends V > keyExtractor ) { return Box . asOptional ( reduce ( null , ( PairBox < T , V > acc , T t ) -> { V val = keyExtractor . apply ( t ) ; if ( acc == null ) return new PairBox < > ( t , val ) ; if ( val . compareTo ( acc . b ) > 0 ) { acc . b = val ; acc . a = t ; } return acc ; } , ( PairBox < T , V > acc1 , PairBox < T , V > acc2 ) -> ( acc1 == null || acc2 != null && acc1 . b . compareTo ( acc2 . b ) < 0 ) ? acc2 : acc1 ) ) ; } | Returns the maximum element of this stream according to the natural order of the keys extracted by provided function . This is a special case of a reduction . |
31,384 | public Optional < T > maxByInt ( ToIntFunction < ? super T > keyExtractor ) { return Box . asOptional ( reduce ( null , ( ObjIntBox < T > acc , T t ) -> { int val = keyExtractor . applyAsInt ( t ) ; if ( acc == null ) return new ObjIntBox < > ( t , val ) ; if ( val > acc . b ) { acc . b = val ; acc . a = t ; } return acc ; } , ( ObjIntBox < T > acc1 , ObjIntBox < T > acc2 ) -> ( acc1 == null || acc2 != null && acc1 . b < acc2 . b ) ? acc2 : acc1 ) ) ; } | Returns the maximum element of this stream according to the int values extracted by provided function . This is a special case of a reduction . |
31,385 | public < U > U foldRight ( U seed , BiFunction < ? super T , U , U > accumulator ) { return toListAndThen ( list -> { U result = seed ; for ( int i = list . size ( ) - 1 ; i >= 0 ; i -- ) result = accumulator . apply ( list . get ( i ) , result ) ; return result ; } ) ; } | Folds the elements of this stream using the provided seed object and accumulation function going right to left . |
31,386 | public Optional < T > foldRight ( BinaryOperator < T > accumulator ) { return toListAndThen ( list -> { if ( list . isEmpty ( ) ) return Optional . empty ( ) ; int i = list . size ( ) - 1 ; T result = list . get ( i -- ) ; for ( ; i >= 0 ; i -- ) result = accumulator . apply ( list . get ( i ) , result ) ; return Optional . of ( result ) ; } ) ; } | Folds the elements of this stream using the provided accumulation function going right to left . |
31,387 | public < U > List < U > scanLeft ( U seed , BiFunction < U , ? super T , U > accumulator ) { List < U > result = new ArrayList < > ( ) ; result . add ( seed ) ; forEachOrdered ( t -> result . add ( accumulator . apply ( result . get ( result . size ( ) - 1 ) , t ) ) ) ; return result ; } | Produces a list containing cumulative results of applying the accumulation function going left to right using given seed value . |
31,388 | public List < T > scanLeft ( BinaryOperator < T > accumulator ) { List < T > result = new ArrayList < > ( ) ; forEachOrdered ( t -> { if ( result . isEmpty ( ) ) result . add ( t ) ; else result . add ( accumulator . apply ( result . get ( result . size ( ) - 1 ) , t ) ) ; } ) ; return result ; } | Produces a list containing cumulative results of applying the accumulation function going left to right . |
31,389 | @ SuppressWarnings ( "unchecked" ) public < U > List < U > scanRight ( U seed , BiFunction < ? super T , U , U > accumulator ) { return toListAndThen ( list -> { List < U > result = ( List < U > ) list ; result . add ( seed ) ; for ( int i = result . size ( ) - 2 ; i >= 0 ; i -- ) { result . set ( i , accumulator . apply ( ( T ) result . get ( i ) , result . get ( i + 1 ) ) ) ; } return result ; } ) ; } | Produces a list containing cumulative results of applying the accumulation function going right to left using given seed value . |
31,390 | public List < T > scanRight ( BinaryOperator < T > accumulator ) { return toListAndThen ( list -> { for ( int i = list . size ( ) - 2 ; i >= 0 ; i -- ) { list . set ( i , accumulator . apply ( list . get ( i ) , list . get ( i + 1 ) ) ) ; } return list ; } ) ; } | Produces a collection containing cumulative results of applying the accumulation function going right to left . |
31,391 | public S prefix ( BinaryOperator < T > op ) { Spliterator < T > spltr = spliterator ( ) ; return supply ( spltr . hasCharacteristics ( Spliterator . ORDERED ) ? new PrefixOps . OfRef < > ( spltr , op ) : new PrefixOps . OfUnordRef < T > ( spltr , op ) ) ; } | Returns a stream containing cumulative results of applying the accumulation function going left to right . |
31,392 | @ SuppressWarnings ( "unchecked" ) public < U > U chain ( Function < ? super S , U > mapper ) { return mapper . apply ( ( S ) this ) ; } | Necessary to generate proper JavaDoc |
31,393 | private R connectEmpty ( ) { synchronized ( root ) { Connector < T , R > l = left , r = right ; if ( l == null ) { return pushRight ( none ( ) , none ( ) ) ; } left = right = null ; l . rhs = null ; T laright = l . right ; l . right = none ( ) ; if ( l . acc == NONE ) { if ( r == null ) l . drain ( ) ; else { if ( l . lhs != null ) { l . lhs . right = r ; r . lhs = l . lhs ; } } return none ( ) ; } if ( r == null ) { return l . drainLeft ( ) ; } r . lhs = null ; if ( r . acc == NONE ) { if ( r . rhs != null ) { r . rhs . left = l ; l . rhs = r . rhs ; l . right = laright ; } return none ( ) ; } T raleft = r . left ; r . left = none ( ) ; if ( mergeable . test ( laright , raleft ) ) { R acc = combiner . apply ( l . acc , r . acc ) ; if ( l . left == NONE && r . right == NONE ) { l . drain ( ) ; r . drain ( ) ; return acc ; } l . acc = acc ; l . right = r . right ; if ( r . rhs != null ) { r . rhs . left = l ; l . rhs = r . rhs ; } return none ( ) ; } if ( l . left == NONE ) { if ( r . right == NONE ) right = new Connector < > ( this , r . drain ( ) , null ) ; return l . drain ( ) ; } return r . drainRight ( ) ; } } | l + r |
31,394 | public < R > StreamEx < R > mapKeyValuePartial ( BiFunction < ? super K , ? super V , ? extends Optional < ? extends R > > mapper ) { return mapPartial ( toFunction ( mapper ) ) ; } | Performs a mapping of the stream keys and values to a partial function removing the elements to which the function is not applicable . |
31,395 | public EntryStream < K , V > filterKeys ( Predicate < ? super K > keyPredicate ) { return filter ( e -> keyPredicate . test ( e . getKey ( ) ) ) ; } | Returns a stream consisting of the elements of this stream which keys match the given predicate . |
31,396 | public EntryStream < K , V > filterValues ( Predicate < ? super V > valuePredicate ) { return filter ( e -> valuePredicate . test ( e . getValue ( ) ) ) ; } | Returns a stream consisting of the elements of this stream which values match the given predicate . |
31,397 | public EntryStream < K , V > filterKeyValue ( BiPredicate < ? super K , ? super V > predicate ) { return filter ( e -> predicate . test ( e . getKey ( ) , e . getValue ( ) ) ) ; } | Returns a stream consisting of the elements of this stream which elements match the given predicate . |
31,398 | public EntryStream < K , V > removeKeys ( Predicate < ? super K > keyPredicate ) { return filterKeys ( keyPredicate . negate ( ) ) ; } | Returns a stream consisting of the elements of this stream which keys don t match the given predicate . |
31,399 | public EntryStream < K , V > peekKeys ( Consumer < ? super K > keyAction ) { return peek ( e -> keyAction . accept ( e . getKey ( ) ) ) ; } | Returns a stream consisting of the entries of this stream additionally performing the provided action on each entry key as entries are consumed from the resulting stream . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.