signature:
public class XmlPath { /** * Add a parameter for the expression . Example :
 * < pre >
 * String type = System . console ( ) . readLine ( ) ;
 * List & lt ; Map & gt ; books = with ( Object ) . param ( " type " , type ) . get ( " shopping . category . findAll { it . @ type = = type } " ) ;
 * < / pre >
 * @ param key The name of the parameter . Just use this name in your expression as a variable
 * @ param value The value of the parameter
 * @ return New XmlPath instance with the parameter set */
public XmlPath param ( String key , Object value ) { } }

implementation: XmlPath newP = new XmlPath ( this , getXmlPathConfig ( ) ) ; if ( newP . params == null ) { newP . params = new HashMap < String , Object > ( ) ; } newP . params . put ( key , value ) ; return newP ;


signature:
public class XmlPath { /** * Peeks into the XML / HTML that XmlPath will parse by printing it to the console . You can
 * continue working with XmlPath afterwards . This is mainly for debug purposes . If you want to return a prettified version of the content
 * see { @ link # prettify ( ) } . If you want to return a prettified version of the content and also print it to the console use { @ link # prettyPrint ( ) } .
 * Note that the content is not guaranteed to be looking exactly like the it does at the source . This is because once you peek
 * the content has been downloaded and transformed into another data structure ( used by XmlPath ) and the XML is rendered
 * from this data structure .
 * @ return The same XmlPath instance */
public XmlPath peek ( ) { } }

implementation: final GPathResult result = lazyXmlParser . invoke ( ) ; final String render = XmlRenderer . render ( result ) ; System . out . println ( render ) ; return this ;


signature:
public class XmlPath { /** * Peeks into the XML / HTML that XmlPath will parse by printing it to the console in a prettified manner . You can
 * continue working with XmlPath afterwards . This is mainly for debug purposes . If you want to return a prettified version of the content
 * see { @ link # prettify ( ) } . If you want to return a prettified version of the content and also print it to the console use { @ link # prettyPrint ( ) } .
 * Note that the content is not guaranteed to be looking exactly like the it does at the source . This is because once you peek
 * the content has been downloaded and transformed into another data structure ( used by XmlPath ) and the XML is rendered
 * from this data structure .
 * @ return The same XmlPath instance */
public XmlPath prettyPeek ( ) { } }

implementation: final GPathResult result = lazyXmlParser . invoke ( ) ; final String prettify = XmlPrettifier . prettify ( result ) ; System . out . println ( prettify ) ; return this ;


signature:
public class RequestSpecBuilder { /** * Specify an Object request content that will automatically be serialized to JSON or XML and sent with the request using a specific object mapper .
 * This works for the POST , PATCH and PUT methods only . Trying to do this for the other http methods will cause an exception to be thrown .
 * @ param object The object to serialize and send with the request
 * @ param mapper The object mapper
 * @ return The request specification */
public RequestSpecBuilder setBody ( Object object , ObjectMapper mapper ) { } }

implementation: spec . body ( object , mapper ) ; return this ;


signature:
public class RequestSpecBuilder { /** * Specify an Object request content that will automatically be serialized to JSON or XML and sent with the request using a specific object mapper type .
 * This works for the POST , PATCH and PUT methods only . Trying to do this for the other http methods will cause an exception to be thrown .
 * Example of use :
 * < pre >
 * Message message = new Message ( ) ;
 * message . setMessage ( " My beautiful message " ) ;
 * given ( ) .
 * body ( message , ObjectMapper . GSON ) .
 * expect ( ) .
 * content ( equalTo ( " Response to a beautiful message " ) ) .
 * when ( ) .
 * post ( " / beautiful - message " ) ;
 * < / pre >
 * @ param object The object to serialize and send with the request
 * @ param mapperType The object mapper type to be used
 * @ return The request specification */
public RequestSpecBuilder setBody ( Object object , ObjectMapperType mapperType ) { } }

implementation: spec . body ( object , mapperType ) ; return this ;


signature:
public class RequestSpecBuilder { /** * Add a cookie to be sent with the request .
 * @ param key The cookie key
 * @ param value The cookie value
 * @ param cookieNameValuePairs Additional cookies values . This will actually create two cookies with the same name but with different values .
 * @ return The request specification builder */
public RequestSpecBuilder addCookie ( String key , Object value , Object ... cookieNameValuePairs ) { } }

implementation: spec . cookie ( key , value , cookieNameValuePairs ) ; return this ;


signature:
public class RequestSpecBuilder { /** * Add a parameter to be sent with the request .
 * @ param parameterName The parameter name
 * @ param parameterValues Zero to many parameter values for this parameter name .
 * @ return The request specification builder */
public RequestSpecBuilder addParam ( String parameterName , Object ... parameterValues ) { } }

implementation: spec . param ( parameterName , parameterValues ) ; return this ;


signature:
public class RequestSpecBuilder { /** * Add a multi - value parameter to be sent with the request .
 * @ param parameterName The parameter key
 * @ param parameterValues The parameter values
 * @ return The request specification builder */
public RequestSpecBuilder addParam ( String parameterName , Collection < ? > parameterValues ) { } }


signature:
public class RequestSpecBuilder { /** * Add a query parameter to be sent with the request . This method is the same as { @ link # addParam ( String , java . util . Collection ) }
 * for all HTTP methods except POST where this method can be used to differentiate between form and query params .
 * @ param parameterName The parameter key
 * @ param parameterValues The parameter values
 * @ return The request specification builder
 * @ see # addQueryParam ( String , Object . . . ) */
public RequestSpecBuilder addQueryParam ( String parameterName , Collection < ? > parameterValues ) { } }

implementation: spec . queryParam ( parameterName , parameterValues ) ; return this ;


signature:
public class RequestSpecBuilder { /** * Add a query parameter to be sent with the request . This method is the same as { @ link # addParam ( String , Object . . . ) } ) }
 * for all HTTP methods except POST where this method can be used to differentiate between form and query params .
 * @ param parameterName The parameter key
 * @ param parameterValues Zero to many parameter values for this parameter name .
 * @ return The request specification builder */
public RequestSpecBuilder addQueryParam ( String parameterName , Object ... parameterValues ) { } }


signature:
public class RequestSpecBuilder { /** * Add a form parameter to be sent with the request . This method is the same as { @ link # addParam ( String , java . util . Collection ) }
 * for all HTTP methods except PUT where this method can be used to differentiate between form and query params .
 * @ param parameterName The parameter key
 * @ param parameterValues The parameter values
 * @ return The request specification builder
 * @ see # addFormParam ( String , Object . . . ) */
public RequestSpecBuilder addFormParam ( String parameterName , Collection < ? > parameterValues ) { } }

implementation: spec . formParam ( parameterName , parameterValues ) ; return this ;


signature:
public class RequestSpecBuilder { /** * Add a form parameter to be sent with the request . This method is the same as { @ link # addParam ( String , Object . . . ) } ) }
 * for all HTTP methods except PUT where this method can be used to differentiate between form and query params .
 * @ param parameterName The parameter key
 * @ param parameterValues Zero to many parameter values for this parameter name .
 * @ return The request specification builder
 * @ see # addFormParam ( String , Object . . . ) */
public RequestSpecBuilder addFormParam ( String parameterName , Object ... parameterValues ) { } }


signature:
public class RequestSpecBuilder { /** * Specify a path parameter . Path parameters are used to improve readability of the request path . E . g . instead
 * of writing :
 * < pre >
 * expect ( ) . statusCode ( 200 ) . when ( ) . get ( " / item / " + myItem . getItemNumber ( ) + " / buy / " + 2 ) ;
 * < / pre >
 * you can write :
 * < pre >
 * given ( ) .
 * pathParam ( " itemNumber " , myItem . getItemNumber ( ) ) .
 * pathParam ( " amount " , 2 ) .
 * expect ( ) .
 * statusCode ( 200 ) .
 * when ( ) .
 * get ( " / item / { itemNumber } / buy / { amount } " ) ;
 * < / pre >
 * which improves readability and allows the path to be reusable in many tests . Another alternative is to use :
 * < pre >
 * expect ( ) . statusCode ( 200 ) . when ( ) . get ( " / item / { itemNumber } / buy / { amount } " , myItem . getItemNumber ( ) , 2 ) ;
 * < / pre >
 * @ param parameterName The parameter key
 * @ param parameterValue The parameter value
 * @ return The request specification */
public RequestSpecBuilder addPathParam ( String parameterName , Object parameterValue ) { } }

implementation: spec . pathParam ( parameterName , parameterValue ) ; return this ;


signature:
public class RequestSpecBuilder { /** * Specify multiple path parameter name - value pairs . Path parameters are used to improve readability of the request path . E . g . instead
 * of writing :
 * < pre >
 * expect ( ) . statusCode ( 200 ) . when ( ) . get ( " / item / " + myItem . getItemNumber ( ) + " / buy / " + 2 ) ;
 * < / pre >
 * you can write :
 * < pre >
 * given ( ) .
 * pathParam ( " itemNumber " , myItem . getItemNumber ( ) , " amount " , 2 ) .
 * expect ( ) .
 * statusCode ( 200 ) .
 * when ( ) .
 * get ( " / item / { itemNumber } / buy / { amount } " ) ;
 * < / pre >
 * which improves readability and allows the path to be reusable in many tests . Another alternative is to use :
 * < pre >
 * expect ( ) . statusCode ( 200 ) . when ( ) . get ( " / item / { itemNumber } / buy / { amount } " , myItem . getItemNumber ( ) , 2 ) ;
 * < / pre >
 * @ param firstParameterName The name of the first parameter
 * @ param firstParameterValue The value of the first parameter
 * @ param parameterNameValuePairs Additional parameters in name - value pairs .
 * @ return The request specification */
public RequestSpecBuilder addPathParams ( String firstParameterName , Object firstParameterValue , Object ... parameterNameValuePairs ) { } }

implementation: spec . pathParams ( firstParameterName , firstParameterValue , parameterNameValuePairs ) ; return this ;


signature:
public class RequestSpecBuilder { /** * Specify a keystore .
 * < pre >
 * RestAssured . keyStore ( " / truststore _ javanet . jks " , " test1234 " ) ;
 * < / pre >
 * or
 * < pre >
 * given ( ) . keyStore ( " / truststore _ javanet . jks " , " test1234 " ) . . .
 * < / pre >
 * @ param pathToJks The path to the JKS
 * @ param password The store pass */
public RequestSpecBuilder setKeyStore ( String pathToJks , String password ) { } }

implementation: spec . keyStore ( pathToJks , password ) ; return this ;


signature:
public class RequestSpecBuilder { /** * The following documentation is taken from < a href = " HTTP Builder " > https : / / github . com / jgritman / httpbuilder / wiki / SSL < / a > :
 * < h1 > SSL Configuration < / h1 >
 * SSL should , for the most part , " just work . " There are a few situations where it is not completely intuitive . You can follow the example below , or see HttpClient ' s SSLSocketFactory documentation for more information .
 * < h1 > SSLPeerUnverifiedException < / h1 >
 * If you can ' t connect to an SSL website , it is likely because the certificate chain is not trusted . This is an Apache HttpClient issue , but explained here for convenience . To correct the untrusted certificate , you need to import a certificate into an SSL truststore .
 * First , export a certificate from the website using your browser . For example , if you go to https : / / dev . java . net in Firefox , you will probably get a warning in your browser . Choose " Add Exception , " " Get Certificate , " " View , " " Details tab . " Choose a certificate in the chain and export it as a PEM file . You can view the details of the exported certificate like so :
 * < pre >
 * $ keytool - printcert - file EquifaxSecureGlobaleBusinessCA - 1 . crt
 * Owner : CN = Equifax Secure Global eBusiness CA - 1 , O = Equifax Secure Inc . , C = US
 * Issuer : CN = Equifax Secure Global eBusiness CA - 1 , O = Equifax Secure Inc . , C = US
 * Serial number : 1
 * Valid from : Mon Jun 21 00:00:00 EDT 1999 until : Sun Jun 21 00:00:00 EDT 2020
 * Certificate fingerprints :
 * MD5 : 8F : 5D : 77:06:27 : C4:98:3C : 5B : 93:78 : E7 : D7:7D : 9B : CC
 * SHA1 : 7E : 78:4A : 10:1C : 82:65 : CC : 2D : E1 : F1:6D : 47 : B4:40 : CA : D9:0A : 19:45
 * Signature algorithm name : MD5withRSA
 * Version : 3
 * < / pre >
 * Now , import that into a Java keystore file :
 * < pre >
 * $ keytool - importcert - alias " equifax - ca " - file EquifaxSecureGlobaleBusinessCA - 1 . crt - keystore truststore _ javanet . jks - storepass test1234
 * Owner : CN = Equifax Secure Global eBusiness CA - 1 , O = Equifax Secure Inc . , C = US
 * Issuer : CN = Equifax Secure Global eBusiness CA - 1 , O = Equifax Secure Inc . , C = US
 * Serial number : 1
 * Valid from : Mon Jun 21 00:00:00 EDT 1999 until : Sun Jun 21 00:00:00 EDT 2020
 * Certificate fingerprints :
 * MD5 : 8F : 5D : 77:06:27 : C4:98:3C : 5B : 93:78 : E7 : D7:7D : 9B : CC
 * SHA1 : 7E : 78:4A : 10:1C : 82:65 : CC : 2D : E1 : F1:6D : 47 : B4:40 : CA : D9:0A : 19:45
 * Signature algorithm name : MD5withRSA
 * Version : 3
 * Trust this certificate ? [ no ] : yes
 * Certificate was added to keystore
 * < / pre >
 * Now you want to use this truststore in your client :
 * < pre >
 * RestAssured . trustStore ( " / truststore _ javanet . jks " , " test1234 " ) ;
 * < / pre >
 * or
 * < pre >
 * given ( ) . trustStore ( " / truststore _ javanet . jks " , " test1234 " ) . . .
 * < / pre >
 * @ param pathToJks The path to the JKS
 * @ param password The store pass */
public RequestSpecBuilder setTrustStore ( String pathToJks , String password ) { } }

implementation: spec . trustStore ( pathToJks , password ) ; return this ;


signature:
public class RequestSpecBuilder { /** * Add a header to be sent with the request e . g :
 * @ param headerName The header name
 * @ param headerValue The header value
 * @ return The request specification builder */
public RequestSpecBuilder addHeader ( String headerName , String headerValue ) { } }

implementation: spec . header ( headerName , headerValue ) ; return this ;


signature:
public class RequestSpecBuilder { /** * Specify an inputstream to upload to the server using multi - part form data .
 * It will use the content - type < tt > application / octet - stream < / tt > . If this is not what you want please use an overloaded method .
 * @ param controlName Defines the control name of the body part . In HTML this is the attribute name of the input tag .
 * @ param fileName The name of the content you ' re uploading
 * @ param stream The stream you want to send
 * @ return The request specification */
public RequestSpecBuilder addMultiPart ( String controlName , String fileName , InputStream stream ) { } }

implementation: spec . multiPart ( controlName , fileName , stream ) ; return this ;


signature:
public class RequestSpecBuilder { /** * Specify a string to send to the server using multi - part form data .
 * It will use the content - type < tt > text / plain < / tt > . If this is not what you want please use an overloaded method .
 * @ param controlName Defines the control name of the body part . In HTML this is the attribute name of the input tag .
 * @ param contentBody The string to send
 * @ return The request specification */
public RequestSpecBuilder addMultiPart ( String controlName , String contentBody ) { } }

implementation: spec . multiPart ( controlName , contentBody ) ; return this ;


signature:
public class RequestSpecBuilder { /** * Set the session id name and value for this request . It ' ll override the default session id name from the configuration ( by default this is { @ value SessionConfig # DEFAULT _ SESSION _ ID _ NAME } ) .
 * You can configure the default session id name by using :
 * < pre >
 * RestAssured . config = newConfig ( ) . sessionConfig ( new SessionConfig ( ) . sessionIdName ( & lt ; sessionIdName & gt ; ) ) ;
 * < / pre >
 * and then you can use the { @ link RequestSpecBuilder # setSessionId ( String ) } method to set the session id value without specifying the name for each request .
 * @ param sessionIdName The session id name
 * @ param sessionIdValue The session id value .
 * @ return The request specification */
public RequestSpecBuilder setSessionId ( String sessionIdName , String sessionIdValue ) { } }

implementation: spec . sessionId ( sessionIdName , sessionIdValue ) ; return this ;


signature:
public class RequestSpecBuilder { /** * Merge this builder with settings from another specification . Note that the supplied specification
 * can overwrite data in the current specification . The following settings are overwritten :
 * < ul >
 * < li > Port < / li >
 * < li > Authentication scheme < /
 * < li > Content type < / li >
 * < li > Request body < / li >
 * < / ul >
 * The following settings are merged :
 * < ul >
 * < li > Parameters < / li >
 * < li > Cookies < / li >
 * < li > Headers < / li >
 * < li > Filters < / li >
 * < / ul >
 * @ param specification The specification to add
 * @ return The request specification builder */
public RequestSpecBuilder addRequestSpecification ( RequestSpecification specification ) { } }

implementation: if ( ! ( specification instanceof RequestSpecificationImpl ) ) { throw new IllegalArgumentException ( "Specification must be of type " + RequestSpecificationImpl . class . getClass ( ) + "." ) ; } RequestSpecificationImpl rs = ( RequestSpecificationImpl ) specification ; SpecificationMerger . merge ( ( RequestSpecificationImpl ) spec , rs ) ; return this ;


signature:
public class RequestSpecBuilder { /** * Enabled logging with the specified log detail . Set a { @ link LogConfig } to configure the print stream and pretty printing options .
 * @ param logDetail The log detail .
 * @ return RequestSpecBuilder */
public RequestSpecBuilder log ( LogDetail logDetail ) { } }

implementation: notNull ( logDetail , LogDetail . class ) ; RestAssuredConfig restAssuredConfig = spec . getConfig ( ) ; LogConfig logConfig ; if ( restAssuredConfig == null ) { logConfig = new RestAssuredConfig ( ) . getLogConfig ( ) ; } else { logConfig = restAssuredConfig . getLogConfig ( ) ; } PrintStream printStream = logConfig . defaultStream ( ) ; boolean prettyPrintingEnabled = logConfig . isPrettyPrintingEnabled ( ) ; boolean shouldUrlEncodeRequestUri = logConfig . shouldUrlEncodeRequestUri ( ) ; spec . filter ( new RequestLoggingFilter ( logDetail , prettyPrintingEnabled , printStream , shouldUrlEncodeRequestUri ) ) ; return this ;


signature:
public class RequestSpecBuilder { /** * Instruct REST Assured to connect to a proxy on the specified port on localhost with a specific scheme .
 * @ param host The hostname of the proxy to connect to ( for example < code > 127.0.0.1 < / code > )
 * @ param port The port of the proxy to connect to ( for example < code > 8888 < / code > )
 * @ param scheme The http scheme ( http or https )
 * @ return RequestSpecBuilder */
public RequestSpecBuilder setProxy ( String host , int port , String scheme ) { } }

implementation: spec . proxy ( host , port , scheme ) ; return this ;


signature:
public class MockMvcParamConfig { /** * Set form parameter update strategy to the given value .
 * @ param updateStrategy The update strategy to use for form parameters
 * @ return A new instance of { @ link MockMvcParamConfig } */
public MockMvcParamConfig formParamsUpdateStrategy ( UpdateStrategy updateStrategy ) { } }

implementation: return new MockMvcParamConfig ( queryParamsUpdateStrategy , updateStrategy , requestParameterUpdateStrategy , attributeUpdateStrategy , sessionUpdateStrategy , true ) ;


signature:
public class RestAssuredMatchers { /** * Creates a { @ link ResponseAwareMatcher } that extracts the given path from the response and
 * wraps it in a { @ link org . hamcrest . Matchers # equalTo ( Object ) } matcher . This is useful if you have a resource that e . g . returns the given JSON :
 * < pre >
 * " userId " : " my - id " ,
 * " playerId " : " my - id "
 * < / pre >
 * you can then test it like this :
 * < pre >
 * get ( " / x " ) . then ( ) . body ( " userId " , equalToPath ( " playerId " ) ) ;
 * < / pre >
 * @ param path The path to check
 * @ return A { @ link ResponseAwareMatcher } */
public static ResponseAwareMatcher < Response > equalToPath ( final String path ) { } }

implementation: return response -> equalTo ( response . path ( path ) ) ;


signature:
public class RestAssuredMatchers { /** * Creates a { @ link ResponseAwareMatcher } that extracts the given path from the response and
 * wraps it in a { @ link org . hamcrest . Matchers # equalTo ( Object ) } matcher . This is useful if you have a resource that e . g . returns the given JSON :
 * < pre >
 * " userId " : " my - id " ,
 * " href " : " http : / / localhost : 8080 / my - id "
 * < / pre >
 * you can then test it like this :
 * < pre >
 * get ( " / x " ) . then ( ) . body ( " href " , endsWithPath ( " userId " ) ) ;
 * < / pre >
 * @ param path The path to check
 * @ return A { @ link ResponseAwareMatcher } */
public static ResponseAwareMatcher < Response > endsWithPath ( final String path ) { } }

implementation: return response -> endsWith ( response . < String > path ( path ) ) ;


signature:
public class RestAssuredMatchers { /** * Creates a { @ link ResponseAwareMatcher } that extracts the given path from the response and
 * wraps it in a { @ link org . hamcrest . Matchers # equalTo ( Object ) } matcher . This is useful if you have a resource that e . g . returns the given JSON :
 * < pre >
 * " userId " : " my - id " ,
 * " baseUri " : " http : / / localhost : 8080 " ,
 * " href " : " http : / / localhost : 8080 / my - id "
 * < / pre >
 * you can then test it like this :
 * < pre >
 * get ( " / x " ) . then ( ) . body ( " href " , startsWithPath ( " baseUri " ) ) ;
 * < / pre >
 * @ param path The path to check
 * @ return A { @ link ResponseAwareMatcher } */
public static ResponseAwareMatcher < Response > startsWithPath ( final String path ) { } }

implementation: return response -> startsWith ( response . < String > path ( path ) ) ;


signature:
public class RestAssuredMatchers { /** * Creates a { @ link ResponseAwareMatcher } that extracts the given path from the response and
 * wraps it in a { @ link org . hamcrest . Matchers # equalTo ( Object ) } matcher . This is useful if you have a resource that e . g . returns the given JSON :
 * < pre >
 * " userId " : " my - id " ,
 * " href " : " http : / / localhost : 8080 / my - id "
 * < / pre >
 * you can then test it like this :
 * < pre >
 * get ( " / x " ) . then ( ) . body ( " href " , containsPath ( " userId " ) ) ;
 * < / pre >
 * @ param path The path to check
 * @ return A { @ link ResponseAwareMatcher } */
public static ResponseAwareMatcher < Response > containsPath ( final String path ) { } }

implementation: return response -> containsString ( response . < String > path ( path ) ) ;


signature:
public class ResponseLoggingFilter { /** * Create a new logging filter without using the " new " operator .
 * Will make the DSL look nicer .
 * @ param stream The print stream to log to
 * @ param matcher The matcher that must be fulfilled in order for logging to occur
 * @ return a new instance of the filter */
public static Filter logResponseToIfMatches ( PrintStream stream , Matcher < Integer > matcher ) { } }

implementation: return new ResponseLoggingFilter ( stream , matcher ) ;


signature:
public class SSLConfig { /** * Use a keystore located on the file - system . See { @ link # keyStore ( String , String ) } for more details .
 * @ param pathToJks The path to JKS file on the file - system
 * @ param password The password for the keystore
 * @ return The request specification
 * @ see # keyStore ( String , String ) */
public SSLConfig keyStore ( File pathToJks , String password ) { } }

implementation: Validate . notNull ( pathToJks , "Path to JKS on the file system cannot be null" ) ; Validate . notEmpty ( password , "Password cannot be empty" ) ; return new SSLConfig ( pathToJks , pathToTrustStore , password , trustStorePassword , keyStoreType , trustStoreType , port , keyStore , trustStore , x509HostnameVerifier , sslSocketFactory , true ) ;


signature:
public class SSLConfig { /** * Uses the user default keystore stored in & lt ; user . home & gt ; / . keystore
 * @ param password - Use null for no password
 * @ return The keystore specification */
public SSLConfig keyStore ( String password ) { } }

implementation: Validate . notEmpty ( password , "Password cannot be empty" ) ; return keyStore ( System . getProperty ( "user.home" ) + File . separatorChar + ".keystore" , password ) ;


signature:
public class SSLConfig { /** * The certificate type , will use { @ link java . security . KeyStore # getDefaultType ( ) } by default .
 * @ param keystoreType The keystore type .
 * @ return A new SSLConfig instance */
public SSLConfig keystoreType ( String keystoreType ) { } }

implementation: return new SSLConfig ( pathToKeyStore , pathToTrustStore , keyStorePassword , trustStorePassword , keystoreType , trustStoreType , port , keyStore , trustStore , x509HostnameVerifier , sslSocketFactory , true ) ;


signature:
public class SSLConfig { /** * Use relaxed HTTP validation . This means that you ' ll trust all hosts regardless if the SSL certificate is invalid . By using this
 * method you don ' t need to specify a keystore ( see { @ link # keyStore ( String , String ) } or trust store ( see { @ link # trustStore ( java . security . KeyStore ) } .
 * @ param protocol The standard name of the requested protocol . See the SSLContext section in the < a href = " https : / / docs . oracle . com / javase / 8 / docs / technotes / guides / security / StandardNames . html # SSLContext " > Java Cryptography Architecture Standard Algorithm Name Documentation < / a > for information about standard protocol names .
 * @ return A new SSLConfig instance */
public SSLConfig relaxedHTTPSValidation ( String protocol ) { } }

implementation:
AssertParameter . notNull ( protocol , "Protocol" ) ; SSLContext sslContext ; try { sslContext = SSLContext . getInstance ( protocol ) ; } catch ( NoSuchAlgorithmException e ) { return SafeExceptionRethrower . safeRethrow ( e ) ; } // Set up a TrustManager that trusts everything
try { sslContext . init ( null , new TrustManager [ ] { new X509TrustManager ( ) { public X509Certificate [ ] getAcceptedIssuers ( ) { return null ; } public void checkClientTrusted ( X509Certificate [ ] certs , String authType ) { } public void checkServerTrusted ( X509Certificate [ ] certs , String authType ) { } } } , new SecureRandom ( ) ) ; } catch ( KeyManagementException e ) { return SafeExceptionRethrower . safeRethrow ( e ) ; } SSLSocketFactory sf = new SSLSocketFactory ( sslContext , ALLOW_ALL_HOSTNAME_VERIFIER ) ; return sslSocketFactory ( sf ) ;


signature:
public class SSLConfig { /** * Specify a { @ link org . apache . http . conn . ssl . SSLSocketFactory } . This will override settings from trust store as well as keystore and password .
 * @ param sslSocketFactory The { @ link org . apache . http . conn . ssl . SSLSocketFactory } to use .
 * @ return A new SSLConfig instance */
public SSLConfig sslSocketFactory ( SSLSocketFactory sslSocketFactory ) { } }

implementation: AssertParameter . notNull ( sslSocketFactory , SSLSocketFactory . class ) ; return new SSLConfig ( pathToKeyStore , pathToTrustStore , keyStorePassword , trustStorePassword , keyStoreType , trustStoreType , port , keyStore , trustStore , x509HostnameVerifier , sslSocketFactory , true ) ;


signature:
public class Cookies { /** * Get a single cookie with the supplied name . If there are several cookies match the < code > cookieName < / code > then
 * the first one is returned .
 * @ param cookieName The name of the cookie to find
 * @ return The found cookie or < code > null < / code > if no cookie was found . */
public Cookie get ( String cookieName ) { } }

implementation: AssertParameter . notNull ( cookieName , "Cookie name" ) ; return cookies . get ( cookieName ) ;


signature:
public class Cookies { /** * Get a single cookie < i > value < / i > with the supplied name . If there are several cookies matching the < code > cookieName < / code > then
 * the first one is returned .
 * @ param cookieName The name of the cookie to find
 * @ return The found cookie or < code > null < / code > if no cookie was found . */
public String getValue ( String cookieName ) { } }

implementation: AssertParameter . notNull ( cookieName , "Cookie name" ) ; return cookies . getValue ( cookieName ) ;


signature:
public class Cookies { /** * An alternative way to create a Cookies object from the constructor .
 * @ param cookie The cookie to be included
 * @ param additionalCookies Additional cookies to be included ( optional )
 * @ return A new cookies object containing the specified cookies */
public static Cookies cookies ( Cookie cookie , Cookie ... additionalCookies ) { } }

implementation: AssertParameter . notNull ( cookie , "Cookie" ) ; final List < Cookie > cookieList = new LinkedList < Cookie > ( ) ; cookieList . add ( cookie ) ; Collections . addAll ( cookieList , additionalCookies ) ; return new Cookies ( cookieList ) ;


signature:
public class JndiIntegration { /** * Creates a provider which looks up objects in JNDI using the given name . Example usage :
 * < pre >
 * bind ( DataSource . class ) . toProvider ( fromJndi ( DataSource . class , " java : . . . " ) ) ;
 * < / pre > */
public static < T > Provider < T > fromJndi ( Class < T > type , String name ) { } }

implementation: return new JndiProvider < T > ( type , name ) ;


signature:
public class WeakKeySet { /** * There may be multiple child injectors blacklisting a certain key so only remove the source
 * that ' s relevant . */
private void cleanUpForCollectedState ( Set < KeyAndSource > keysAndSources ) { } }

implementation: synchronized ( lock ) { for ( KeyAndSource keyAndSource : keysAndSources ) { Multiset < Object > set = backingMap . get ( keyAndSource . key ) ; if ( set != null ) { set . remove ( keyAndSource . source ) ; if ( set . isEmpty ( ) ) { backingMap . remove ( keyAndSource . key ) ; } } } }


signature:
public class InjectorImpl { /** * Indexes bindings by type . */
void index ( ) { } }

implementation: for ( Binding < ? > binding : state . getExplicitBindingsThisLevel ( ) . values ( ) ) { bindingsMultimap . put ( binding . getKey ( ) . getTypeLiteral ( ) , binding ) ; }


signature:
public class InjectorImpl { /** * Returns the binding for { @ code key } */
@ Override public < T > BindingImpl < T > getBinding ( Key < T > key ) { } }

implementation: Errors errors = new Errors ( checkNotNull ( key , "key" ) ) ; try { BindingImpl < T > result = getBindingOrThrow ( key , errors , JitLimitation . EXISTING_JIT ) ; errors . throwConfigurationExceptionIfErrorsExist ( ) ; return result ; } catch ( ErrorsException e ) { throw new ConfigurationException ( errors . merge ( e . getErrors ( ) ) . getMessages ( ) ) ; }


signature:
public class InjectorImpl { /** * Gets a binding implementation . First , it check to see if the parent has a binding . If the
 * parent has a binding and the binding is scoped , it will use that binding . Otherwise , this
 * checks for an explicit binding . If no explicit binding is found , it looks for a just - in - time
 * binding . */
< T > BindingImpl < T > getBindingOrThrow ( Key < T > key , Errors errors , JitLimitation jitType ) throws ErrorsException { } }

implementation:
// Check explicit bindings , i . e . bindings created by modules .
BindingImpl < T > binding = state . getExplicitBinding ( key ) ; if ( binding != null ) { return binding ; } // Look for an on - demand binding .
return getJustInTimeBinding ( key , errors , jitType ) ;


signature:
public class InjectorImpl { /** * Returns a just - in - time binding for { @ code key } , creating it if necessary .
 * @ throws ErrorsException if the binding could not be created . */
private < T > BindingImpl < T > getJustInTimeBinding ( Key < T > key , Errors errors , JitLimitation jitType ) throws ErrorsException { } }

implementation:
boolean jitOverride = isProvider ( key ) || isTypeLiteral ( key ) || isMembersInjector ( key ) ; synchronized ( state . lock ( ) ) { // first try to find a JIT binding that we ' ve already created
for ( InjectorImpl injector = this ; injector != null ; injector = injector . parent ) { @ SuppressWarnings ( "unchecked" ) // we only store bindings that match their key
BindingImpl < T > binding = ( BindingImpl < T > ) injector . jitBindings . get ( key ) ; if ( binding != null ) { // If we found a JIT binding and we don ' t allow them ,
// fail . ( But allow bindings created through TypeConverters . )
if ( options . jitDisabled && jitType == JitLimitation . NO_JIT && ! jitOverride && ! ( binding instanceof ConvertedConstantBindingImpl ) ) { throw errors . jitDisabled ( key ) . toException ( ) ; } else { return binding ; } } } // If we previously failed creating this JIT binding and our Errors has
// already recorded an error , then just directly throw that error .
// We need to do this because it ' s possible we already cleaned up the
// entry in jitBindings ( during cleanup ) , and we may be trying
// to create it again ( in the case of a recursive JIT binding ) .
// We need both of these guards for different reasons
// failedJitBindings . contains : We want to continue processing if we ' ve never
// failed before , so that our initial error message contains
// as much useful information as possible about what errors exist .
// errors . hasErrors : If we haven ' t already failed , then it ' s OK to
// continue processing , to make sure the ultimate error message
// is the correct one .
// See : ImplicitBindingsTest # testRecursiveJitBindingsCleanupCorrectly
// for where this guard compes into play .
if ( failedJitBindings . contains ( key ) && errors . hasErrors ( ) ) { throw errors . toException ( ) ; } return createJustInTimeBindingRecursive ( key , errors , options . jitDisabled , jitType ) ; } // end synchronized ( state . lock ( ) )


signature:
public class InjectorImpl { /** * Returns true if the key type is MembersInjector ( but not a subclass of MembersInjector ) . */
private static boolean isMembersInjector ( Key < ? > key ) { } }

implementation: return key . getTypeLiteral ( ) . getRawType ( ) . equals ( MembersInjector . class ) && key . getAnnotationType ( ) == null ;


signature:
public class InjectorImpl { /** * Creates a synthetic binding to { @ code Provider < T > } , i . e . a binding to the provider from { @ code
 * Binding < T > } . */
private < T > BindingImpl < Provider < T > > createProviderBinding ( Key < Provider < T > > key , Errors errors ) throws ErrorsException { } }

implementation: Key < T > providedKey = getProvidedKey ( key , errors ) ; BindingImpl < T > delegate = getBindingOrThrow ( providedKey , errors , JitLimitation . NO_JIT ) ; return new ProviderBindingImpl < T > ( this , key , delegate ) ;


signature:
public class InjectorImpl { /** * Converts a constant string binding to the required type .
 * @ return the binding if it could be resolved , or null if the binding doesn ' t exist
 * @ throws com . google . inject . internal . ErrorsException if there was an error resolving the binding */
private < T > BindingImpl < T > convertConstantStringBinding ( Key < T > key , Errors errors ) throws ErrorsException { } }

implementation:
// Find a constant string binding .
Key < String > stringKey = key . ofType ( STRING_TYPE ) ; BindingImpl < String > stringBinding = state . getExplicitBinding ( stringKey ) ; if ( stringBinding == null || ! stringBinding . isConstant ( ) ) { return null ; } // We can ' t call getProvider ( ) . get ( ) because this InstanceBinding may not have been inintialized
// yet ( because we may have been called during InternalInjectorCreator . initializeStatically and
// instance binding validation hasn ' t happened yet . )
@ SuppressWarnings ( "unchecked" ) String stringValue = ( ( InstanceBinding < String > ) stringBinding ) . getInstance ( ) ; Object source = stringBinding . getSource ( ) ; // Find a matching type converter .
TypeLiteral < T > type = key . getTypeLiteral ( ) ; TypeConverterBinding typeConverterBinding = state . getConverter ( stringValue , type , errors , source ) ; if ( typeConverterBinding == null ) { // No converter can handle the given type .
return null ; } // Try to convert the string . A failed conversion results in an error .
try { @ SuppressWarnings ( "unchecked" ) // This cast is safe because we double check below .
T converted = ( T ) typeConverterBinding . getTypeConverter ( ) . convert ( stringValue , type ) ; if ( converted == null ) { throw errors . converterReturnedNull ( stringValue , source , type , typeConverterBinding ) . toException ( ) ; } if ( ! type . getRawType ( ) . isInstance ( converted ) ) { throw errors . conversionTypeError ( stringValue , source , type , typeConverterBinding , converted ) . toException ( ) ; } return new ConvertedConstantBindingImpl < T > ( this , key , converted , stringBinding , typeConverterBinding ) ; } catch ( ErrorsException e ) { throw e ; } catch ( RuntimeException e ) { throw errors . conversionError ( stringValue , source , type , typeConverterBinding , e ) . toException ( ) ; }


signature:
public class InjectorImpl { /** * Iterates through the binding ' s dependencies to clean up any stray bindings that were leftover
 * from a failed JIT binding . This is required because the bindings are eagerly & optimistically
 * added to allow circular dependency support , so dependencies may pass where they should have
 * failed . */
private boolean cleanup ( BindingImpl < ? > binding , Set < Key > encountered ) { } }

implementation:
boolean bindingFailed = false ; Set < Dependency < ? > > deps = getInternalDependencies ( binding ) ; for ( Dependency dep : deps ) { Key < ? > depKey = dep . getKey ( ) ; InjectionPoint ip = dep . getInjectionPoint ( ) ; if ( encountered . add ( depKey ) ) { // only check if we haven ' t looked at this key yet
BindingImpl depBinding = jitBindings . get ( depKey ) ; if ( depBinding != null ) { // if the binding still exists , validate
boolean failed = cleanup ( depBinding , encountered ) ; // if children fail , we fail
if ( depBinding instanceof ConstructorBindingImpl ) { ConstructorBindingImpl ctorBinding = ( ConstructorBindingImpl ) depBinding ; ip = ctorBinding . getInternalConstructor ( ) ; if ( ! ctorBinding . isInitialized ( ) ) { failed = true ; } } if ( failed ) { removeFailedJitBinding ( depBinding , ip ) ; bindingFailed = true ; } } else if ( state . getExplicitBinding ( depKey ) == null ) { // ignore keys if they were explicitly bound , but if neither JIT
// nor explicit , it ' s also invalid & should let parent know .
bindingFailed = true ; } } } return bindingFailed ;


signature:
public class InjectorImpl { /** * Cleans up any state that may have been cached when constructing the JIT binding . */
private void removeFailedJitBinding ( Binding < ? > binding , InjectionPoint ip ) { } }

implementation: failedJitBindings . add ( binding . getKey ( ) ) ; jitBindings . remove ( binding . getKey ( ) ) ; membersInjectorStore . remove ( binding . getKey ( ) . getTypeLiteral ( ) ) ; provisionListenerStore . remove ( binding ) ; if ( ip != null ) { constructors . remove ( ip ) ; }


signature:
public class InjectorImpl { /** * Safely gets the dependencies of possibly not initialized bindings . */
@ SuppressWarnings ( "unchecked" ) private Set < Dependency < ? > > getInternalDependencies ( BindingImpl < ? > binding ) { } }

implementation: if ( binding instanceof ConstructorBindingImpl ) { return ( ( ConstructorBindingImpl ) binding ) . getInternalDependencies ( ) ; } else if ( binding instanceof HasDependencies ) { return ( ( HasDependencies ) binding ) . getDependencies ( ) ; } else { return ImmutableSet . of ( ) ; }


signature:
public class InjectorImpl { /** * Creates a binding for an injectable type with the given scope . Looks for a scope on the type if
 * none is specified . */
< T > BindingImpl < T > createUninitializedBinding ( Key < T > key , Scoping scoping , Object source , Errors errors , boolean jitBinding ) throws ErrorsException { } }

implementation:
Class < ? > rawType = key . getTypeLiteral ( ) . getRawType ( ) ; ImplementedBy implementedBy = rawType . getAnnotation ( ImplementedBy . class ) ; // Don ' t try to inject arrays or enums annotated with @ ImplementedBy .
if ( rawType . isArray ( ) || ( rawType . isEnum ( ) && implementedBy != null ) ) { throw errors . missingImplementationWithHint ( key , this ) . toException ( ) ; } // Handle TypeLiteral < T > by binding the inner type
if ( rawType == TypeLiteral . class ) { @ SuppressWarnings ( "unchecked" ) // we have to fudge the inner type as Object
BindingImpl < T > binding = ( BindingImpl < T > ) createTypeLiteralBinding ( ( Key < TypeLiteral < Object > > ) key , errors ) ; return binding ; } // Handle @ ImplementedBy
if ( implementedBy != null ) { Annotations . checkForMisplacedScopeAnnotations ( rawType , source , errors ) ; return createImplementedByBinding ( key , scoping , implementedBy , errors ) ; } // Handle @ ProvidedBy .
ProvidedBy providedBy = rawType . getAnnotation ( ProvidedBy . class ) ; if ( providedBy != null ) { Annotations . checkForMisplacedScopeAnnotations ( rawType , source , errors ) ; return createProvidedByBinding ( key , scoping , providedBy , errors ) ; } return ConstructorBindingImpl . create ( this , key , null , /* use default constructor */
source , scoping , errors , jitBinding && options . jitDisabled , options . atInjectRequired ) ;


signature:
public class InjectorImpl { /** * Converts a binding for a { @ code Key < TypeLiteral < T > > } to the value { @ code TypeLiteral < T > } . It ' s
 * a bit awkward because we have to pull out the inner type in the type literal . */
private < T > BindingImpl < TypeLiteral < T > > createTypeLiteralBinding ( Key < TypeLiteral < T > > key , Errors errors ) throws ErrorsException { } }

implementation:
Type typeLiteralType = key . getTypeLiteral ( ) . getType ( ) ; if ( ! ( typeLiteralType instanceof ParameterizedType ) ) { throw errors . cannotInjectRawTypeLiteral ( ) . toException ( ) ; } ParameterizedType parameterizedType = ( ParameterizedType ) typeLiteralType ; Type innerType = parameterizedType . getActualTypeArguments ( ) [ 0 ] ; // this is unforunate . We don ' t support building TypeLiterals for type variable like ' T ' . If
// this proves problematic , we can probably fix TypeLiteral to support type variables
if ( ! ( innerType instanceof Class ) && ! ( innerType instanceof GenericArrayType ) && ! ( innerType instanceof ParameterizedType ) ) { throw errors . cannotInjectTypeLiteralOf ( innerType ) . toException ( ) ; } @ SuppressWarnings ( "unchecked" ) // by definition , innerType = = T , so this is safe
TypeLiteral < T > value = ( TypeLiteral < T > ) TypeLiteral . get ( innerType ) ; InternalFactory < TypeLiteral < T > > factory = new ConstantFactory < TypeLiteral < T > > ( Initializables . of ( value ) ) ; return new InstanceBindingImpl < TypeLiteral < T > > ( this , key , SourceProvider . UNKNOWN_SOURCE , factory , ImmutableSet . < InjectionPoint > of ( ) , value ) ;


signature:
public class InjectorImpl { /** * Creates a binding for a type annotated with @ ProvidedBy . */
< T > BindingImpl < T > createProvidedByBinding ( Key < T > key , Scoping scoping , ProvidedBy providedBy , Errors errors ) throws ErrorsException { } }

implementation:
Class < ? > rawType = key . getTypeLiteral ( ) . getRawType ( ) ; Class < ? extends javax . inject . Provider < ? > > providerType = providedBy . value ( ) ; // Make sure it ' s not the same type . TODO : Can we check for deeper loops ?
if ( providerType == rawType ) { throw errors . recursiveProviderType ( ) . toException ( ) ; } // Assume the provider provides an appropriate type . We double check at runtime .
@ SuppressWarnings ( "unchecked" ) Key < ? extends Provider < T > > providerKey = ( Key < ? extends Provider < T > > ) Key . get ( providerType ) ; ProvidedByInternalFactory < T > internalFactory = new ProvidedByInternalFactory < T > ( rawType , providerType , providerKey ) ; Object source = rawType ; BindingImpl < T > binding = LinkedProviderBindingImpl . createWithInitializer ( this , key , source , Scoping . < T > scope ( key , this , internalFactory , source , scoping ) , scoping , providerKey , internalFactory ) ; internalFactory . setProvisionListenerCallback ( provisionListenerStore . get ( binding ) ) ; return binding ;


signature:
public class InjectorImpl { /** * Creates a binding for a type annotated with @ ImplementedBy . */
private < T > BindingImpl < T > createImplementedByBinding ( Key < T > key , Scoping scoping , ImplementedBy implementedBy , Errors errors ) throws ErrorsException { } }

implementation:
Class < ? > rawType = key . getTypeLiteral ( ) . getRawType ( ) ; Class < ? > implementationType = implementedBy . value ( ) ; // Make sure it ' s not the same type . TODO : Can we check for deeper cycles ?
if ( implementationType == rawType ) { throw errors . recursiveImplementationType ( ) . toException ( ) ; } // Make sure implementationType extends type .
if ( ! rawType . isAssignableFrom ( implementationType ) ) { throw errors . notASubtype ( implementationType , rawType ) . toException ( ) ; } @ SuppressWarnings ( "unchecked" ) // After the preceding check , this cast is safe .
Class < ? extends T > subclass = ( Class < ? extends T > ) implementationType ; // Look up the target binding .
final Key < ? extends T > targetKey = Key . get ( subclass ) ; Object source = rawType ; FactoryProxy < T > factory = new FactoryProxy < > ( this , key , targetKey , source ) ; factory . notify ( errors ) ; // causes the factory to initialize itself internally
return new LinkedBindingImpl < T > ( this , key , source , Scoping . < T > scope ( key , this , factory , source , scoping ) , scoping , targetKey ) ;


signature:
public class InjectorImpl { /** * Attempts to create a just - in - time binding for { @ code key } in the root injector , falling back to
 * other ancestor injectors until this injector is tried . */
private < T > BindingImpl < T > createJustInTimeBindingRecursive ( Key < T > key , Errors errors , boolean jitDisabled , JitLimitation jitType ) throws ErrorsException { } }

implementation:
// ask the parent to create the JIT binding
if ( parent != null ) { if ( jitType == JitLimitation . NEW_OR_EXISTING_JIT && jitDisabled && ! parent . options . jitDisabled ) { // If the binding would be forbidden here but allowed in a parent , report an error instead
throw errors . jitDisabledInParent ( key ) . toException ( ) ; } try { return parent . createJustInTimeBindingRecursive ( key , new Errors ( ) , jitDisabled , parent . options . jitDisabled ? JitLimitation . NO_JIT : jitType ) ; } catch ( ErrorsException ignored ) { } } // Retrieve the sources before checking for blacklisting to guard against sources becoming null
// due to a full GC happening after calling state . isBlacklisted and
// state . getSourcesForBlacklistedKey .
// TODO ( user ) : Consolidate these two APIs .
Set < Object > sources = state . getSourcesForBlacklistedKey ( key ) ; if ( state . isBlacklisted ( key ) ) { throw errors . childBindingAlreadySet ( key , sources ) . toException ( ) ; } key = MoreTypes . canonicalizeKey ( key ) ; // before storing the key long - term , canonicalize it .
BindingImpl < T > binding = createJustInTimeBinding ( key , errors , jitDisabled , jitType ) ; state . parent ( ) . blacklist ( key , state , binding . getSource ( ) ) ; jitBindings . put ( key , binding ) ; return binding ;


signature:
public class InjectorImpl { /** * Returns a new just - in - time binding created by resolving { @ code key } . The strategies used to
 * create just - in - time bindings are :
 * < ol >
 * < li > Internalizing Providers . If the requested binding is for { @ code Provider < T > } , we delegate
 * to the binding for { @ code T } .
 * < li > Converting constants .
 * < li > ImplementedBy and ProvidedBy annotations . Only for unannotated keys .
 * < li > The constructor of the raw type . Only for unannotated keys .
 * < / ol >
 * @ throws com . google . inject . internal . ErrorsException if the binding cannot be created . */
private < T > BindingImpl < T > createJustInTimeBinding ( Key < T > key , Errors errors , boolean jitDisabled , JitLimitation jitType ) throws ErrorsException { } }

implementation:
int numErrorsBefore = errors . size ( ) ; // Retrieve the sources before checking for blacklisting to guard against sources becoming null
// due to a full GC happening after calling state . isBlacklisted and
// state . getSourcesForBlacklistedKey .
// TODO ( user ) : Consolidate these two APIs .
Set < Object > sources = state . getSourcesForBlacklistedKey ( key ) ; if ( state . isBlacklisted ( key ) ) { throw errors . childBindingAlreadySet ( key , sources ) . toException ( ) ; } // Handle cases where T is a Provider < ? > .
if ( isProvider ( key ) ) { // These casts are safe . We know T extends Provider < X > and that given Key < Provider < X > > ,
// createProviderBinding ( ) will return BindingImpl < Provider < X > > .
@ SuppressWarnings ( { "unchecked" , "cast" } ) BindingImpl < T > binding = ( BindingImpl < T > ) createProviderBinding ( ( Key ) key , errors ) ; return binding ; } // Handle cases where T is a MembersInjector < ? >
if ( isMembersInjector ( key ) ) { // These casts are safe . T extends MembersInjector < X > and that given Key < MembersInjector < X > > ,
// createMembersInjectorBinding ( ) will return BindingImpl < MembersInjector < X > > .
@ SuppressWarnings ( { "unchecked" , "cast" } ) BindingImpl < T > binding = ( BindingImpl < T > ) createMembersInjectorBinding ( ( Key ) key , errors ) ; return binding ; } // Try to convert a constant string binding to the requested type .
BindingImpl < T > convertedBinding = convertConstantStringBinding ( key , errors ) ; if ( convertedBinding != null ) { return convertedBinding ; } if ( ! isTypeLiteral ( key ) && jitDisabled && jitType != JitLimitation . NEW_OR_EXISTING_JIT ) { throw errors . jitDisabled ( key ) . toException ( ) ; } // If the key has an annotation . . .
if ( key . getAnnotationType ( ) != null ) { // Look for a binding without annotation attributes or return null .
if ( key . hasAttributes ( ) && ! options . exactBindingAnnotationsRequired ) { try { Errors ignored = new Errors ( ) ; return getBindingOrThrow ( key . withoutAttributes ( ) , ignored , JitLimitation . NO_JIT ) ; } catch ( ErrorsException ignored ) { // throw with a more appropriate message below
} } throw errors . missingImplementationWithHint ( key , this ) . toException ( ) ; } Object source = key . getTypeLiteral ( ) . getRawType ( ) ; BindingImpl < T > binding = createUninitializedBinding ( key , Scoping . UNSCOPED , source , errors , true ) ; errors . throwIfNewErrors ( numErrorsBefore ) ; initializeJitBinding ( binding , errors ) ; return binding ;


signature:
public class InjectorImpl { /** * Returns parameter injectors , or { @ code null } if there are no parameters . */
SingleParameterInjector < ? > [ ] getParametersInjectors ( List < Dependency < ? > > parameters , Errors errors ) throws ErrorsException { } }

implementation:
if ( parameters . isEmpty ( ) ) { return null ; } int numErrorsBefore = errors . size ( ) ; SingleParameterInjector < ? > [ ] result = new SingleParameterInjector < ? > [ parameters . size ( ) ] ; int i = 0 ; for ( Dependency < ? > parameter : parameters ) { try { result [ i ++ ] = createParameterInjector ( parameter , errors . withSource ( parameter ) ) ; } catch ( ErrorsException rethrownBelow ) { // rethrown below
} } errors . throwIfNewErrors ( numErrorsBefore ) ; return result ;


signature:
public class InjectorImpl { /** * Looks up thread local context and { @ link InternalContext # enter ( ) enters } it or creates a new
 * context if necessary .
 * < p > All callers of this are responsible for calling { @ link InternalContext # close ( ) } . Typical
 * usage should look like :
 * < pre > { @ code
 * InternalContext ctx = injector . enterContext ( ) ;
 * try {
 * . . . use ctx . . .
 * } finally {
 * ctx . close ( ) ;
 * } < / pre > */
InternalContext enterContext ( ) { } }

implementation: Object [ ] reference = localContext . get ( ) ; if ( reference == null ) { reference = new Object [ 1 ] ; localContext . set ( reference ) ; } InternalContext ctx = ( InternalContext ) reference [ 0 ] ; if ( ctx == null ) { reference [ 0 ] = ctx = new InternalContext ( options , reference ) ; } else { ctx . enter ( ) ; } return ctx ;


signature:
public class SingleParameterInjector { /** * Returns an array of parameter values . */
static Object [ ] getAll ( InternalContext context , SingleParameterInjector < ? > [ ] parameterInjectors ) throws InternalProvisionException { } }

implementation:
if ( parameterInjectors == null ) { return NO_ARGUMENTS ; } int size = parameterInjectors . length ; Object [ ] parameters = new Object [ size ] ; // optimization : use manual for / each to save allocating an iterator here
for ( int i = 0 ; i < size ; i ++ ) { parameters [ i ] = parameterInjectors [ i ] . inject ( context ) ; } return parameters ;


signature:
public class GraphvizGrapher { /** * Creates the " label " for a node . This is a string of HTML that defines a table with a heading at
 * the top and ( in the case of { @ link ImplementationNode } s ) rows for each of the member fields . */
protected String getNodeLabel ( GraphvizNode node ) { } }

implementation:
String cellborder = node . getStyle ( ) == NodeStyle . INVISIBLE ? "1" : "0" ; StringBuilder html = new StringBuilder ( ) ; html . append ( "<" ) ; html . append ( "
" ) ; html . append ( "
" ) . append ( "" ) ; String subtitle = Joiner . on ( "
" ) . join ( node . getSubtitles ( ) ) ; if ( subtitle . length ( ) != 0 ) { html . append ( "" ) ; html . append ( subtitle ) . append ( "
" ) . append ( "" ) ; } html . append ( "" ) ; html . append ( htmlEscape ( node . getTitle ( ) ) ) . append ( "
" ) ; html . append ( "" ) . append ( "	" ) . append ( "
" ) ; for ( Map . Entry < String , String > field : node . getFields ( ) . entrySet ( ) ) { html . append ( "
" ) ; html . append ( "" ) ; html . append ( htmlEscape ( field . getValue ( ) ) ) ; html . append ( "	" ) . append ( "
" ) ; } html . append ( "
" ) ; html . append ( ">" ) ; return html . toString ( ) ;


signature:
public class Multibinder { /** * Returns a new multibinder that collects instances of the key ' s type in a { @ link Set } that is
 * itself bound with the annotation ( if any ) of the key .
 * @ since 4.0 */
public static < T > Multibinder < T > newSetBinder ( Binder binder , Key < T > key ) { } }

implementation: return new Multibinder < T > ( newRealSetBinder ( binder . skipSources ( Multibinder . class ) , key ) ) ;


signature:
public class Multibinder { /** * Returns a new multibinder that collects instances of { @ code type } in a { @ link Set } that is
 * itself bound with { @ code annotationType } . */
public static < T > Multibinder < T > newSetBinder ( Binder binder , Class < T > type , Class < ? extends Annotation > annotationType ) { } }

implementation: return newSetBinder ( binder , Key . get ( type , annotationType ) ) ;


signature:
public class FactoryModuleBuilder { /** * See the factory configuration examples at { @ link FactoryModuleBuilder } . */
public < T > FactoryModuleBuilder implement ( Class < T > source , Class < ? extends T > target ) { } }

implementation: return implement ( source , TypeLiteral . get ( target ) ) ;


signature:
public class FactoryModuleBuilder { /** * See the factory configuration examples at { @ link FactoryModuleBuilder } . */
public < F > Module build ( Class < F > factoryInterface ) { } }

implementation: return build ( TypeLiteral . get ( factoryInterface ) ) ;


signature:
public class FactoryModuleBuilder { /** * See the factory configuration examples at { @ link FactoryModuleBuilder } . */
public < F > Module build ( TypeLiteral < F > factoryInterface ) { } }

implementation: return build ( Key . get ( factoryInterface ) ) ;


signature:
public class InjectorShell { /** * The Injector is a special case because we allow both parent and child injectors to both have a
 * binding for that key . */
private static void bindInjector ( InjectorImpl injector ) { } }

implementation: Key < Injector > key = Key . get ( Injector . class ) ; InjectorFactory injectorFactory = new InjectorFactory ( injector ) ; injector . state . putBinding ( key , new ProviderInstanceBindingImpl < Injector > ( injector , key , SourceProvider . UNKNOWN_SOURCE , injectorFactory , Scoping . UNSCOPED , injectorFactory , ImmutableSet . < InjectionPoint > of ( ) ) ) ;


signature:
public class InjectorShell { /** * The Logger is a special case because it knows the injection point of the injected member . It ' s
 * the only binding that does this . */
private static void bindLogger ( InjectorImpl injector ) { } }

implementation: Key < Logger > key = Key . get ( Logger . class ) ; LoggerFactory loggerFactory = new LoggerFactory ( ) ; injector . state . putBinding ( key , new ProviderInstanceBindingImpl < Logger > ( injector , key , SourceProvider . UNKNOWN_SOURCE , loggerFactory , Scoping . UNSCOPED , loggerFactory , ImmutableSet . < InjectionPoint > of ( ) ) ) ;


signature:
public class InjectionPoint { /** * This metohd is necessary to create a Dependency < T > with proper generic type information */
private < T > Dependency < T > newDependency ( Key < T > key , boolean allowsNull , int parameterIndex ) { } }

implementation: return new Dependency < T > ( this , key , allowsNull , parameterIndex ) ;


signature:
public class InjectionPoint { /** * Returns a new injection point for the specified constructor . If the declaring type of { @ code
 * constructor } is parameterized ( such as { @ code List < T > } ) , prefer the overload that includes a
 * type literal .
 * @ param constructor any single constructor present on { @ code type } .
 * @ since 3.0 */
public static < T > InjectionPoint forConstructor ( Constructor < T > constructor ) { } }

implementation: return new InjectionPoint ( TypeLiteral . get ( constructor . getDeclaringClass ( ) ) , constructor ) ;


signature:
public class InjectionPoint { /** * Returns a new injection point for the specified constructor of { @ code type } .
 * @ param constructor any single constructor present on { @ code type } .
 * @ param type the concrete type that defines { @ code constructor } .
 * @ since 3.0 */
public static < T > InjectionPoint forConstructor ( Constructor < T > constructor , TypeLiteral < ? extends T > type ) { } }

implementation: if ( type . getRawType ( ) != constructor . getDeclaringClass ( ) ) { new Errors ( type ) . constructorNotDefinedByType ( constructor , type ) . throwConfigurationExceptionIfErrorsExist ( ) ; } return new InjectionPoint ( type , constructor ) ;


signature:
public class InjectionPoint { /** * Returns a new injection point for the injectable constructor of { @ code type } .
 * @ param type a concrete type with exactly one constructor annotated { @ literal @ } { @ link Inject } ,
 * or a no - arguments constructor that is not private .
 * @ throws ConfigurationException if there is no injectable constructor , more than one injectable
 * constructor , or if parameters of the injectable constructor are malformed , such as a
 * parameter with multiple binding annotations . */
public static InjectionPoint forConstructorOf ( TypeLiteral < ? > type ) { } }

implementation:
Class < ? > rawType = getRawType ( type . getType ( ) ) ; Errors errors = new Errors ( rawType ) ; Constructor < ? > injectableConstructor = null ; for ( Constructor < ? > constructor : rawType . getDeclaredConstructors ( ) ) { boolean optional ; Inject guiceInject = constructor . getAnnotation ( Inject . class ) ; if ( guiceInject == null ) { javax . inject . Inject javaxInject = constructor . getAnnotation ( javax . inject . Inject . class ) ; if ( javaxInject == null ) { continue ; } optional = false ; } else { optional = guiceInject . optional ( ) ; } if ( optional ) { errors . optionalConstructor ( constructor ) ; } if ( injectableConstructor != null ) { errors . tooManyConstructors ( rawType ) ; } injectableConstructor = constructor ; checkForMisplacedBindingAnnotations ( injectableConstructor , errors ) ; } errors . throwConfigurationExceptionIfErrorsExist ( ) ; if ( injectableConstructor != null ) { return new InjectionPoint ( type , injectableConstructor ) ; } // If no annotated constructor is found , look for a no - arg constructor instead .
try { Constructor < ? > noArgConstructor = rawType . getDeclaredConstructor ( ) ; // Disallow private constructors on non - private classes ( unless they have @ Inject )
if ( Modifier . isPrivate ( noArgConstructor . getModifiers ( ) ) && ! Modifier . isPrivate ( rawType . getModifiers ( ) ) ) { errors . missingConstructor ( rawType ) ; throw new ConfigurationException ( errors . getMessages ( ) ) ; } checkForMisplacedBindingAnnotations ( noArgConstructor , errors ) ; return new InjectionPoint ( type , noArgConstructor ) ; } catch ( NoSuchMethodException e ) { errors . missingConstructor ( rawType ) ; throw new ConfigurationException ( errors . getMessages ( ) ) ; }


signature:
public class InjectionPoint { /** * Returns a new injection point for the specified method of { @ code type } . This is useful for
 * extensions that need to build dependency graphs from arbitrary methods .
 * @ param method any single method present on { @ code type } .
 * @ param type the concrete type that defines { @ code method } .
 * @ since 4.0 */
public static < T > InjectionPoint forMethod ( Method method , TypeLiteral < T > type ) { } }

implementation: return new InjectionPoint ( type , method , false ) ;


signature:
public class InjectionPoint { /** * Returns all static method and field injection points on { @ code type } .
 * @ return a possibly empty set of injection points . The set has a specified iteration order . All
 * fields are returned and then all methods . Within the fields , supertype fields are returned
 * before subtype fields . Similarly , supertype methods are returned before subtype methods .
 * @ throws ConfigurationException if there is a malformed injection point on { @ code type } , such as
 * a field with multiple binding annotations . The exception ' s { @ link
 * ConfigurationException # getPartialValue ( ) partial value } is a { @ code Set < InjectionPoint > } of
 * the valid injection points . */
public static Set < InjectionPoint > forStaticMethodsAndFields ( TypeLiteral < ? > type ) { } }

implementation: Errors errors = new Errors ( ) ; Set < InjectionPoint > result ; if ( type . getRawType ( ) . isInterface ( ) ) { errors . staticInjectionOnInterface ( type . getRawType ( ) ) ; result = null ; } else { result = getInjectionPoints ( type , true , errors ) ; } if ( errors . hasErrors ( ) ) { throw new ConfigurationException ( errors . getMessages ( ) ) . withPartialValue ( result ) ; } return result ;


signature:
public class InjectionPoint { /** * Returns all instance method and field injection points on { @ code type } .
 * @ return a possibly empty set of injection points . The set has a specified iteration order . All
 * fields are returned and then all methods . Within the fields , supertype fields are returned
 * before subtype fields . Similarly , supertype methods are returned before subtype methods .
 * @ throws ConfigurationException if there is a malformed injection point on { @ code type } , such as
 * a field with multiple binding annotations . The exception ' s { @ link
 * ConfigurationException # getPartialValue ( ) partial value } is a { @ code Set < InjectionPoint > } of
 * the valid injection points . */
public static Set < InjectionPoint > forInstanceMethodsAndFields ( TypeLiteral < ? > type ) { } }

implementation: Errors errors = new Errors ( ) ; Set < InjectionPoint > result = getInjectionPoints ( type , false , errors ) ; if ( errors . hasErrors ( ) ) { throw new ConfigurationException ( errors . getMessages ( ) ) . withPartialValue ( result ) ; } return result ;


signature:
public class InjectionPoint { /** * Returns true if the binding annotation is in the wrong place . */
private static boolean checkForMisplacedBindingAnnotations ( Member member , Errors errors ) { } }

implementation:
Annotation misplacedBindingAnnotation = Annotations . findBindingAnnotation ( errors , member , ( ( AnnotatedElement ) member ) . getAnnotations ( ) ) ; if ( misplacedBindingAnnotation == null ) { return false ; } // don ' t warn about misplaced binding annotations on methods when there ' s a field with the same
// name . In Scala , fields always get accessor methods ( that we need to ignore ) . See bug 242.
if ( member instanceof Method ) { try { if ( member . getDeclaringClass ( ) . getDeclaredField ( member . getName ( ) ) != null ) { return false ; } } catch ( NoSuchFieldException ignore ) { } } errors . misplacedBindingAnnotation ( member , misplacedBindingAnnotation ) ; return true ;


signature:
public class InjectionPoint { /** * Returns an ordered , immutable set of injection points for the given type . Members in
 * superclasses come before members in subclasses . Within a class , fields come before methods .
 * Overridden methods are filtered out . The order of fields / methods within a class is consistent
 * but undefined .
 * @ param statics true is this method should return static members , false for instance members
 * @ param errors used to record errors */
private static Set < InjectionPoint > getInjectionPoints ( final TypeLiteral < ? > type , boolean statics , Errors errors ) { } }

implementation:
InjectableMembers injectableMembers = new InjectableMembers ( ) ; OverrideIndex overrideIndex = null ; List < TypeLiteral < ? > > hierarchy = hierarchyFor ( type ) ; int topIndex = hierarchy . size ( ) - 1 ; for ( int i = topIndex ; i >= 0 ; i -- ) { if ( overrideIndex != null && i < topIndex ) { // Knowing the position within the hierarchy helps us make optimizations .
if ( i == 0 ) { overrideIndex . position = Position . BOTTOM ; } else { overrideIndex . position = Position . MIDDLE ; } } TypeLiteral < ? > current = hierarchy . get ( i ) ; for ( Field field : getDeclaredFields ( current ) ) { if ( Modifier . isStatic ( field . getModifiers ( ) ) == statics ) { Annotation atInject = getAtInject ( field ) ; if ( atInject != null ) { InjectableField injectableField = new InjectableField ( current , field , atInject ) ; if ( injectableField . jsr330 && Modifier . isFinal ( field . getModifiers ( ) ) ) { errors . cannotInjectFinalField ( field ) ; } injectableMembers . add ( injectableField ) ; } } } for ( Method method : getDeclaredMethods ( current ) ) { if ( isEligibleForInjection ( method , statics ) ) { Annotation atInject = getAtInject ( method ) ; if ( atInject != null ) { InjectableMethod injectableMethod = new InjectableMethod ( current , method , atInject ) ; if ( checkForMisplacedBindingAnnotations ( method , errors ) || ! isValidMethod ( injectableMethod , errors ) ) { if ( overrideIndex != null ) { boolean removed = overrideIndex . removeIfOverriddenBy ( method , false , injectableMethod ) ; if ( removed ) { logger . log ( Level . WARNING , "Method: {0} is not a valid injectable method (" + "because it either has misplaced binding annotations " + "or specifies type parameters) but is overriding a method that is " + "valid. Because it is not valid, the method will not be injected. " + "To fix this, make the method a valid injectable method." , method ) ; } } continue ; } if ( statics ) { injectableMembers . add ( injectableMethod ) ; } else { if ( overrideIndex == null ) { /* * Creating the override index lazily means that the first type in the hierarchy
 * with injectable methods ( not necessarily the top most type ) will be treated as
 * the TOP position and will enjoy the same optimizations ( no checks for overridden
 * methods , etc . ) . */
overrideIndex = new OverrideIndex ( injectableMembers ) ; } else { // Forcibly remove the overridden method , otherwise we ' ll inject
// it twice .
overrideIndex . removeIfOverriddenBy ( method , true , injectableMethod ) ; } overrideIndex . add ( injectableMethod ) ; } } else { if ( overrideIndex != null ) { boolean removed = overrideIndex . removeIfOverriddenBy ( method , false , null ) ; if ( removed ) { logger . log ( Level . WARNING , "Method: {0} is not annotated with @Inject but " + "is overriding a method that is annotated with @javax.inject.Inject." + "Because it is not annotated with @Inject, the method will not be " + "injected. To fix this, annotate the method with @Inject." , method ) ; } } } } } } if ( injectableMembers . isEmpty ( ) ) { return Collections . emptySet ( ) ; } ImmutableSet . Builder < InjectionPoint > builder = ImmutableSet . builder ( ) ; for ( InjectableMember im = injectableMembers . head ; im != null ; im = im . next ) { try { builder . add ( im . toInjectionPoint ( ) ) ; } catch ( ConfigurationException ignorable ) { if ( ! im . optional ) { errors . merge ( ignorable . getErrorMessages ( ) ) ; } } } return builder . build ( ) ;


signature:
public class InjectionPoint { /** * Returns true if the method is eligible to be injected . This is different than { @ link
 * # isValidMethod } , because ineligibility will not drop a method from being injected if a
 * superclass was eligible & valid . Bridge & synthetic methods are excluded from eligibility for
 * two reasons :
 * < p > Prior to Java8 , javac would generate these methods in subclasses without annotations , which
 * means this would accidentally stop injecting a method annotated with { @ link
 * javax . inject . Inject } , since the spec says to stop injecting if a subclass isn ' t annotated with
 * it .
 * < p > Starting at Java8 , javac copies the annotations to the generated subclass method , except it
 * leaves out the generic types . If this considered it a valid injectable method , this would eject
 * the parent ' s overridden method that had the proper generic types , and would use invalid
 * injectable parameters as a result .
 * < p > The fix for both is simply to ignore these synthetic bridge methods . */
private static boolean isEligibleForInjection ( Method method , boolean statics ) { } }

implementation: return Modifier . isStatic ( method . getModifiers ( ) ) == statics && ! method . isBridge ( ) && ! method . isSynthetic ( ) ;


signature:
public class InjectionPoint { /** * Returns true if a overrides b . Assumes signatures of a and b are the same and a ' s declaring
 * class is a subclass of b ' s declaring class . */
private static boolean overrides ( Method a , Method b ) { } }

implementation:
// See JLS section 8.4.8.1
int modifiers = b . getModifiers ( ) ; if ( Modifier . isPublic ( modifiers ) || Modifier . isProtected ( modifiers ) ) { return true ; } if ( Modifier . isPrivate ( modifiers ) ) { return false ; } // b must be package - private
return a . getDeclaringClass ( ) . getPackage ( ) . equals ( b . getDeclaringClass ( ) . getPackage ( ) ) ;


signature:
public class MembersInjectorLookup { /** * Sets the actual members injector .
 * @ throws IllegalStateException if the delegate is already set */
public void initializeDelegate ( MembersInjector < T > delegate ) { } }

implementation: checkState ( this . delegate == null , "delegate already initialized" ) ; this . delegate = checkNotNull ( delegate , "delegate" ) ;


signature:
public class MembersInjectorLookup { /** * Returns the looked up members injector . The result is not valid until this lookup has been
 * initialized , which usually happens when the injector is created . The members injector will
 * throw an { @ code IllegalStateException } if you try to use it beforehand . */
public MembersInjector < T > getMembersInjector ( ) { } }

implementation: return new MembersInjector < T > ( ) { @ Override public void injectMembers ( T instance ) { MembersInjector < T > local = delegate ; if ( local == null ) { throw new IllegalStateException ( "This MembersInjector cannot be used until the Injector has been created." ) ; } local . injectMembers ( instance ) ; } @ Override public String toString ( ) { return "MembersInjector<" + type + ">" ; } } ;


signature:
public class CheckedProviders { /** * Returns a { @ link CheckedProvider } which always provides { @ code instance } .
 * < p > The provider type passed as { @ code providerType } must be an interface . Calls to methods
 * other than { @ link CheckedProvider # get } will throw { @ link UnsupportedOperationException } .
 * @ param providerType the type of the { @ link CheckedProvider } to return
 * @ param instance the instance that should always be provided */
public static < T , P extends CheckedProvider < ? super T > > P of ( TypeLiteral < P > providerType , @ Nullable T instance ) { } }

implementation: return generateProvider ( providerType , Optional . fromNullable ( instance ) , new ReturningHandler < T > ( instance ) ) ;


signature:
public class CheckedProviders { /** * Returns a { @ link CheckedProvider } which always provides { @ code instance } .
 * @ param providerType the type of the { @ link CheckedProvider } to return
 * @ param instance the instance that should always be provided
 * @ see # of ( TypeLiteral , T ) */
public static < T , P extends CheckedProvider < ? super T > > P of ( Class < P > providerType , @ Nullable T instance ) { } }

implementation: return of ( TypeLiteral . get ( providerType ) , instance ) ;


signature:
public class CheckedProviders { /** * Returns a { @ link CheckedProvider } which always throws exceptions .
 * < p > This method uses the nullary ( no argument ) constructor of { @ code throwable } to create a new
 * instance of the given { @ link Throwable } on each method invocation which is then thrown
 * immediately .
 * < p > See { @ link # of ( TypeLiteral , T ) } for more information .
 * @ param providerType the type of the { @ link CheckedProvider } to return
 * @ param throwable the type of the { @ link Throwable } to throw
 * @ see # of ( TypeLiteral , T ) */
public static < T , P extends CheckedProvider < ? super T > > P throwing ( TypeLiteral < P > providerType , Class < ? extends Throwable > throwable ) { } }

implementation:
// TODO ( eatnumber1 ) : Understand why TypeLiteral # getRawType returns a Class < ? super T > rather
// than a Class < T > and remove this unsafe cast .
Class < P > providerRaw = ( Class ) providerType . getRawType ( ) ; checkThrowable ( providerRaw , throwable ) ; return generateProvider ( providerType , Optional . < T > absent ( ) , ThrowingHandler . forClass ( throwable ) ) ;


signature:
public class CheckedProviders { /** * Returns a { @ link CheckedProvider } which always throws exceptions .
 * @ param providerType the type of the { @ link CheckedProvider } to return
 * @ param throwable the type of the { @ link Throwable } to throw
 * @ see # throwing ( TypeLiteral , Class ) */
public static < T , P extends CheckedProvider < ? super T > > P throwing ( Class < P > providerType , Class < ? extends Throwable > throwable ) { } }

implementation: return throwing ( TypeLiteral . get ( providerType ) , throwable ) ;


signature:
public class TypeLiteral { /** * Returns the type from super class ' s type parameter in { @ link MoreTypes # canonicalize ( Type )
 * canonical form } . */
static Type getSuperclassTypeParameter ( Class < ? > subclass ) { } }

implementation: Type superclass = subclass . getGenericSuperclass ( ) ; if ( superclass instanceof Class ) { throw new RuntimeException ( "Missing type parameter." ) ; } ParameterizedType parameterized = ( ParameterizedType ) superclass ; return canonicalize ( parameterized . getActualTypeArguments ( ) [ 0 ] ) ;


signature:
public class TypeLiteral { /** * Gets the type of this type ' s provider . */
@ SuppressWarnings ( "unchecked" ) final TypeLiteral < Provider < T > > providerType ( ) { } }

implementation:
// This cast is safe and wouldn ' t generate a warning if Type had a type
// parameter .
return ( TypeLiteral < Provider < T > > ) get ( Types . providerOf ( getType ( ) ) ) ;


signature:
public class TypeLiteral { /** * Gets type literal for the given { @ code Class } instance . */
public static < T > TypeLiteral < T > get ( Class < T > type ) { } }

implementation: return new TypeLiteral < T > ( type ) ;


signature:
public class TypeLiteral { /** * Returns an immutable list of the resolved types . */
private List < TypeLiteral < ? > > resolveAll ( Type [ ] types ) { } }

implementation: TypeLiteral < ? > [ ] result = new TypeLiteral < ? > [ types . length ] ; for ( int t = 0 ; t < types . length ; t ++ ) { result [ t ] = resolve ( types [ t ] ) ; } return ImmutableList . copyOf ( result ) ;


signature:
public class TypeLiteral { /** * Returns the generic form of { @ code supertype } . For example , if this is { @ code
 * ArrayList < String > } , this returns { @ code Iterable < String > } given the input { @ code
 * Iterable . class } .
 * @ param supertype a superclass of , or interface implemented by , this .
 * @ since 2.0 */
public TypeLiteral < ? > getSupertype ( Class < ? > supertype ) { } }

implementation: checkArgument ( supertype . isAssignableFrom ( rawType ) , "%s is not a supertype of %s" , supertype , this . type ) ; return resolve ( MoreTypes . getGenericSupertype ( type , rawType , supertype ) ) ;


signature:
public class TypeLiteral { /** * Returns the resolved generic type of { @ code field } .
 * @ param field a field defined by this or any superclass .
 * @ since 2.0 */
public TypeLiteral < ? > getFieldType ( Field field ) { } }

implementation: checkArgument ( field . getDeclaringClass ( ) . isAssignableFrom ( rawType ) , "%s is not defined by a supertype of %s" , field , type ) ; return resolve ( field . getGenericType ( ) ) ;


signature:
public class TypeLiteral { /** * Returns the resolved generic parameter types of { @ code methodOrConstructor } .
 * @ param methodOrConstructor a method or constructor defined by this or any supertype .
 * @ since 2.0 */
public List < TypeLiteral < ? > > getParameterTypes ( Member methodOrConstructor ) { } }

implementation: Type [ ] genericParameterTypes ; if ( methodOrConstructor instanceof Method ) { Method method = ( Method ) methodOrConstructor ; checkArgument ( method . getDeclaringClass ( ) . isAssignableFrom ( rawType ) , "%s is not defined by a supertype of %s" , method , type ) ; genericParameterTypes = method . getGenericParameterTypes ( ) ; } else if ( methodOrConstructor instanceof Constructor ) { Constructor < ? > constructor = ( Constructor < ? > ) methodOrConstructor ; checkArgument ( constructor . getDeclaringClass ( ) . isAssignableFrom ( rawType ) , "%s does not construct a supertype of %s" , constructor , type ) ; genericParameterTypes = constructor . getGenericParameterTypes ( ) ; } else { throw new IllegalArgumentException ( "Not a method or a constructor: " + methodOrConstructor ) ; } return resolveAll ( genericParameterTypes ) ;


signature:
public class TypeLiteral { /** * Returns the resolved generic exception types thrown by { @ code constructor } .
 * @ param methodOrConstructor a method or constructor defined by this or any supertype .
 * @ since 2.0 */
public List < TypeLiteral < ? > > getExceptionTypes ( Member methodOrConstructor ) { } }

implementation: Type [ ] genericExceptionTypes ; if ( methodOrConstructor instanceof Method ) { Method method = ( Method ) methodOrConstructor ; checkArgument ( method . getDeclaringClass ( ) . isAssignableFrom ( rawType ) , "%s is not defined by a supertype of %s" , method , type ) ; genericExceptionTypes = method . getGenericExceptionTypes ( ) ; } else if ( methodOrConstructor instanceof Constructor ) { Constructor < ? > constructor = ( Constructor < ? > ) methodOrConstructor ; checkArgument ( constructor . getDeclaringClass ( ) . isAssignableFrom ( rawType ) , "%s does not construct a supertype of %s" , constructor , type ) ; genericExceptionTypes = constructor . getGenericExceptionTypes ( ) ; } else { throw new IllegalArgumentException ( "Not a method or a constructor: " + methodOrConstructor ) ; } return resolveAll ( genericExceptionTypes ) ;


signature:
public class TypeLiteral { /** * Returns the resolved generic return type of { @ code method } .
 * @ param method a method defined by this or any supertype .
 * @ since 2.0 */
public TypeLiteral < ? > getReturnType ( Method method ) { } }

implementation: checkArgument ( method . getDeclaringClass ( ) . isAssignableFrom ( rawType ) , "%s is not defined by a supertype of %s" , method , type ) ; return resolve ( method . getGenericReturnType ( ) ) ;


signature:
public class MoreTypes { /** * Returns a key that doesn ' t hold any references to parent classes . This is necessary for
 * anonymous keys , so ensure we don ' t hold a ref to the containing module ( or class ) forever . */
public static < T > Key < T > canonicalizeKey ( Key < T > key ) { } }

implementation:
// If we know this isn ' t a subclass , return as - is .
// Otherwise , recreate the key to avoid the subclass
if ( key . getClass ( ) == Key . class ) { return key ; } else if ( key . getAnnotation ( ) != null ) { return Key . get ( key . getTypeLiteral ( ) , key . getAnnotation ( ) ) ; } else if ( key . getAnnotationType ( ) != null ) { return Key . get ( key . getTypeLiteral ( ) , key . getAnnotationType ( ) ) ; } else { return Key . get ( key . getTypeLiteral ( ) ) ; }


signature:
public class MoreTypes { /** * Returns an type that ' s appropriate for use in a key .
 * < p > If the raw type of { @ code typeLiteral } is a { @ code javax . inject . Provider } , this returns a
 * { @ code com . google . inject . Provider } with the same type parameters .
 * < p > If the type is a primitive , the corresponding wrapper type will be returned .
 * @ throws ConfigurationException if { @ code type } contains a type variable */
public static < T > TypeLiteral < T > canonicalizeForKey ( TypeLiteral < T > typeLiteral ) { } }

implementation:
Type type = typeLiteral . getType ( ) ; if ( ! isFullySpecified ( type ) ) { Errors errors = new Errors ( ) . keyNotFullySpecified ( typeLiteral ) ; throw new ConfigurationException ( errors . getMessages ( ) ) ; } if ( typeLiteral . getRawType ( ) == javax . inject . Provider . class ) { ParameterizedType parameterizedType = ( ParameterizedType ) type ; // the following casts are generally unsafe , but com . google . inject . Provider extends
// javax . inject . Provider and is covariant
@ SuppressWarnings ( "unchecked" ) TypeLiteral < T > guiceProviderType = ( TypeLiteral < T > ) TypeLiteral . get ( Types . providerOf ( parameterizedType . getActualTypeArguments ( ) [ 0 ] ) ) ; return guiceProviderType ; } @ SuppressWarnings ( "unchecked" ) TypeLiteral < T > wrappedPrimitives = ( TypeLiteral < T > ) PRIMITIVE_TO_WRAPPER . get ( typeLiteral ) ; if ( wrappedPrimitives != null ) { return wrappedPrimitives ; } // If we know this isn ' t a subclass , return as - is .
if ( typeLiteral . getClass ( ) == TypeLiteral . class ) { return typeLiteral ; } // recreate the TypeLiteral to avoid anonymous TypeLiterals from holding refs to their
// surrounding classes .
@ SuppressWarnings ( "unchecked" ) TypeLiteral < T > recreated = ( TypeLiteral < T > ) TypeLiteral . get ( typeLiteral . getType ( ) ) ; return recreated ;


signature:
public class MoreTypes { /** * Returns true if { @ code type } is free from type variables . */
private static boolean isFullySpecified ( Type type ) { } }

implementation: if ( type instanceof Class ) { return true ; } else if ( type instanceof CompositeType ) { return ( ( CompositeType ) type ) . isFullySpecified ( ) ; } else if ( type instanceof TypeVariable ) { return false ; } else { return ( ( CompositeType ) canonicalize ( type ) ) . isFullySpecified ( ) ; }


signature:
public class MoreTypes { /** * Returns a type that is functionally equal but not necessarily equal according to { @ link
 * Object # equals ( Object ) Object . equals ( ) } . The returned type is { @ link Serializable } . */
public static Type canonicalize ( Type type ) { } }

implementation:
if ( type instanceof Class ) { Class < ? > c = ( Class < ? > ) type ; return c . isArray ( ) ? new GenericArrayTypeImpl ( canonicalize ( c . getComponentType ( ) ) ) : c ; } else if ( type instanceof CompositeType ) { return type ; } else if ( type instanceof ParameterizedType ) { ParameterizedType p = ( ParameterizedType ) type ; return new ParameterizedTypeImpl ( p . getOwnerType ( ) , p . getRawType ( ) , p . getActualTypeArguments ( ) ) ; } else if ( type instanceof GenericArrayType ) { GenericArrayType g = ( GenericArrayType ) type ; return new GenericArrayTypeImpl ( g . getGenericComponentType ( ) ) ; } else if ( type instanceof WildcardType ) { WildcardType w = ( WildcardType ) type ; return new WildcardTypeImpl ( w . getUpperBounds ( ) , w . getLowerBounds ( ) ) ; } else { // type is either serializable as - is or unsupported
return type ; }


signature:
public class MoreTypes { /** * Returns the declaring class of { @ code typeVariable } , or { @ code null } if it was not declared by
 * a class . */
private static Class < ? > declaringClassOf ( TypeVariable typeVariable ) { } }

implementation: GenericDeclaration genericDeclaration = typeVariable . getGenericDeclaration ( ) ; return genericDeclaration instanceof Class ? ( Class < ? > ) genericDeclaration : null ;


signature:
public class ManagedServletPipeline { /** * Introspects the injector and collects all instances of bound { @ code List < ServletDefinition > }
 * into a master list .
 * < p > We have a guarantee that { @ link com . google . inject . Injector # getBindings ( ) } returns a map that
 * preserves insertion order in entry - set iterators . */
private ServletDefinition [ ] collectServletDefinitions ( Injector injector ) { } }

implementation:
List < ServletDefinition > servletDefinitions = Lists . newArrayList ( ) ; for ( Binding < ServletDefinition > entry : injector . findBindingsByType ( SERVLET_DEFS ) ) { servletDefinitions . add ( entry . getProvider ( ) . get ( ) ) ; } // Copy to a fixed size array for speed .
return servletDefinitions . toArray ( new ServletDefinition [ servletDefinitions . size ( ) ] ) ;


signature:
public class TypeConverterBindingProcessor { /** * Installs default converters for primitives , enums , and class literals . */
static void prepareBuiltInConverters ( InjectorImpl injector ) { } }

implementation:
// Configure type converters .
convertToPrimitiveType ( injector , int . class , Integer . class ) ; convertToPrimitiveType ( injector , long . class , Long . class ) ; convertToPrimitiveType ( injector , boolean . class , Boolean . class ) ; convertToPrimitiveType ( injector , byte . class , Byte . class ) ; convertToPrimitiveType ( injector , short . class , Short . class ) ; convertToPrimitiveType ( injector , float . class , Float . class ) ; convertToPrimitiveType ( injector , double . class , Double . class ) ; convertToClass ( injector , Character . class , new TypeConverter ( ) { @ Override public Object convert ( String value , TypeLiteral < ? > toType ) { value = value . trim ( ) ; if ( value . length ( ) != 1 ) { throw new RuntimeException ( "Length != 1." ) ; } return value . charAt ( 0 ) ; } @ Override public String toString ( ) { return "TypeConverter<Character>" ; } } ) ; convertToClasses ( injector , Matchers . subclassesOf ( Enum . class ) , new TypeConverter ( ) { @ Override @ SuppressWarnings ( "unchecked" ) public Object convert ( String value , TypeLiteral < ? > toType ) { return Enum . valueOf ( ( Class ) toType . getRawType ( ) , value ) ; } @ Override public String toString ( ) { return "TypeConverter<E extends Enum<E>>" ; } } ) ; internalConvertToTypes ( injector , new AbstractMatcher < TypeLiteral < ? > > ( ) { @ Override public boolean matches ( TypeLiteral < ? > typeLiteral ) { return typeLiteral . getRawType ( ) == Class . class ; } @ Override public String toString ( ) { return "Class<?>" ; } } , new TypeConverter ( ) { @ Override @ SuppressWarnings ( "unchecked" ) public Object convert ( String value , TypeLiteral < ? > toType ) { try { return Class . forName ( value ) ; } catch ( ClassNotFoundException e ) { throw new RuntimeException ( e . getMessage ( ) ) ; } } @ Override public String toString ( ) { return "TypeConverter<Class<?>>" ; } } ) ;


signature:
public class BytecodeGen { /** * Attempts to canonicalize null references to the system class loader . May return null if for
 * some reason the system loader is unavailable . */
private static ClassLoader canonicalize ( ClassLoader classLoader ) { } }

implementation: return classLoader != null ? classLoader : SystemBridgeHolder . SYSTEM_BRIDGE . getParent ( ) ;


signature:
public class BytecodeGen { /** * Returns a FastClass proxy for invoking the given member or { @ code null } if access rules
 * disallow it .
 * @ see # newFastClassForMember ( Class , Member ) for a full description */
public static net . sf . cglib . reflect . FastClass newFastClassForMember ( Member member ) { } }

implementation: return newFastClassForMember ( member . getDeclaringClass ( ) , member ) ;


signature:
public class BytecodeGen { /** * Returns a FastClass proxy for invoking the given member or { @ code null } if access rules
 * disallow it .
 * < p > FastClass works by generating a type in the same package as the target { @ code type } . This
 * may or may not work depending on the access level of the class / member . It breaks down into the
 * following cases depending on accessibility :
 * < ul >
 * < li > Public : This always works since we can generate the type into the { @ link BridgeClassLoader }
 * which ensures there are no versioning issues .
 * < li > Package private and Protected : This works as long as :
 * < ul >
 * < li > We can generate into the same classloader as the type . This is not possible for JDK
 * types which use the ' bootstrap ' loader .
 * < li > The classloader of the type has the same version of { @ code FastClass } as we do . This
 * may be violated when running in OSGI bundles .
 * < / ul >
 * < li > Private : This never works .
 * < / ul >
 * If we are unable to generate the type , then we return null and callers should work around by
 * using normal java reflection . */
public static net . sf . cglib . reflect . FastClass newFastClassForMember ( Class < ? > type , Member member ) { } }

implementation:
if ( ! new net . sf . cglib . core . VisibilityPredicate ( type , false ) . evaluate ( member ) ) { // the member cannot be indexed by fast class . Bail out .
return null ; } boolean publiclyCallable = isPubliclyCallable ( member ) ; if ( ! publiclyCallable && ! hasSameVersionOfCglib ( type . getClassLoader ( ) ) ) { // The type is in a classloader with a different version of cglib and is not publicly visible
// ( so we can ' t use the bridge classloader to work around ) . Bail out .
return null ; } net . sf . cglib . reflect . FastClass . Generator generator = new net . sf . cglib . reflect . FastClass . Generator ( ) ; if ( publiclyCallable ) { // Use the bridge classloader if we can
generator . setClassLoader ( getClassLoader ( type ) ) ; } generator . setType ( type ) ; generator . setNamingPolicy ( FASTCLASS_NAMING_POLICY ) ; if ( logger . isLoggable ( Level . FINE ) ) { logger . fine ( "Loading " + type + " FastClass with " + generator . getClassLoader ( ) ) ; } return generator . create ( ) ;


signature:
public class BytecodeGen { /** * Returns true if the types classloader has the same version of cglib that BytecodeGen has . This
 * only returns false in strange OSGI situations , but it prevents us from using FastClass for non
 * public members . */
private static boolean hasSameVersionOfCglib ( ClassLoader classLoader ) { } }

implementation: Class < ? > fc = net . sf . cglib . reflect . FastClass . class ; try { return classLoader . loadClass ( fc . getName ( ) ) == fc ; } catch ( ClassNotFoundException e ) { return false ; }


signature:
public class BytecodeGen { /** * Returns true if the member can be called by a fast class generated in a different classloader . */
private static boolean isPubliclyCallable ( Member member ) { } }

implementation: if ( ! Modifier . isPublic ( member . getModifiers ( ) ) ) { return false ; } Class < ? > [ ] parameterTypes ; if ( member instanceof Constructor ) { parameterTypes = ( ( Constructor ) member ) . getParameterTypes ( ) ; } else { Method method = ( Method ) member ; if ( ! Modifier . isPublic ( method . getReturnType ( ) . getModifiers ( ) ) ) { return false ; } parameterTypes = method . getParameterTypes ( ) ; } for ( Class < ? > type : parameterTypes ) { if ( ! Modifier . isPublic ( type . getModifiers ( ) ) ) { return false ; } } return true ;


signature:
public class ProviderMethod { /** * Creates a { @ link ProviderMethod } .
 * < p > Unless { @ code skipFastClassGeneration } is set , this will use { @ link
 * net . sf . cglib . reflect . FastClass } to invoke the actual method , since it is significantly faster .
 * However , this will fail if the method is { @ code private } or { @ code protected } , since fastclass
 * is subject to java access policies . */
static < T > ProviderMethod < T > create ( Key < T > key , Method method , Object instance , ImmutableSet < Dependency < ? > > dependencies , Class < ? extends Annotation > scopeAnnotation , boolean skipFastClassGeneration , Annotation annotation ) { } }

implementation:
int modifiers = method . getModifiers ( ) ; /* if [ AOP ] */
if ( ! skipFastClassGeneration ) { try { net . sf . cglib . reflect . FastClass fc = BytecodeGen . newFastClassForMember ( method ) ; if ( fc != null ) { return new FastClassProviderMethod < T > ( key , fc , method , instance , dependencies , scopeAnnotation , annotation ) ; } } catch ( net . sf . cglib . core . CodeGenerationException e ) { /* fall - through */
} } /* end [ AOP ] */
if ( ! Modifier . isPublic ( modifiers ) || ! Modifier . isPublic ( method . getDeclaringClass ( ) . getModifiers ( ) ) ) { method . setAccessible ( true ) ; } return new ReflectionProviderMethod < T > ( key , method , instance , dependencies , scopeAnnotation , annotation ) ;


signature:
public class Parameter { /** * Returns the Guice { @ link Key } for this parameter . */
public Object getValue ( Injector injector ) { } }

implementation: if ( null == provider ) { synchronized ( this ) { if ( null == provider ) { provider = isProvider ? injector . getProvider ( getBindingForType ( getProvidedType ( type ) ) ) : injector . getProvider ( getPrimaryBindingKey ( ) ) ; } } } return isProvider ? provider : provider . get ( ) ;


signature:
public class Parameter { /** * Replace annotation instances with annotation types , this is only appropriate for testing if a
 * key is bound and not for injecting .
 * < p > See Guice bug 125 , https : / / github . com / google / guice / issues / 125 */
public Key < ? > fixAnnotations ( Key < ? > key ) { } }

implementation: return key . getAnnotation ( ) == null ? key : Key . get ( key . getTypeLiteral ( ) , key . getAnnotation ( ) . annotationType ( ) ) ;


signature:
public class Parameter { /** * Returns the unique binding annotation from the specified list , or { @ code null } if there are
 * none .
 * @ throws IllegalStateException if multiple binding annotations exist . */
private Annotation getBindingAnnotation ( Annotation [ ] annotations ) { } }

implementation: Annotation bindingAnnotation = null ; for ( Annotation annotation : annotations ) { if ( Annotations . isBindingAnnotation ( annotation . annotationType ( ) ) ) { checkArgument ( bindingAnnotation == null , "Parameter has multiple binding annotations: %s and %s" , bindingAnnotation , annotation ) ; bindingAnnotation = annotation ; } } return bindingAnnotation ;


signature:
public class Initializer { /** * Registers an instance for member injection when that step is performed .
 * @ param instance an instance that optionally has members to be injected ( each annotated
 * with @ Inject ) .
 * @ param binding the binding that caused this initializable to be created , if it exists .
 * @ param source the source location that this injection was requested */
< T > Initializable < T > requestInjection ( InjectorImpl injector , T instance , Binding < T > binding , Object source , Set < InjectionPoint > injectionPoints ) { } }

implementation:
checkNotNull ( source ) ; Preconditions . checkState ( ! validationStarted , "Member injection could not be requested after validation is started" ) ; ProvisionListenerStackCallback < T > provisionCallback = binding == null ? null : injector . provisionListenerStore . get ( binding ) ; // short circuit if the object has no injections or listeners .
if ( instance == null || ( injectionPoints . isEmpty ( ) && ! injector . membersInjectorStore . hasTypeListeners ( ) && provisionCallback == null ) ) { return Initializables . of ( instance ) ; } if ( initializablesCache . containsKey ( instance ) ) { @ SuppressWarnings ( "unchecked" ) // Map from T to InjectableReference < T >
Initializable < T > cached = ( Initializable < T > ) initializablesCache . get ( instance ) ; return cached ; } InjectableReference < T > injectableReference = new InjectableReference < T > ( injector , instance , binding == null ? null : binding . getKey ( ) , provisionCallback , source , cycleDetectingLockFactory . create ( instance . getClass ( ) ) ) ; initializablesCache . put ( instance , injectableReference ) ; pendingInjections . add ( injectableReference ) ; return injectableReference ;


signature:
public class Initializer { /** * Prepares member injectors for all injected instances . This prompts Guice to do static analysis
 * on the injected instances . */
void validateOustandingInjections ( Errors errors ) { } }

implementation: validationStarted = true ; initializablesCache . clear ( ) ; for ( InjectableReference < ? > reference : pendingInjections ) { try { reference . validate ( errors ) ; } catch ( ErrorsException e ) { errors . merge ( e . getErrors ( ) ) ; } }