idx int64 0 165k | question stringlengths 73 4.15k | target stringlengths 5 918 | len_question int64 21 890 | len_target int64 3 255 |
|---|---|---|---|---|
21,200 | private SortedSet < String > findIdsPerName ( final String indexName , final SortedMap < String , SortedSet < String > > names ) { if ( names . containsKey ( indexName ) ) { return names . get ( indexName ) ; } final TreeSet < String > idsPerName = new TreeSet < String > ( ) ; names . put ( indexName , idsPerName ) ; return idsPerName ; } | Find the set of IDs associated with a full name in the provided map . | 97 | 15 |
21,201 | public Set < String > getNamesPerSurname ( final String surname ) { if ( surname == null ) { return Collections . emptySet ( ) ; } if ( ! surnameIndex . containsKey ( surname ) ) { return Collections . emptySet ( ) ; } return Collections . unmodifiableSet ( surnameIndex . get ( surname ) . keySet ( ) ) ; } | Get the set of full names that occur for a given surname . | 78 | 13 |
21,202 | private Map < String , SortedSet < String > > getNamesPerSurnameMap ( final String surname ) { if ( ! surnameIndex . containsKey ( surname ) ) { return Collections . emptyMap ( ) ; } return surnameIndex . get ( surname ) ; } | Get map of full names to sets of IDs for the provided surname . | 57 | 14 |
21,203 | public Set < String > getIdsPerName ( final String surname , final String name ) { if ( surname == null || name == null ) { return Collections . emptySet ( ) ; } final Map < String , SortedSet < String > > namesPerSurname = getNamesPerSurnameMap ( surname ) ; if ( ! namesPerSurname . containsKey ( name ) ) { return Collections . emptySet ( ) ; } return Collections . unmodifiableSet ( namesPerSurname . get ( name ) ) ; } | Get the set of IDs for the given surname and full name . | 115 | 13 |
21,204 | protected final LocalDate estimateFromOtherEvents ( final LocalDate localDate ) { if ( localDate != null ) { return localDate ; } final PersonAnalysisVisitor visitor = new PersonAnalysisVisitor ( ) ; person . accept ( visitor ) ; for ( final Attribute attr : visitor . getAttributes ( ) ) { final String dateString = getDate ( attr ) ; final LocalDate date = estimateFromEvent ( attr , dateString ) ; if ( date != null ) { return date ; } } return null ; } | Try other lifecycle events . | 111 | 6 |
21,205 | public Person getFather ( ) { if ( ! isSet ( ) ) { return new Person ( ) ; } final Person father = ( Person ) find ( getToString ( ) ) ; if ( father == null ) { return new Person ( ) ; } else { return father ; } } | Get the person that this object refers to . If not found return an unset Person . | 60 | 18 |
21,206 | public static PrimitiveMatrix toCorrelations ( Access2D < ? > covariances , boolean clean ) { int size = Math . toIntExact ( Math . min ( covariances . countRows ( ) , covariances . countColumns ( ) ) ) ; MatrixStore < Double > covarianceMtrx = MatrixStore . PRIMITIVE . makeWrapper ( covariances ) . get ( ) ; if ( clean ) { Eigenvalue < Double > evd = Eigenvalue . PRIMITIVE . make ( covarianceMtrx , true ) ; evd . decompose ( covarianceMtrx ) ; MatrixStore < Double > mtrxV = evd . getV ( ) ; PhysicalStore < Double > mtrxD = evd . getD ( ) . copy ( ) ; double largest = evd . getEigenvalues ( ) . get ( 0 ) . norm ( ) ; double limit = largest * size * PrimitiveMath . RELATIVELY_SMALL ; for ( int ij = 0 ; ij < size ; ij ++ ) { if ( mtrxD . doubleValue ( ij , ij ) < limit ) { mtrxD . set ( ij , ij , limit ) ; } } covarianceMtrx = mtrxV . multiply ( mtrxD ) . multiply ( mtrxV . transpose ( ) ) ; } PrimitiveMatrix . DenseReceiver retVal = PrimitiveMatrix . FACTORY . makeDense ( size , size ) ; double [ ] volatilities = new double [ size ] ; for ( int ij = 0 ; ij < size ; ij ++ ) { volatilities [ ij ] = PrimitiveMath . SQRT . invoke ( covarianceMtrx . doubleValue ( ij , ij ) ) ; } for ( int j = 0 ; j < size ; j ++ ) { double colVol = volatilities [ j ] ; retVal . set ( j , j , PrimitiveMath . ONE ) ; for ( int i = j + 1 ; i < size ; i ++ ) { double rowVol = volatilities [ i ] ; if ( ( rowVol <= PrimitiveMath . ZERO ) || ( colVol <= PrimitiveMath . ZERO ) ) { retVal . set ( i , j , PrimitiveMath . ZERO ) ; retVal . set ( j , i , PrimitiveMath . ZERO ) ; } else { double covariance = covarianceMtrx . doubleValue ( i , j ) ; double correlation = covariance / ( rowVol * colVol ) ; retVal . set ( i , j , correlation ) ; retVal . set ( j , i , correlation ) ; } } } return retVal . get ( ) ; } | Will extract the correlation coefficients from the input covariance matrix . If cleaning is enabled small and negative eigenvalues of the covariance matrix will be replaced with a new minimal value . | 604 | 36 |
21,207 | static ResourceLocator . Request buildChallengeRequest ( ResourceLocator . Session session , String symbol ) { // The "options" part causes the cookie to be set. // Other path endings may also work, // but there has to be something after the symbol return session . request ( ) . host ( FINANCE_YAHOO_COM ) . path ( "/quote/" + symbol + "/options" ) ; } | A request that requires consent and will set the B cookie but not the crumb | 86 | 16 |
21,208 | @ Override protected PrimitiveMatrix calculateAssetWeights ( ) { if ( this . getOptimisationOptions ( ) . logger_appender != null ) { BasicLogger . debug ( ) ; BasicLogger . debug ( "###################################################" ) ; BasicLogger . debug ( "BEGIN RAF: {} MarkowitzModel optimisation" , this . getRiskAversion ( ) ) ; BasicLogger . debug ( "###################################################" ) ; BasicLogger . debug ( ) ; } Optimisation . Result tmpResult ; if ( ( myTargetReturn != null ) || ( myTargetVariance != null ) ) { final double tmpTargetValue ; if ( myTargetVariance != null ) { tmpTargetValue = myTargetVariance . doubleValue ( ) ; } else if ( myTargetReturn != null ) { tmpTargetValue = myTargetReturn . doubleValue ( ) ; } else { tmpTargetValue = _0_0 ; } tmpResult = this . generateOptimisationModel ( _0_0 ) . minimise ( ) ; double tmpTargetNow = _0_0 ; double tmpTargetDiff = _0_0 ; double tmpTargetLast = _0_0 ; if ( tmpResult . getState ( ) . isFeasible ( ) ) { double tmpCurrent ; double tmpLow ; double tmpHigh ; if ( this . isDefaultRiskAversion ( ) ) { tmpCurrent = INIT ; tmpLow = MAX ; tmpHigh = MIN ; } else { tmpCurrent = this . getRiskAversion ( ) . doubleValue ( ) ; tmpLow = tmpCurrent * INIT ; tmpHigh = tmpCurrent / INIT ; } do { final ExpressionsBasedModel tmpModel = this . generateOptimisationModel ( tmpCurrent ) ; tmpResult = tmpModel . minimise ( ) ; tmpTargetLast = tmpTargetNow ; if ( myTargetVariance != null ) { tmpTargetNow = this . calculatePortfolioVariance ( tmpResult ) . doubleValue ( ) ; } else if ( myTargetReturn != null ) { tmpTargetNow = this . calculatePortfolioReturn ( tmpResult , this . calculateAssetReturns ( ) ) . doubleValue ( ) ; } else { tmpTargetNow = tmpTargetValue ; } tmpTargetDiff = tmpTargetNow - tmpTargetValue ; if ( this . getOptimisationOptions ( ) . logger_appender != null ) { BasicLogger . debug ( ) ; BasicLogger . debug ( "RAF: {}" , tmpCurrent ) ; BasicLogger . debug ( "Last: {}" , tmpTargetLast ) ; BasicLogger . debug ( "Now: {}" , tmpTargetNow ) ; BasicLogger . debug ( "Target: {}" , tmpTargetValue ) ; BasicLogger . debug ( "Diff: {}" , tmpTargetDiff ) ; BasicLogger . debug ( "Iteration: {}" , tmpResult ) ; BasicLogger . debug ( ) ; } if ( tmpTargetDiff < _0_0 ) { tmpLow = tmpCurrent ; } else if ( tmpTargetDiff > _0_0 ) { tmpHigh = tmpCurrent ; } tmpCurrent = PrimitiveMath . SQRT . invoke ( tmpLow * tmpHigh ) ; } while ( ! TARGET_CONTEXT . isSmall ( tmpTargetValue , tmpTargetDiff ) && TARGET_CONTEXT . isDifferent ( tmpHigh , tmpLow ) ) ; } } else { tmpResult = this . generateOptimisationModel ( this . getRiskAversion ( ) . doubleValue ( ) ) . minimise ( ) ; } return this . handle ( tmpResult ) ; } | Constrained optimisation . | 771 | 6 |
21,209 | public static Scalar < ? > calculatePortfolioReturn ( final PrimitiveMatrix assetWeights , final PrimitiveMatrix assetReturns ) { return PrimitiveScalar . valueOf ( assetWeights . dot ( assetReturns ) ) ; } | Calculates the portfolio return using the input asset weights and returns . | 50 | 14 |
21,210 | public PrimitiveMatrix calculateAssetReturns ( final PrimitiveMatrix assetWeights ) { final PrimitiveMatrix tmpAssetWeights = myRiskAversion . compareTo ( DEFAULT_RISK_AVERSION ) == 0 ? assetWeights : assetWeights . multiply ( myRiskAversion ) ; return myCovariances . multiply ( tmpAssetWeights ) ; } | If the input vector of asset weights are the weights of the market portfolio then the ouput is the equilibrium excess returns . | 82 | 25 |
21,211 | public PrimitiveMatrix calculateAssetWeights ( final PrimitiveMatrix assetReturns ) { final PrimitiveMatrix tmpAssetWeights = myCovariances . solve ( assetReturns ) ; if ( myRiskAversion . compareTo ( DEFAULT_RISK_AVERSION ) == 0 ) { return tmpAssetWeights ; } else { return tmpAssetWeights . divide ( myRiskAversion ) ; } } | If the input vector of returns are the equilibrium excess returns then the output is the market portfolio weights . This is unconstrained optimisation - there are no constraints on the resulting instrument weights . | 90 | 38 |
21,212 | public Scalar < ? > calculatePortfolioVariance ( final PrimitiveMatrix assetWeights ) { PrimitiveMatrix tmpLeft ; PrimitiveMatrix tmpRight ; if ( assetWeights . countColumns ( ) == 1L ) { tmpLeft = assetWeights . transpose ( ) ; tmpRight = assetWeights ; } else { tmpLeft = assetWeights ; tmpRight = assetWeights . transpose ( ) ; } return tmpLeft . multiply ( myCovariances . multiply ( tmpRight ) ) . toScalar ( 0 , 0 ) ; } | Calculates the portfolio variance using the input instrument weights . | 121 | 12 |
21,213 | public MarketEquilibrium clean ( ) { final PrimitiveMatrix tmpAssetVolatilities = FinanceUtils . toVolatilities ( myCovariances , true ) ; final PrimitiveMatrix tmpCleanedCorrelations = FinanceUtils . toCorrelations ( myCovariances , true ) ; final PrimitiveMatrix tmpCovariances = FinanceUtils . toCovariances ( tmpAssetVolatilities , tmpCleanedCorrelations ) ; return new MarketEquilibrium ( myAssetKeys , tmpCovariances , myRiskAversion ) ; } | Equivalent to copying but additionally the covariance matrix will be cleaned of negative and very small eigenvalues to make it positive definite . | 120 | 27 |
21,214 | protected PrimitiveMatrix getViewReturns ( ) { final int tmpRowDim = myViews . size ( ) ; final int tmpColDim = 1 ; final PrimitiveMatrix . DenseReceiver retVal = MATRIX_FACTORY . makeDense ( tmpRowDim , tmpColDim ) ; double tmpRet ; final double tmpRAF = this . getRiskAversion ( ) . doubleValue ( ) ; for ( int i = 0 ; i < tmpRowDim ; i ++ ) { tmpRet = myViews . get ( i ) . getMeanReturn ( ) ; retVal . set ( i , 0 , PrimitiveMath . DIVIDE . invoke ( tmpRet , tmpRAF ) ) ; } return retVal . build ( ) ; } | Scaled by risk aversion factor . | 164 | 7 |
21,215 | public User initialize ( String authCode , String redirectUri ) throws WorkspaceApiException { return initialize ( authCode , redirectUri , null , null ) ; } | Initialize the API using the provided authorization code and redirect URI . The authorization code comes from using the Authorization Code Grant flow to authenticate with the Authentication API . | 36 | 32 |
21,216 | public User initialize ( String token ) throws WorkspaceApiException { return initialize ( null , null , null , token ) ; } | Initialize the API using the provided access token . | 27 | 10 |
21,217 | public void destroy ( long disconnectRequestTimeout ) throws WorkspaceApiException { try { if ( this . workspaceInitialized ) { notifications . disconnect ( disconnectRequestTimeout ) ; sessionApi . logout ( ) ; } } catch ( Exception e ) { throw new WorkspaceApiException ( "destroy failed." , e ) ; } finally { this . workspaceInitialized = false ; } } | Ends the current agent s session . This request logs out the agent on all activated channels ends the HTTP session and cleans up related resources . After you end the session you ll need to make a login request before making any new calls to the API . | 80 | 50 |
21,218 | public void setAgentReady ( KeyValueCollection reasons , KeyValueCollection extensions ) throws WorkspaceApiException { try { VoicereadyData readyData = new VoicereadyData ( ) ; readyData . setReasons ( Util . toKVList ( reasons ) ) ; readyData . setExtensions ( Util . toKVList ( extensions ) ) ; ReadyData data = new ReadyData ( ) ; data . data ( readyData ) ; ApiSuccessResponse response = this . voiceApi . setAgentStateReady ( data ) ; throwIfNotOk ( "setAgentReady" , response ) ; } catch ( ApiException e ) { throw new WorkspaceApiException ( "setAgentReady failed." , e ) ; } } | Set the current agent s state to Ready on the voice channel . | 157 | 13 |
21,219 | public void dndOn ( ) throws WorkspaceApiException { try { ApiSuccessResponse response = this . voiceApi . setDNDOn ( null ) ; throwIfNotOk ( "dndOn" , response ) ; } catch ( ApiException e ) { throw new WorkspaceApiException ( "dndOn failed." , e ) ; } } | Set the current agent s state to Do Not Disturb on the voice channel . | 79 | 16 |
21,220 | public void dndOff ( ) throws WorkspaceApiException { try { ApiSuccessResponse response = this . voiceApi . setDNDOff ( null ) ; throwIfNotOk ( "dndOff" , response ) ; } catch ( ApiException e ) { throw new WorkspaceApiException ( "dndOff failed." , e ) ; } } | Turn off Do Not Disturb for the current agent on the voice channel . | 79 | 15 |
21,221 | public void setForward ( String destination ) throws WorkspaceApiException { try { VoicesetforwardData forwardData = new VoicesetforwardData ( ) ; forwardData . setForwardTo ( destination ) ; ForwardData data = new ForwardData ( ) ; data . data ( forwardData ) ; ApiSuccessResponse response = this . voiceApi . forward ( data ) ; throwIfNotOk ( "setForward" , response ) ; } catch ( ApiException e ) { throw new WorkspaceApiException ( "setForward failed." , e ) ; } } | Set call forwarding on the current agent s DN to the specified destination . | 118 | 14 |
21,222 | public void cancelForward ( ) throws WorkspaceApiException { try { ApiSuccessResponse response = this . voiceApi . cancelForward ( null ) ; throwIfNotOk ( "cancelForward" , response ) ; } catch ( ApiException e ) { throw new WorkspaceApiException ( "cancelForward failed." , e ) ; } } | Cancel call forwarding for the current agent . | 76 | 9 |
21,223 | public void answerCall ( String connId , KeyValueCollection reasons , KeyValueCollection extensions ) throws WorkspaceApiException { try { VoicecallsidanswerData answerData = new VoicecallsidanswerData ( ) ; answerData . setReasons ( Util . toKVList ( reasons ) ) ; answerData . setExtensions ( Util . toKVList ( extensions ) ) ; AnswerData data = new AnswerData ( ) ; data . setData ( answerData ) ; ApiSuccessResponse response = this . voiceApi . answer ( connId , data ) ; throwIfNotOk ( "answerCall" , response ) ; } catch ( ApiException e ) { throw new WorkspaceApiException ( "answerCall failed." , e ) ; } } | Answer the specified call . | 165 | 5 |
21,224 | public void holdCall ( String connId , KeyValueCollection reasons , KeyValueCollection extensions ) throws WorkspaceApiException { try { VoicecallsidanswerData holdData = new VoicecallsidanswerData ( ) ; holdData . setReasons ( Util . toKVList ( reasons ) ) ; holdData . setExtensions ( Util . toKVList ( extensions ) ) ; HoldData data = new HoldData ( ) ; data . data ( holdData ) ; ApiSuccessResponse response = this . voiceApi . hold ( connId , data ) ; throwIfNotOk ( "holdCall" , response ) ; } catch ( ApiException e ) { throw new WorkspaceApiException ( "holdCall failed." , e ) ; } } | Place the specified call on hold . | 164 | 7 |
21,225 | public void retrieveCall ( String connId , KeyValueCollection reasons , KeyValueCollection extensions ) throws WorkspaceApiException { try { VoicecallsidanswerData retrieveData = new VoicecallsidanswerData ( ) ; retrieveData . setReasons ( Util . toKVList ( reasons ) ) ; retrieveData . setExtensions ( Util . toKVList ( extensions ) ) ; RetrieveData data = new RetrieveData ( ) ; data . data ( retrieveData ) ; ApiSuccessResponse response = this . voiceApi . retrieve ( connId , data ) ; throwIfNotOk ( "retrieveCall" , response ) ; } catch ( ApiException e ) { throw new WorkspaceApiException ( "retrieveCall failed." , e ) ; } } | Retrieve the specified call from hold . | 168 | 8 |
21,226 | public void releaseCall ( String connId , KeyValueCollection reasons , KeyValueCollection extensions ) throws WorkspaceApiException { try { VoicecallsidanswerData releaseData = new VoicecallsidanswerData ( ) ; releaseData . setReasons ( Util . toKVList ( reasons ) ) ; releaseData . setExtensions ( Util . toKVList ( extensions ) ) ; ReleaseData data = new ReleaseData ( ) ; data . data ( releaseData ) ; ApiSuccessResponse response = this . voiceApi . release ( connId , data ) ; throwIfNotOk ( "releaseCall" , response ) ; } catch ( ApiException e ) { throw new WorkspaceApiException ( "releaseCall failed." , e ) ; } } | Release the specified call . | 164 | 5 |
21,227 | public void initiateConference ( String connId , String destination , String location , String outboundCallerId , KeyValueCollection userData , KeyValueCollection reasons , KeyValueCollection extensions ) throws WorkspaceApiException { try { VoicecallsidinitiateconferenceData initData = new VoicecallsidinitiateconferenceData ( ) ; initData . setDestination ( destination ) ; initData . setLocation ( location ) ; initData . setOutboundCallerId ( outboundCallerId ) ; initData . setUserData ( Util . toKVList ( userData ) ) ; initData . setReasons ( Util . toKVList ( reasons ) ) ; initData . setExtensions ( Util . toKVList ( extensions ) ) ; InitiateConferenceData data = new InitiateConferenceData ( ) ; data . data ( initData ) ; ApiSuccessResponse response = this . voiceApi . initiateConference ( connId , data ) ; throwIfNotOk ( "initiateConference" , response ) ; } catch ( ApiException e ) { throw new WorkspaceApiException ( "initiateConference failed." , e ) ; } } | Initiate a two - step conference to the specified destination . This places the existing call on hold and creates a new call in the dialing state . After initiating the conference you can use completeConference to complete the conference and bring all parties into the same call . | 260 | 54 |
21,228 | public void completeConference ( String connId , String parentConnId ) throws WorkspaceApiException { this . completeConference ( connId , parentConnId , null , null ) ; } | Complete a previously initiated two - step conference identified by the provided IDs . Once completed the two separate calls are brought together so that all three parties are participating in the same call . | 41 | 35 |
21,229 | public void attachUserData ( String connId , KeyValueCollection userData ) throws WorkspaceApiException { try { VoicecallsidcompleteData completeData = new VoicecallsidcompleteData ( ) ; completeData . setUserData ( Util . toKVList ( userData ) ) ; UserDataOperationId data = new UserDataOperationId ( ) ; data . data ( completeData ) ; ApiSuccessResponse response = this . voiceApi . attachUserData ( connId , data ) ; throwIfNotOk ( "attachUserData" , response ) ; } catch ( ApiException e ) { throw new WorkspaceApiException ( "attachUserData failed." , e ) ; } } | Attach the provided data to the call . This adds the data to the call even if data already exists with the provided keys . | 151 | 25 |
21,230 | public void deleteUserDataPair ( String connId , String key ) throws WorkspaceApiException { try { VoicecallsiddeleteuserdatapairData deletePairData = new VoicecallsiddeleteuserdatapairData ( ) ; deletePairData . setKey ( key ) ; KeyData data = new KeyData ( ) ; data . data ( deletePairData ) ; ApiSuccessResponse response = this . voiceApi . deleteUserDataPair ( connId , data ) ; throwIfNotOk ( "deleteUserDataPair" , response ) ; } catch ( ApiException e ) { throw new WorkspaceApiException ( "deleteUserDataPair failed." , e ) ; } } | Delete data with the specified key from the call s user data . | 157 | 13 |
21,231 | public void redirectCall ( String connId , String destination ) throws WorkspaceApiException { this . redirectCall ( connId , destination , null , null ) ; } | Redirect a call to the specified destination . | 35 | 9 |
21,232 | public void redirectCall ( String connId , String destination , KeyValueCollection reasons , KeyValueCollection extensions ) throws WorkspaceApiException { try { VoicecallsidredirectData redirectData = new VoicecallsidredirectData ( ) ; redirectData . setDestination ( destination ) ; redirectData . setReasons ( Util . toKVList ( reasons ) ) ; redirectData . setExtensions ( Util . toKVList ( extensions ) ) ; RedirectData data = new RedirectData ( ) ; data . data ( redirectData ) ; ApiSuccessResponse response = this . voiceApi . redirect ( connId , data ) ; throwIfNotOk ( "redirectCall" , response ) ; } catch ( ApiException e ) { throw new WorkspaceApiException ( "redirectCall failed." , e ) ; } } | Redirect a call to the specified destination | 183 | 8 |
21,233 | public void clearCall ( String connId , KeyValueCollection reasons , KeyValueCollection extensions ) throws WorkspaceApiException { try { VoicecallsidanswerData clearData = new VoicecallsidanswerData ( ) ; clearData . setReasons ( Util . toKVList ( reasons ) ) ; clearData . setExtensions ( Util . toKVList ( extensions ) ) ; ClearData data = new ClearData ( ) ; data . data ( clearData ) ; ApiSuccessResponse response = this . voiceApi . clear ( connId , data ) ; throwIfNotOk ( "clearCall" , response ) ; } catch ( ApiException e ) { throw new WorkspaceApiException ( "clearCall failed." , e ) ; } } | End the conference call for all parties . This can be performed by any agent participating in the conference . | 164 | 20 |
21,234 | public ApiResponse < CurrentSession > getCurrentSessionWithHttpInfo ( ) throws ApiException { com . squareup . okhttp . Call call = getCurrentSessionValidateBeforeCall ( null , null ) ; Type localVarReturnType = new TypeToken < CurrentSession > ( ) { } . getType ( ) ; return apiClient . execute ( call , localVarReturnType ) ; } | Get information about the current user Get information about the current user including any existing media logins calls and interactions . The returned user information includes state recovery information about the active session . You can make this request at startup to check for an existing session . | 83 | 49 |
21,235 | public ApiResponse < CurrentSession > getUserInfoWithHttpInfo ( ) throws ApiException { com . squareup . okhttp . Call call = getUserInfoValidateBeforeCall ( null , null ) ; Type localVarReturnType = new TypeToken < CurrentSession > ( ) { } . getType ( ) ; return apiClient . execute ( call , localVarReturnType ) ; } | Retrieve encrypted data about the current user This request can be used to retrieve encrypted data about the user to use with other services | 83 | 25 |
21,236 | public List < StatisticValue > peek ( String subscriptionId ) throws WorkspaceApiException { try { InlineResponse2002 resp = api . peek ( subscriptionId ) ; Util . throwIfNotOk ( resp . getStatus ( ) ) ; InlineResponse2002Data data = resp . getData ( ) ; if ( data == null ) { throw new WorkspaceApiException ( "Response data is empty" ) ; } return data . getStatistics ( ) ; } catch ( ApiException ex ) { throw new WorkspaceApiException ( "Cannot peek" , ex ) ; } } | Get the statistics for the specified subscription ID . | 126 | 9 |
21,237 | public void unsubscribe ( String subscriptionId ) throws WorkspaceApiException { try { ApiSuccessResponse resp = api . unsubscribe ( subscriptionId ) ; Util . throwIfNotOk ( resp ) ; } catch ( ApiException ex ) { throw new WorkspaceApiException ( "Cannot unsubscribe" , ex ) ; } } | Unsubscribe from the specified group of statistics . | 73 | 10 |
21,238 | public ApiResponse < ApiSuccessResponse > ackRecentMissedCallsWithHttpInfo ( ) throws ApiException { com . squareup . okhttp . Call call = ackRecentMissedCallsValidateBeforeCall ( null , null ) ; Type localVarReturnType = new TypeToken < ApiSuccessResponse > ( ) { } . getType ( ) ; return apiClient . execute ( call , localVarReturnType ) ; } | Acknowledge missed calls Acknowledge missed calls in the list of recent targets . | 95 | 17 |
21,239 | public ApiResponse < Void > swaggerDocWithHttpInfo ( ) throws ApiException { com . squareup . okhttp . Call call = swaggerDocValidateBeforeCall ( null , null ) ; return apiClient . execute ( call ) ; } | Returns API description in Swagger format Returns API description in Swagger format | 54 | 14 |
21,240 | public ApiResponse < Info > versionInfoWithHttpInfo ( ) throws ApiException { com . squareup . okhttp . Call call = versionInfoValidateBeforeCall ( null , null ) ; Type localVarReturnType = new TypeToken < Info > ( ) { } . getType ( ) ; return apiClient . execute ( call , localVarReturnType ) ; } | Returns version information Returns version information | 79 | 6 |
21,241 | public ApiResponse < Void > notificationsWithHttpInfo ( ) throws ApiException { com . squareup . okhttp . Call call = notificationsValidateBeforeCall ( null , null ) ; return apiClient . execute ( call ) ; } | CometD endpoint Subscribe to the CometD notification API . | 50 | 12 |
21,242 | public SearchResult < Target > search ( String searchTerm , TargetsSearchOptions options ) throws WorkspaceApiException { try { String types = null ; List < String > typesArray = null ; if ( options . getTypes ( ) != null ) { typesArray = new ArrayList <> ( 10 ) ; for ( TargetType targetType : options . getTypes ( ) ) { typesArray . add ( targetType . getValue ( ) ) ; } types = StringUtil . join ( typesArray . toArray ( new String [ typesArray . size ( ) ] ) , "," ) ; } String excludeGroups = options . getExcludeGroups ( ) != null ? StringUtil . join ( options . getExcludeGroups ( ) , "," ) : null ; String restrictGroups = options . getRestrictGroups ( ) != null ? StringUtil . join ( options . getRestrictGroups ( ) , "," ) : null ; String excludeFromGroups = options . getExcludeFromGroups ( ) != null ? StringUtil . join ( options . getExcludeFromGroups ( ) , "," ) : null ; String restrictToGroups = options . getRestrictToGroups ( ) != null ? StringUtil . join ( options . getRestrictToGroups ( ) , "," ) : null ; TargetsResponse response = this . targetsApi . getTargets ( searchTerm , options . getFilterName ( ) , types , excludeGroups , restrictGroups , excludeFromGroups , restrictToGroups , options . isDesc ( ) ? "desc" : null , options . getLimit ( ) < 1 ? null : new BigDecimal ( options . getLimit ( ) ) , options . isExact ( ) ? "exact" : null ) ; TargetsResponseData data = response . getData ( ) ; List < Target > targets = new ArrayList <> ( ) ; if ( data . getTargets ( ) != null ) { for ( com . genesys . internal . workspace . model . Target t : data . getTargets ( ) ) { Target target = Target . fromTarget ( t ) ; targets . add ( target ) ; } } return new SearchResult <> ( data . getTotalMatches ( ) , targets ) ; } catch ( ApiException e ) { throw new WorkspaceApiException ( "searchTargets failed." , e ) ; } } | Search for targets by the specified search term . | 524 | 9 |
21,243 | public Target getTarget ( long id , TargetType type ) throws WorkspaceApiException { try { TargetsResponse resp = targetsApi . getTarget ( new BigDecimal ( id ) , type . getValue ( ) ) ; Util . throwIfNotOk ( resp . getStatus ( ) ) ; Target target = null ; if ( resp . getData ( ) != null ) { List < com . genesys . internal . workspace . model . Target > targets = resp . getData ( ) . getTargets ( ) ; if ( targets != null && targets . size ( ) > 0 ) { target = Target . fromTarget ( targets . get ( 0 ) ) ; } } return target ; } catch ( ApiException ex ) { throw new WorkspaceApiException ( "Cannot get target" , ex ) ; } } | Get a specific target by type and ID . Targets can be agents agent groups queues route points skills and custom contacts . | 177 | 24 |
21,244 | public void deletePersonalFavorite ( Target target ) throws WorkspaceApiException { try { ApiSuccessResponse resp = targetsApi . deletePersonalFavorite ( String . valueOf ( target . getId ( ) ) , target . getType ( ) . getValue ( ) ) ; Util . throwIfNotOk ( resp ) ; } catch ( ApiException ex ) { throw new WorkspaceApiException ( "Cannot delete personal favorite" , ex ) ; } } | Delete the target from the agent s personal favorites . | 99 | 10 |
21,245 | public SearchResult < Target > getPersonalFavorites ( int limit ) throws WorkspaceApiException { try { TargetsResponse resp = targetsApi . getPersonalFavorites ( limit > 0 ? new BigDecimal ( limit ) : null ) ; Util . throwIfNotOk ( resp . getStatus ( ) ) ; TargetsResponseData data = resp . getData ( ) ; int total = 0 ; List < Target > list = new ArrayList <> ( ) ; if ( data != null ) { total = data . getTotalMatches ( ) ; if ( data . getTargets ( ) != null ) { for ( com . genesys . internal . workspace . model . Target t : data . getTargets ( ) ) { Target target = Target . fromTarget ( t ) ; list . add ( target ) ; } } } return new SearchResult <> ( total , list ) ; } catch ( ApiException ex ) { throw new WorkspaceApiException ( "Cannot personal favorites" , ex ) ; } } | Get the agent s personal favorites . | 222 | 7 |
21,246 | public void savePersonalFavorite ( Target target , String category ) throws WorkspaceApiException { TargetspersonalfavoritessaveData data = new TargetspersonalfavoritessaveData ( ) ; data . setCategory ( category ) ; data . setTarget ( toInformation ( target ) ) ; PersonalFavoriteData favData = new PersonalFavoriteData ( ) ; favData . setData ( data ) ; try { ApiSuccessResponse resp = targetsApi . savePersonalFavorite ( favData ) ; Util . throwIfNotOk ( resp ) ; } catch ( ApiException ex ) { throw new WorkspaceApiException ( "Cannot save personal favorites" , ex ) ; } } | Save a target to the agent s personal favorites in the specified category . | 146 | 14 |
21,247 | public void ackRecentMissedCalls ( ) throws WorkspaceApiException { try { ApiSuccessResponse resp = targetsApi . ackRecentMissedCalls ( ) ; Util . throwIfNotOk ( resp ) ; } catch ( ApiException ex ) { throw new WorkspaceApiException ( "Cannot ack recent missed calls" , ex ) ; } } | Acknowledge missed calls in the list of recent targets . | 83 | 12 |
21,248 | public ApiResponse < InlineResponse200 > getCallsWithHttpInfo ( ) throws ApiException { com . squareup . okhttp . Call call = getCallsValidateBeforeCall ( null , null ) ; Type localVarReturnType = new TypeToken < InlineResponse200 > ( ) { } . getType ( ) ; return apiClient . execute ( call , localVarReturnType ) ; } | Get all calls Get all active calls for the current agent . | 87 | 12 |
21,249 | public ApiSuccessResponse switchToBargeIn ( String id , MonitoringScopeData monitoringScopeData ) throws ApiException { ApiResponse < ApiSuccessResponse > resp = switchToBargeInWithHttpInfo ( id , monitoringScopeData ) ; return resp . getData ( ) ; } | Switch to barge - in Switch to the barge - in monitoring mode . If the agent is currently on a call and T - Server is configured to allow barge - in the supervisor is immediately added to the call . Both the monitored agent and the customer are able to hear and speak with the supervisor . If the target agent is not on a call at the time of the request the supervisor is brought into the call when the agent receives a new call . | 62 | 92 |
21,250 | public ApiSuccessResponse switchToCoaching ( String id , MonitoringScopeData monitoringScopeData ) throws ApiException { ApiResponse < ApiSuccessResponse > resp = switchToCoachingWithHttpInfo ( id , monitoringScopeData ) ; return resp . getData ( ) ; } | Switch to coach Switch to the coach monitoring mode . When coaching is enabled and the agent receives a call the supervisor is brought into the call . Only the agent can hear the supervisor . | 60 | 36 |
21,251 | private List < DependencyError > checkAllowedSection ( final Dependencies dependencies , final Package < DependsOn > allowedPkg , final ClassInfo classInfo ) { final List < DependencyError > errors = new ArrayList < DependencyError > ( ) ; final Iterator < String > it = classInfo . getImports ( ) . iterator ( ) ; while ( it . hasNext ( ) ) { final String importedPkg = it . next ( ) ; if ( ! importedPkg . equals ( allowedPkg . getName ( ) ) && ! dependencies . isAlwaysAllowed ( importedPkg ) ) { final DependsOn dep = Utils . findAllowedByName ( allowedPkg . getDependencies ( ) , importedPkg ) ; if ( dep == null ) { errors . add ( new DependencyError ( classInfo . getName ( ) , importedPkg , allowedPkg . getComment ( ) ) ) ; } } } return errors ; } | Checks the dependencies for a package from the allowed section . | 208 | 12 |
21,252 | private static List < DependencyError > checkForbiddenSection ( final Dependencies dependencies , final Package < NotDependsOn > forbiddenPkg , final ClassInfo classInfo ) { final List < DependencyError > errors = new ArrayList < DependencyError > ( ) ; final Iterator < String > it = classInfo . getImports ( ) . iterator ( ) ; while ( it . hasNext ( ) ) { final String importedPkg = it . next ( ) ; if ( ! importedPkg . equals ( classInfo . getPackageName ( ) ) ) { final NotDependsOn ndo = Utils . findForbiddenByName ( dependencies . getAlwaysForbidden ( ) , importedPkg ) ; if ( ndo != null ) { errors . add ( new DependencyError ( classInfo . getName ( ) , importedPkg , ndo . getComment ( ) ) ) ; } else { final NotDependsOn dep = Utils . findForbiddenByName ( forbiddenPkg . getDependencies ( ) , importedPkg ) ; if ( dep != null ) { final String comment ; if ( dep . getComment ( ) == null ) { comment = forbiddenPkg . getComment ( ) ; } else { comment = dep . getComment ( ) ; } errors . add ( new DependencyError ( classInfo . getName ( ) , importedPkg , comment ) ) ; } } } } return errors ; } | Checks the dependencies for a package from the forbidden section . | 305 | 12 |
21,253 | private static String nameOnly ( final String filename ) { final int p = filename . lastIndexOf ( ' ' ) ; if ( p == - 1 ) { return filename ; } return filename . substring ( 0 , p ) ; } | Returns the name of the file without path an extension . | 49 | 11 |
21,254 | private static List < DependencyError > checkAlwaysForbiddenSection ( final Dependencies dependencies , final ClassInfo classInfo ) { final List < DependencyError > errors = new ArrayList < DependencyError > ( ) ; final Iterator < String > importedPackages = classInfo . getImports ( ) . iterator ( ) ; while ( importedPackages . hasNext ( ) ) { final String importedPackage = importedPackages . next ( ) ; final NotDependsOn ndo = Utils . findForbiddenByName ( dependencies . getAlwaysForbidden ( ) , importedPackage ) ; if ( ndo != null ) { errors . add ( new DependencyError ( classInfo . getName ( ) , importedPackage , ndo . getComment ( ) ) ) ; } } return errors ; } | Checks if any of the imports is listed in the alwaysForbidden section . | 168 | 16 |
21,255 | public final void analyze ( final File classesDir ) { final FileProcessor fileProcessor = new FileProcessor ( new FileHandler ( ) { @ Override public final FileHandlerResult handleFile ( final File classFile ) { if ( ! classFile . getName ( ) . endsWith ( ".class" ) ) { return FileHandlerResult . CONTINUE ; } try { final ClassInfo classInfo = new ClassInfo ( classFile ) ; final Package < DependsOn > allowedPkg = dependencies . findAllowedByName ( classInfo . getPackageName ( ) ) ; if ( allowedPkg == null ) { final Package < NotDependsOn > forbiddenPkg = dependencies . findForbiddenByName ( classInfo . getPackageName ( ) ) ; if ( forbiddenPkg == null ) { dependencyErrors . addAll ( checkAlwaysForbiddenSection ( dependencies , classInfo ) ) ; } else { dependencyErrors . addAll ( checkForbiddenSection ( dependencies , forbiddenPkg , classInfo ) ) ; } } else { dependencyErrors . addAll ( checkAllowedSection ( dependencies , allowedPkg , classInfo ) ) ; } } catch ( final IOException ex ) { throw new RuntimeException ( "Error handling file: " + classFile , ex ) ; } return FileHandlerResult . CONTINUE ; } } ) ; dependencyErrors . clear ( ) ; fileProcessor . process ( classesDir ) ; } | Analyze the dependencies for all classes in the directory and it s sub directories . | 302 | 16 |
21,256 | static void analyzeDir ( final Set < Class < ? > > classes , final File baseDir , final File srcDir , final boolean recursive , final ClassFilter classFilter ) { final FileProcessor fileProcessor = new FileProcessor ( new FileHandler ( ) { @ Override public final FileHandlerResult handleFile ( final File file ) { if ( file . isDirectory ( ) ) { // Directory if ( recursive ) { return FileHandlerResult . CONTINUE ; } return FileHandlerResult . SKIP_SUBDIRS ; } // File final String name = file . getName ( ) ; if ( name . endsWith ( ".java" ) && ! name . equals ( "package-info.java" ) ) { final String packageName = Utils4J . getRelativePath ( baseDir , file . getParentFile ( ) ) . replace ( File . separatorChar , ' ' ) ; final String simpleName = name . substring ( 0 , name . length ( ) - 5 ) ; final String className = packageName + "." + simpleName ; final Class < ? > clasz = classForName ( className ) ; if ( isInclude ( clasz , classFilter ) ) { classes . add ( clasz ) ; } } return FileHandlerResult . CONTINUE ; } } ) ; fileProcessor . process ( srcDir ) ; } | Populates a list of classes from a given java source directory . All source files must have a . class file in the class path . | 291 | 27 |
21,257 | static EntityManager bind ( EntityManager entityManager ) { return entityManagerMap ( true ) . put ( entityManager . getEntityManagerFactory ( ) , entityManager ) ; } | Binds the given EntityManager to the current context for its EntityManagerFactory . | 36 | 16 |
21,258 | static EntityManager unbind ( EntityManagerFactory factory ) { final Map < EntityManagerFactory , EntityManager > entityManagerMap = entityManagerMap ( false ) ; EntityManager existing = null ; if ( entityManagerMap != null ) { existing = entityManagerMap . remove ( factory ) ; doCleanup ( ) ; } return existing ; } | Unbinds the EntityManager if any currently associated with the context for the given EntityManagerFactory . | 70 | 20 |
21,259 | static void unBindAll ( Consumer < EntityManager > function ) { final Map < EntityManagerFactory , EntityManager > entityManagerMap = entityManagerMap ( false ) ; if ( entityManagerMap != null ) { Iterator < EntityManager > iterator = entityManagerMap . values ( ) . iterator ( ) ; while ( iterator . hasNext ( ) ) { EntityManager entityManager = iterator . next ( ) ; function . accept ( entityManager ) ; iterator . remove ( ) ; } doCleanup ( ) ; } } | Unbinds all EntityManagers regardless of EntityManagerFactory currently associated with the context . | 108 | 18 |
21,260 | EntityManager build ( EntityManagerContext entityManagerContext ) { ClassLoader classLoader = Thread . currentThread ( ) . getContextClassLoader ( ) ; return ( EntityManager ) Proxy . newProxyInstance ( classLoader , new Class [ ] { EntityManager . class } , new SharedEntityManagerInvocationHandler ( entityManagerContext ) ) ; } | Create an EntityManager proxy for the given EntityManagerContext . | 71 | 12 |
21,261 | public static boolean hasAnnotation ( final List < AnnotationInstance > annotations , final String annotationClaszName ) { final DotName annotationName = DotName . createSimple ( annotationClaszName ) ; for ( final AnnotationInstance annotation : annotations ) { if ( annotation . name ( ) . equals ( annotationName ) ) { return true ; } } return false ; } | Verifies if a list of annotations contains a given one . | 79 | 12 |
21,262 | public static List < MethodInfo > findOverrideMethods ( final Index index , final MethodInfo method ) { return findOverrideMethods ( index , method . declaringClass ( ) , method , 0 ) ; } | Returns a list of all methods the given one overrides . Such methods can be found in interfaces and super classes . | 41 | 23 |
21,263 | public static void setPrivateField ( final Object obj , final String name , final Object value ) { try { final Field field = obj . getClass ( ) . getDeclaredField ( name ) ; field . setAccessible ( true ) ; field . set ( obj , value ) ; } catch ( final Exception ex ) { throw new RuntimeException ( "Couldn't set field '" + name + "' in class '" + obj . getClass ( ) + "'" , ex ) ; } } | Sets a private field in an object by using reflection . | 104 | 12 |
21,264 | public static void assertCauseMessage ( final Throwable ex , final String expectedMessage ) { assertThat ( ex . getCause ( ) ) . isNotNull ( ) ; assertThat ( ex . getCause ( ) . getMessage ( ) ) . isEqualTo ( expectedMessage ) ; } | Verifies that the cause of an exception contains an expected message . | 61 | 13 |
21,265 | public static void assertCauseCauseMessage ( final Throwable ex , final String expectedMessage ) { assertThat ( ex . getCause ( ) ) . isNotNull ( ) ; assertThat ( ex . getCause ( ) . getCause ( ) ) . isNotNull ( ) ; assertThat ( ex . getCause ( ) . getCause ( ) . getMessage ( ) ) . isEqualTo ( expectedMessage ) ; } | Verifies that the cause of a cause of an exception contains an expected message . | 89 | 16 |
21,266 | public static Set < ConstraintViolation < Object > > validate ( final Object obj , final Class < ? > ... scopes ) { if ( scopes == null ) { return validator ( ) . validate ( obj , Default . class ) ; } return validator ( ) . validate ( obj , scopes ) ; } | Validates the given object by using a newly created validator . | 68 | 13 |
21,267 | public static List < File > findFilesRecursive ( final File dir , final String extension ) { final String dotExtension = "." + extension ; final List < File > files = new ArrayList <> ( ) ; final FileProcessor fileProcessor = new FileProcessor ( new FileHandler ( ) { @ Override public final FileHandlerResult handleFile ( final File file ) { // Directory if ( file . isDirectory ( ) ) { return FileHandlerResult . CONTINUE ; } // File final String name = file . getName ( ) ; if ( name . endsWith ( dotExtension ) ) { files . add ( file ) ; } return FileHandlerResult . CONTINUE ; } } ) ; fileProcessor . process ( dir ) ; return files ; } | Returns a list of files with a given extension . | 161 | 10 |
21,268 | public static final Index indexAllClasses ( final List < File > classFiles ) { final Indexer indexer = new Indexer ( ) ; indexAllClasses ( indexer , classFiles ) ; return indexer . complete ( ) ; } | Creates an index for all class files in the given list . | 51 | 13 |
21,269 | public static final void indexAllClasses ( final Indexer indexer , final List < File > classFiles ) { classFiles . forEach ( file -> { try { final InputStream in = new FileInputStream ( file ) ; try { indexer . index ( in ) ; } finally { in . close ( ) ; } } catch ( final IOException ex ) { throw new RuntimeException ( ex ) ; } } ) ; } | Index all class files in the given list . | 90 | 9 |
21,270 | public static ClassInfo classInfo ( final ClassLoader cl , final Class < ? > clasz ) { return classInfo ( cl , clasz . getName ( ) ) ; } | Loads a class and creates a Jandex class information for it . | 39 | 15 |
21,271 | public static ClassInfo classInfo ( final ClassLoader cl , final String className ) { final Index index = index ( cl , className ) ; return index . getClassByName ( DotName . createSimple ( className ) ) ; } | Loads a class by it s name and creates a Jandex class information for it . | 50 | 19 |
21,272 | public static Index index ( final ClassLoader cl , final String className ) { final Indexer indexer = new Indexer ( ) ; index ( indexer , cl , className ) ; return indexer . complete ( ) ; } | Returns a Jandex index for a class by it s name . | 48 | 14 |
21,273 | public static void index ( final Indexer indexer , final ClassLoader cl , final String className ) { final InputStream stream = cl . getResourceAsStream ( className . replace ( ' ' , ' ' ) + ".class" ) ; try { indexer . index ( stream ) ; } catch ( final IOException ex ) { throw new RuntimeException ( ex ) ; } } | Indexes a class by it s name . | 80 | 9 |
21,274 | public static String replaceXmlAttr ( final String xml , final KV ... keyValues ) { final List < String > searchList = new ArrayList < String > ( ) ; final List < String > replacementList = new ArrayList < String > ( ) ; for ( final KV kv : keyValues ) { final String tag = kv . getKey ( ) + "=\"" ; int pa = xml . indexOf ( tag ) ; while ( pa > - 1 ) { final int s = pa + tag . length ( ) ; final int pe = xml . indexOf ( "\"" , s ) ; if ( pe > - 1 ) { final String str = xml . substring ( pa , pe + 1 ) ; searchList . add ( str ) ; final String repl = xml . substring ( pa , pa + tag . length ( ) ) + kv . getValue ( ) + "\"" ; replacementList . add ( repl ) ; } pa = xml . indexOf ( tag , s ) ; } } final String [ ] searchArray = searchList . toArray ( new String [ searchList . size ( ) ] ) ; final String [ ] replacementArray = replacementList . toArray ( new String [ replacementList . size ( ) ] ) ; return StringUtils . replaceEachRepeatedly ( xml , searchArray , replacementArray ) ; } | Replaces the content of one or more XML attributes . | 288 | 11 |
21,275 | public static boolean isExpectedType ( final Class < ? > expectedClass , final Object obj ) { final Class < ? > actualClass ; if ( obj == null ) { actualClass = null ; } else { actualClass = obj . getClass ( ) ; } return Objects . equals ( expectedClass , actualClass ) ; } | Determines if an object has an expected type in a null - safe way . | 68 | 17 |
21,276 | public static boolean isExpectedException ( final Class < ? extends Exception > expectedClass , final String expectedMessage , final Exception ex ) { if ( ! isExpectedType ( expectedClass , ex ) ) { return false ; } if ( ( expectedClass != null ) && ( expectedMessage != null ) && ( ex != null ) ) { return Objects . equals ( expectedMessage , ex . getMessage ( ) ) ; } return true ; } | Determines if an exception has an expected type and message in a null - safe way . | 91 | 19 |
21,277 | public final boolean isAlwaysAllowed ( final String packageName ) { if ( packageName . equals ( "java.lang" ) ) { return true ; } return Utils . findAllowedByName ( getAlwaysAllowed ( ) , packageName ) != null ; } | Checks if the package is always OK . | 57 | 9 |
21,278 | public final void validate ( ) throws InvalidDependenciesDefinitionException { int errorCount = 0 ; final StringBuilder sb = new StringBuilder ( "Duplicate package entries in 'allowed' and 'forbidden': " ) ; final List < Package < NotDependsOn > > list = getForbidden ( ) ; for ( int i = 0 ; i < list . size ( ) ; i ++ ) { final String name = list . get ( i ) . getName ( ) ; final Package < DependsOn > dep = new Package < DependsOn > ( name ) ; if ( getAllowed ( ) . indexOf ( dep ) > - 1 ) { if ( errorCount > 0 ) { sb . append ( ", " ) ; } sb . append ( name ) ; errorCount ++ ; } } if ( errorCount > 0 ) { throw new InvalidDependenciesDefinitionException ( this , sb . toString ( ) ) ; } } | Checks if the definition is valid - Especially if no package is in both lists . | 202 | 17 |
21,279 | public final Package < DependsOn > findAllowedByName ( final String packageName ) { final List < Package < DependsOn > > list = getAllowed ( ) ; for ( final Package < DependsOn > pkg : list ) { if ( pkg . getName ( ) . equals ( packageName ) ) { return pkg ; } } return null ; } | Find an entry in the allowed list by package name . | 80 | 11 |
21,280 | public final Package < NotDependsOn > findForbiddenByName ( final String packageName ) { final List < Package < NotDependsOn > > list = getForbidden ( ) ; for ( final Package < NotDependsOn > pkg : list ) { if ( pkg . getName ( ) . equals ( packageName ) ) { return pkg ; } } return null ; } | Find an entry in the forbidden list by package name . | 83 | 11 |
21,281 | public static XStream createXStream ( ) { final Class < ? > [ ] classes = new Class [ ] { Dependencies . class , Package . class , DependsOn . class , NotDependsOn . class , Dependency . class } ; final XStream xstream = new XStream ( ) ; XStream . setupDefaultSecurity ( xstream ) ; xstream . allowTypes ( classes ) ; xstream . alias ( "dependencies" , Dependencies . class ) ; xstream . alias ( "package" , Package . class ) ; xstream . alias ( "dependsOn" , DependsOn . class ) ; xstream . alias ( "notDependsOn" , NotDependsOn . class ) ; xstream . aliasField ( "package" , Dependency . class , "packageName" ) ; xstream . useAttributeFor ( Package . class , "name" ) ; xstream . useAttributeFor ( Package . class , "comment" ) ; xstream . useAttributeFor ( Dependency . class , "packageName" ) ; xstream . useAttributeFor ( Dependency . class , "includeSubPackages" ) ; xstream . useAttributeFor ( NotDependsOn . class , "comment" ) ; xstream . addImplicitCollection ( Package . class , "dependencies" ) ; return xstream ; } | Creates a ready configured XStream instance . | 285 | 9 |
21,282 | public static Dependencies load ( final File file ) { Utils4J . checkNotNull ( "file" , file ) ; Utils4J . checkValidFile ( file ) ; try { final InputStream inputStream = new BufferedInputStream ( new FileInputStream ( file ) ) ; try { return load ( inputStream ) ; } finally { inputStream . close ( ) ; } } catch ( final IOException ex ) { throw new RuntimeException ( ex ) ; } } | Load dependencies from a file . | 101 | 6 |
21,283 | public static Dependencies load ( final InputStream inputStream ) { Utils4J . checkNotNull ( "inputStream" , inputStream ) ; final XStream xstream = createXStream ( ) ; final Reader reader = new InputStreamReader ( inputStream ) ; return ( Dependencies ) xstream . fromXML ( reader ) ; } | Load dependencies from an input stream . | 72 | 7 |
21,284 | public static Dependencies load ( final Class < ? > clasz , final String resourcePathAndName ) { Utils4J . checkNotNull ( "clasz" , clasz ) ; Utils4J . checkNotNull ( "resourcePathAndName" , resourcePathAndName ) ; try { final URL url = clasz . getResource ( resourcePathAndName ) ; if ( url == null ) { throw new RuntimeException ( "Resource '" + resourcePathAndName + "' not found!" ) ; } final InputStream in = url . openStream ( ) ; try { return load ( in ) ; } finally { in . close ( ) ; } } catch ( final IOException ex ) { throw new RuntimeException ( ex ) ; } } | Load dependencies from a resource . | 162 | 6 |
21,285 | public static void save ( final File file , final Dependencies dependencies ) { Utils4J . checkNotNull ( "file" , file ) ; Utils4J . checkValidFile ( file ) ; final XStream xstream = createXStream ( ) ; try { final Writer writer = new FileWriter ( file ) ; try { xstream . toXML ( dependencies , writer ) ; } finally { writer . close ( ) ; } } catch ( final IOException ex ) { throw new RuntimeException ( ex ) ; } } | Write the dependencies to a file . | 111 | 7 |
21,286 | public final void findCallingMethodsInJar ( final File file ) throws IOException { try ( final JarFile jarFile = new JarFile ( file ) ) { final Enumeration < JarEntry > entries = jarFile . entries ( ) ; while ( entries . hasMoreElements ( ) ) { final JarEntry entry = entries . nextElement ( ) ; if ( entry . getName ( ) . endsWith ( ".class" ) ) { final InputStream in = new BufferedInputStream ( jarFile . getInputStream ( entry ) , 1024 ) ; try { new ClassReader ( in ) . accept ( cv , 0 ) ; } finally { in . close ( ) ; } } } } } | Locate method calls in classes of a JAR file . | 147 | 12 |
21,287 | public final void findCallingMethodsInDir ( final File dir , final FileFilter filter ) { final FileProcessor fileProcessor = new FileProcessor ( new FileHandler ( ) { @ Override public final FileHandlerResult handleFile ( final File file ) { if ( file . isDirectory ( ) ) { return FileHandlerResult . CONTINUE ; } if ( file . getName ( ) . endsWith ( ".class" ) && ( filter == null || filter . accept ( file ) ) ) { handleClass ( file ) ; } return FileHandlerResult . CONTINUE ; } } ) ; fileProcessor . process ( dir ) ; } | Locate method calls in classes of a directory . | 133 | 10 |
21,288 | public final void addCall ( final MCAMethod found , final int line ) { calls . add ( new MCAMethodCall ( found , className , methodName , methodDescr , source , line ) ) ; } | Adds the current method to the list of callers . | 48 | 11 |
21,289 | private void createDefaultExtractOperation ( ) { this . currentStreamOperation = new DStreamOperation ( this . operationIdCounter ++ ) ; this . currentStreamOperation . addStreamOperationFunction ( Ops . extract . name ( ) , s -> s ) ; } | Will create an operation named extract with a pass - thru function | 54 | 12 |
21,290 | public static File toJar ( File sourceDir , String jarName ) { if ( ! sourceDir . isAbsolute ( ) ) { throw new IllegalArgumentException ( "Source must be expressed through absolute path" ) ; } Manifest manifest = new Manifest ( ) ; manifest . getMainAttributes ( ) . put ( Attributes . Name . MANIFEST_VERSION , "1.0" ) ; File jarFile = new File ( jarName ) ; try { JarOutputStream target = new JarOutputStream ( new FileOutputStream ( jarFile ) , manifest ) ; add ( sourceDir , sourceDir . getAbsolutePath ( ) . length ( ) , target ) ; target . close ( ) ; } catch ( Exception e ) { throw new IllegalStateException ( "Failed to create JAR file '" + jarName + "' from " + sourceDir . getAbsolutePath ( ) , e ) ; } return jarFile ; } | Will create a JAR file from base dir | 195 | 9 |
21,291 | private String installConfiguration ( String configurationName , InputStream confFileInputStream ) { String outputPath ; try { File confDir = new File ( System . getProperty ( "java.io.tmpdir" ) + "/dstream_" + UUID . randomUUID ( ) ) ; confDir . mkdirs ( ) ; File executionConfig = new File ( confDir , configurationName ) ; executionConfig . deleteOnExit ( ) ; FileOutputStream confFileOs = new FileOutputStream ( executionConfig ) ; Properties configurationProperties = new Properties ( ) ; configurationProperties . load ( confFileInputStream ) ; configurationProperties . store ( confFileOs , configurationName + " configuration" ) ; this . addToClassPath ( confDir ) ; outputPath = configurationProperties . containsKey ( DStreamConstants . OUTPUT ) ? configurationProperties . getProperty ( DStreamConstants . OUTPUT ) : configurationName . split ( "\\." ) [ 0 ] + "/out" ; } catch ( Exception e ) { throw new IllegalStateException ( "Failed to generate execution config" , e ) ; } return outputPath ; } | Will generate execution configuration and add it to the classpath | 243 | 11 |
21,292 | public static < T , U , E extends Exception > BiConsumer < T , U > sneaked ( SneakyBiConsumer < T , U , E > biConsumer ) { return ( t , u ) -> { @ SuppressWarnings ( "unchecked" ) SneakyBiConsumer < T , U , RuntimeException > castedBiConsumer = ( SneakyBiConsumer < T , U , RuntimeException > ) biConsumer ; castedBiConsumer . accept ( t , u ) ; } ; } | Sneaky throws a BiConsumer lambda . | 105 | 9 |
21,293 | public static < T , U , R , E extends Exception > BiFunction < T , U , R > sneaked ( SneakyBiFunction < T , U , R , E > biFunction ) { return ( t , u ) -> { @ SuppressWarnings ( "unchecked" ) SneakyBiFunction < T , U , R , RuntimeException > castedBiFunction = ( SneakyBiFunction < T , U , R , RuntimeException > ) biFunction ; return castedBiFunction . apply ( t , u ) ; } ; } | Sneaky throws a BiFunction lambda . | 116 | 9 |
21,294 | public static < T , E extends Exception > BinaryOperator < T > sneaked ( SneakyBinaryOperator < T , E > binaryOperator ) { return ( t1 , t2 ) -> { @ SuppressWarnings ( "unchecked" ) SneakyBinaryOperator < T , RuntimeException > castedBinaryOperator = ( SneakyBinaryOperator < T , RuntimeException > ) binaryOperator ; return castedBinaryOperator . apply ( t1 , t2 ) ; } ; } | Sneaky throws a BinaryOperator lambda . | 113 | 10 |
21,295 | public static < T , U , E extends Exception > BiPredicate < T , U > sneaked ( SneakyBiPredicate < T , U , E > biPredicate ) { return ( t , u ) -> { @ SuppressWarnings ( "unchecked" ) SneakyBiPredicate < T , U , RuntimeException > castedBiPredicate = ( SneakyBiPredicate < T , U , RuntimeException > ) biPredicate ; return castedBiPredicate . test ( t , u ) ; } ; } | Sneaky throws a BiPredicate lambda . | 114 | 10 |
21,296 | public static < T , E extends Exception > Consumer < T > sneaked ( SneakyConsumer < T , E > consumer ) { return t -> { @ SuppressWarnings ( "unchecked" ) SneakyConsumer < T , RuntimeException > casedConsumer = ( SneakyConsumer < T , RuntimeException > ) consumer ; casedConsumer . accept ( t ) ; } ; } | Sneaky throws a Consumer lambda . | 81 | 8 |
21,297 | public static < T , R , E extends Exception > Function < T , R > sneaked ( SneakyFunction < T , R , E > function ) { return t -> { @ SuppressWarnings ( "unchecked" ) SneakyFunction < T , R , RuntimeException > f1 = ( SneakyFunction < T , R , RuntimeException > ) function ; return f1 . apply ( t ) ; } ; } | Sneaky throws a Function lambda . | 90 | 8 |
21,298 | public static < T , E extends Exception > Predicate < T > sneaked ( SneakyPredicate < T , E > predicate ) { return t -> { @ SuppressWarnings ( "unchecked" ) SneakyPredicate < T , RuntimeException > castedSneakyPredicate = ( SneakyPredicate < T , RuntimeException > ) predicate ; return castedSneakyPredicate . test ( t ) ; } ; } | Sneaky throws a Predicate lambda . | 94 | 9 |
21,299 | public static < E extends Exception > Runnable sneaked ( SneakyRunnable < E > runnable ) { return ( ) -> { @ SuppressWarnings ( "unchecked" ) SneakyRunnable < RuntimeException > castedRunnable = ( SneakyRunnable < RuntimeException > ) runnable ; castedRunnable . run ( ) ; } ; } | Sneaky throws a Runnable lambda . | 86 | 10 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.