signature:
public class Reactor { /** * Map a reactor object like { @ link Flux } or { @ link Mono } into a { @ link Deferred } object .
 * < pre > { @ code
 * import org . jooby . reactor . Reactor ;
 * with ( ( ) - > {
 * get ( " / lux " , req - > Flux . . . ) ;
 * get ( " / mono " , req - > Mono . . . ) ;
 * } ) . map ( Reactor . reactor (
 * flux - > flux . publishOn ( Computations . concurrent ( ) ) ,
 * mono - > mono . publishOn ( Computations . concurrent ( ) ) ) ;
 * } < / pre >
 * @ param flux A flux adapter .
 * @ param mono A mono adapter .
 * @ return A new mapper . */
@ SuppressWarnings ( "unchecked" ) public static Route . Mapper < Object > reactor ( final Function < Flux , Flux > flux , final Function < Mono , Mono > mono ) { } }

implementation: requireNonNull ( flux , "Flux's adapter is required." ) ; requireNonNull ( mono , "Mono's adapter is required." ) ; return Route . Mapper . create ( "reactor" , value -> { if ( value instanceof Flux ) { return new Deferred ( deferred -> flux . apply ( ( Flux ) value ) . consume ( deferred :: set , deferred :: set ) ) ; } if ( value instanceof Mono ) { return new Deferred ( deferred -> mono . apply ( ( Mono ) value ) . consume ( deferred :: set , deferred :: set ) ) ; } return value ; } ) ;


signature:
public class Deferred { /** * { @ link # resolve ( Object ) } or { @ link # reject ( Throwable ) } the given value .
 * @ param value Resolved value . */
@ Override @ Nonnull public Result set ( final Object value ) { } }

implementation: if ( value instanceof Throwable ) { reject ( ( Throwable ) value ) ; } else { resolve ( value ) ; } return this ;


signature:
public class Deferred { /** * Resolve the deferred value and handle it . This method will send the response to a client and
 * cleanup and close all the resources .
 * @ param value A value for this deferred . */
public void resolve ( @ Nullable final Object value ) { } }

implementation: if ( value == null ) { handler . handle ( null , null ) ; } else { Result result ; if ( value instanceof Result ) { super . set ( value ) ; result = ( Result ) value ; } else { super . set ( value ) ; result = clone ( ) ; } handler . handle ( result , null ) ; }


signature:
public class Deferred { /** * Setup a handler for this deferred . Application code should never call this method : INTERNAL USE
 * ONLY .
 * @ param req Current request .
 * @ param handler A response handler .
 * @ throws Exception If initializer fails to start . */
public void handler ( final Request req , final Handler handler ) throws Exception { } }

implementation: this . handler = requireNonNull ( handler , "Handler is required." ) ; if ( initializer != null ) { initializer . run ( req , this ) ; }


signature:
public class Deferred { /** * Functional version of { @ link Deferred # Deferred ( Initializer ) } . To use ideally with one
 * or more { @ link Executor } :
 * < pre > { @ code
 * executor ( " cached " , Executors . newCachedExecutor ( ) ) ;
 * get ( " / fork " , deferred ( " cached " , ( ) - > {
 * return " OK " ;
 * } < / pre >
 * This handler automatically { @ link Deferred # resolve ( Object ) } or
 * { @ link Deferred # reject ( Throwable ) } a route handler response .
 * @ param executor Executor to run the deferred .
 * @ param handler Application block .
 * @ return A new deferred handler . */
@ Nonnull public static Deferred deferred ( final String executor , final Route . ZeroArgHandler handler ) { } }

implementation: return deferred ( executor , req -> handler . handle ( ) ) ;


signature:
public class Deferred { /** * Functional version of { @ link Deferred # Deferred ( Initializer ) } . To use ideally with one
 * or more { @ link Executor } :
 * < pre > { @ code
 * executor ( " cached " , Executors . newCachedExecutor ( ) ) ;
 * get ( " / fork " , deferred ( " cached " , req - > {
 * return req . param ( " value " ) . value ( ) ;
 * } < / pre >
 * This handler automatically { @ link Deferred # resolve ( Object ) } or
 * { @ link Deferred # reject ( Throwable ) } a route handler response .
 * @ param executor Executor to run the deferred .
 * @ param handler Application block .
 * @ return A new deferred handler . */
@ Nonnull public static Deferred deferred ( final String executor , final Route . OneArgHandler handler ) { } }

implementation: return new Deferred ( executor , ( req , deferred ) -> { try { deferred . resolve ( handler . handle ( req ) ) ; } catch ( Throwable x ) { deferred . reject ( x ) ; } } ) ;


signature:
public class Raml { /** * Get a path for the given pattern . If the path doesn ' t exist , a new path will be created .
 * @ param pattern Pattern .
 * @ return Path for the given pattern . */
public RamlPath path ( String pattern ) { } }

implementation: RamlPath path = resources . get ( pattern ) ; if ( path == null ) { path = new RamlPath ( ) ; resources . put ( pattern , path ) ; } return path ;


signature:
public class Raml { /** * Define / map a custom Java type to RAML type .
 * < pre >
 * RamlType uuid = raml . define ( UUID . class , RamlType . STRING ) ;
 * uuid . setPattern ( " . . . " ) ;
 * < / pre >
 * @ param javaType Java type .
 * @ param baseType RAML base type .
 * @ return New RAML type . */
public RamlType define ( Type javaType , RamlType baseType ) { } }

implementation: Objects . requireNonNull ( javaType , "Java type required." ) ; Objects . requireNonNull ( baseType , "Raml type required." ) ; if ( types == null ) { types = new LinkedHashMap < > ( ) ; } String typeName = MoreTypes . getRawType ( javaType ) . getSimpleName ( ) ; RamlType ramlType = new RamlType ( baseType . getType ( ) , typeName ) ; types . put ( typeName , ramlType ) ; return ramlType ;


signature:
public class Raml { /** * Register a Java type and produces an equivalent RAML type . It returns an existing RAML type if
 * the Java type was registered already .
 * @ param type Java type .
 * @ return RAML type . */
public RamlType define ( Type type ) { } }

implementation: if ( types == null ) { types = new LinkedHashMap < > ( ) ; } Type componentType = componentType ( type ) ; String typeName = MoreTypes . getRawType ( componentType ) . getSimpleName ( ) ; RamlType ramlType = RamlType . valueOf ( typeName ) ; if ( ramlType . isObject ( ) ) { RamlType existing = types . get ( typeName ) ; if ( existing == null ) { ModelConverters converter = ModelConverters . getInstance ( ) ; Property property = converter . readAsProperty ( componentType ) ; Map < PropertyBuilder . PropertyId , Object > args = new EnumMap < > ( PropertyBuilder . PropertyId . class ) ; for ( Map . Entry < String , Model > entry : converter . readAll ( componentType ) . entrySet ( ) ) { define ( entry . getKey ( ) , entry . getValue ( ) ) ; } ramlType = define ( typeName , PropertyBuilder . toModel ( PropertyBuilder . merge ( property , args ) ) ) ; } else { ramlType = existing ; } } return type != componentType ? ramlType . toArray ( ) : ramlType ;


signature:
public class Raml { /** * Convert this RAML object to Yaml .
 * @ return Yaml string .
 * @ throws IOException If something goes wrong . */
public String toYaml ( ) throws IOException { } }

implementation: YAMLMapper mapper = new YAMLMapper ( ) ; mapper . setSerializationInclusion ( JsonInclude . Include . NON_NULL ) ; mapper . configure ( YAMLGenerator . Feature . ALWAYS_QUOTE_NUMBERS_AS_STRINGS , false ) ; mapper . configure ( YAMLGenerator . Feature . MINIMIZE_QUOTES , true ) ; return "#%RAML 1.0\n" + mapper . writer ( ) . withDefaultPrettyPrinter ( ) . writeValueAsString ( this ) ;


signature:
public class RouteResponse { /** * Get status codes .
 * @ return Status codes . */
public Map < Integer , String > status ( ) { } }

implementation: return Optional . ofNullable ( status ) . orElse ( ImmutableMap . of ( ) ) ;


signature:
public class RouteResponse { /** * Status code .
 * @ return Status code . */
public int statusCode ( ) { } }

implementation: return status ( ) . entrySet ( ) . stream ( ) . map ( it -> it . getKey ( ) ) . filter ( code -> code >= 200 && code < 400 ) . findFirst ( ) . orElseGet ( ( ) -> type ( ) == void . class ? 204 : 200 ) ;


signature:
public class RouteResponse { /** * Set status code map .
 * @ param status Status code map .
 * @ return This response . */
public RouteResponse status ( final Map < Integer , String > status ) { } }

implementation: if ( status != null ) { if ( this . status == null ) { this . status = new LinkedHashMap < > ( ) ; this . status . putAll ( status ) ; } } return this ;


signature:
public class RamlResponse { /** * Set media type .
 * @ param mediaType Media type .
 * @ param body RAML type . */
public void setMediaType ( final String mediaType , RamlType body ) { } }

implementation: if ( this . mediaType == null ) { this . mediaType = new LinkedHashMap < > ( ) ; } this . mediaType . put ( mediaType , body ) ;


signature:
public class SslContext { /** * Generates a key specification for an ( encrypted ) private key .
 * @ param password characters , if { @ code null } or empty an unencrypted key is assumed
 * @ param key bytes of the DER encoded private key
 * @ return a key specification
 * @ throws IOException if parsing { @ code key } fails
 * @ throws NoSuchAlgorithmException if the algorithm used to encrypt { @ code key } is unkown
 * @ throws NoSuchPaddingException if the padding scheme specified in the decryption algorithm is
 * unkown
 * @ throws InvalidKeySpecException if the decryption key based on { @ code password } cannot be
 * generated
 * @ throws InvalidKeyException if the decryption key based on { @ code password } cannot be used to
 * decrypt
 * { @ code key }
 * @ throws InvalidAlgorithmParameterException if decryption algorithm parameters are somehow
 * faulty */
protected static PKCS8EncodedKeySpec generateKeySpec ( final char [ ] password , final byte [ ] key ) throws IOException , NoSuchAlgorithmException , NoSuchPaddingException , InvalidKeySpecException , InvalidKeyException , InvalidAlgorithmParameterException { } }

implementation: if ( password == null || password . length == 0 ) { return new PKCS8EncodedKeySpec ( key ) ; } EncryptedPrivateKeyInfo encryptedPrivateKeyInfo = new EncryptedPrivateKeyInfo ( key ) ; SecretKeyFactory keyFactory = SecretKeyFactory . getInstance ( encryptedPrivateKeyInfo . getAlgName ( ) ) ; PBEKeySpec pbeKeySpec = new PBEKeySpec ( password ) ; SecretKey pbeKey = keyFactory . generateSecret ( pbeKeySpec ) ; Cipher cipher = Cipher . getInstance ( encryptedPrivateKeyInfo . getAlgName ( ) ) ; cipher . init ( Cipher . DECRYPT_MODE , pbeKey , encryptedPrivateKeyInfo . getAlgParameters ( ) ) ; return encryptedPrivateKeyInfo . getKeySpec ( cipher ) ;


signature:
public class SslContext { /** * Generates a new { @ link KeyStore } .
 * @ param certChainFile a X . 509 certificate chain file in PEM format ,
 * @ param keyFile a PKCS # 8 private key file in PEM format ,
 * @ param keyPasswordChars the password of the { @ code keyFile } .
 * { @ code null } if it ' s not password - protected .
 * @ return generated { @ link KeyStore } . */
static KeyStore buildKeyStore ( final File certChainFile , final File keyFile , final char [ ] keyPasswordChars ) throws KeyStoreException , NoSuchAlgorithmException , NoSuchPaddingException , InvalidKeySpecException , InvalidAlgorithmParameterException , CertificateException , KeyException , IOException { } }

implementation: ByteBuffer encodedKeyBuf = PemReader . readPrivateKey ( keyFile ) ; byte [ ] encodedKey = encodedKeyBuf . array ( ) ; PKCS8EncodedKeySpec encodedKeySpec = generateKeySpec ( keyPasswordChars , encodedKey ) ; PrivateKey key ; try { key = KeyFactory . getInstance ( "RSA" ) . generatePrivate ( encodedKeySpec ) ; } catch ( InvalidKeySpecException ignore ) { try { key = KeyFactory . getInstance ( "DSA" ) . generatePrivate ( encodedKeySpec ) ; } catch ( InvalidKeySpecException ignore2 ) { try { key = KeyFactory . getInstance ( "EC" ) . generatePrivate ( encodedKeySpec ) ; } catch ( InvalidKeySpecException e ) { throw new InvalidKeySpecException ( "Neither RSA, DSA nor EC worked" , e ) ; } } } CertificateFactory cf = CertificateFactory . getInstance ( "X.509" ) ; List < ByteBuffer > certs = PemReader . readCertificates ( certChainFile ) ; List < Certificate > certChain = new ArrayList < Certificate > ( certs . size ( ) ) ; for ( ByteBuffer buf : certs ) { certChain . add ( cf . generateCertificate ( new ByteArrayInputStream ( buf . array ( ) ) ) ) ; } KeyStore ks = KeyStore . getInstance ( "JKS" ) ; ks . load ( null , null ) ; ks . setKeyEntry ( "key" , key , keyPasswordChars , certChain . toArray ( new Certificate [ certChain . size ( ) ] ) ) ; return ks ;


signature:
public class SslContext { /** * Build a { @ link TrustManagerFactory } from a certificate chain file .
 * @ param certChainFile The certificate file to build from .
 * @ param trustManagerFactory The existing { @ link TrustManagerFactory } that will be used if not
 * { @ code null } .
 * @ return A { @ link TrustManagerFactory } which contains the certificates in { @ code certChainFile } */
protected static TrustManagerFactory buildTrustManagerFactory ( final File certChainFile , TrustManagerFactory trustManagerFactory ) throws NoSuchAlgorithmException , CertificateException , KeyStoreException , IOException { } }

implementation:
KeyStore ks = KeyStore . getInstance ( "JKS" ) ; ks . load ( null , null ) ; CertificateFactory cf = CertificateFactory . getInstance ( "X.509" ) ; List < ByteBuffer > certs = PemReader . readCertificates ( certChainFile ) ; for ( ByteBuffer buf : certs ) { X509Certificate cert = ( X509Certificate ) cf . generateCertificate ( new ByteArrayInputStream ( buf . array ( ) ) ) ; X500Principal principal = cert . getSubjectX500Principal ( ) ; ks . setCertificateEntry ( principal . getName ( "RFC2253" ) , cert ) ; } // Set up trust manager factory to use our key store .
if ( trustManagerFactory == null ) { trustManagerFactory = TrustManagerFactory . getInstance ( TrustManagerFactory . getDefaultAlgorithm ( ) ) ; } trustManagerFactory . init ( ks ) ; return trustManagerFactory ;


signature:
public class Jade { /** * Configure callback that let you tweak or modified a { @ link JadeConfiguration } .
 * @ param callback A callback .
 * @ return This module . */
public Jade doWith ( final Consumer < JadeConfiguration > callback ) { } }

implementation: requireNonNull ( callback , "Configurer callback is required." ) ; return doWith ( ( j , c ) -> callback . accept ( j ) ) ;


signature:
public class RouteParameter { /** * List of enum values when the { @ link # type ( ) } represents an enum .
 * @ return Enum values . */
public List < String > enums ( ) { } }

implementation: return Optional . ofNullable ( MoreTypes . getRawType ( type ) ) . map ( Class :: getEnumConstants ) . filter ( Objects :: nonNull ) . map ( values -> Arrays . asList ( values ) . stream ( ) . map ( value -> ( ( Enum ) value ) . name ( ) ) . collect ( Collectors . toList ( ) ) ) . orElse ( Collections . emptyList ( ) ) ;


signature:
public class Result { /** * Get a result value for the given types ( accept header ) .
 * @ param types Accept header .
 * @ return Result content . */
@ Nonnull public Optional < Object > ifGet ( final List < MediaType > types ) { } }

implementation: return Optional . ofNullable ( value ) ;


signature:
public class Result { /** * Get a result value for the given types ( accept header ) .
 * @ param types Accept header .
 * @ param < T > Value type .
 * @ return Result content or < code > null < / code > . */
@ SuppressWarnings ( "unchecked" ) @ Nullable public < T > T get ( final List < MediaType > types ) { } }

implementation: return ( T ) value ;


signature:
public class Result { /** * Sets a response header with the given name and value . If the header had already been set ,
 * the new value overwrites the previous one .
 * @ param name Header ' s name .
 * @ param value Header ' s value .
 * @ return This content . */
@ Nonnull public Result header ( final String name , final Object value ) { } }

implementation: requireNonNull ( name , "Header's name is required." ) ; requireNonNull ( value , "Header's value is required." ) ; setHeader ( name , value ) ; return this ;


signature:
public class Result { /** * Sets a response header with the given name and value . If the header had already been set ,
 * the new value overwrites the previous one .
 * @ param name Header ' s name .
 * @ param values Header ' s values .
 * @ return This content . */
@ Nonnull public Result header ( final String name , final Object ... values ) { } }

implementation: requireNonNull ( name , "Header's name is required." ) ; requireNonNull ( values , "Header's values are required." ) ; return header ( name , ImmutableList . copyOf ( values ) ) ;


signature:
public class Result { /** * Sets a response header with the given name and value . If the header had already been set ,
 * the new value overwrites the previous one .
 * @ param name Header ' s name .
 * @ param values Header ' s values .
 * @ return This content . */
@ Nonnull public Result header ( final String name , final Iterable < Object > values ) { } }

implementation: requireNonNull ( name , "Header's name is required." ) ; requireNonNull ( values , "Header's values are required." ) ; setHeader ( name , values ) ; return this ;


signature:
public class Ebeanby { /** * package for test .
 * @ return An enhancer task . It runs once per classloader instance . */
static Throwing . Runnable runEnhancer ( ) { } }

implementation: return ( ) -> { Set < String > packages = PKG . getAndSet ( null ) ; if ( packages != null ) { EbeanEnhancer . newEnhancer ( ) . run ( packages ) ; } } ;


signature:
public class RamlMethod { /** * Set media types .
 * @ param mediaType Media types . */
public void setMediaType ( final List < String > mediaType ) { } }

implementation: this . mediaType = mediaType == null ? null : ( mediaType . isEmpty ( ) ? null : mediaType ) ;


signature:
public class RamlMethod { /** * Get or create a query parameter using the giving name .
 * @ param name Parameter name .
 * @ return Query parameter . */
public RamlParameter queryParameter ( String name ) { } }

implementation: if ( queryParameters == null ) { queryParameters = new LinkedHashMap < > ( ) ; } RamlParameter param = queryParameters . get ( name ) ; if ( param == null ) { param = new RamlParameter ( name ) ; queryParameters . put ( name , param ) ; } return param ;


signature:
public class RamlMethod { /** * Get or create a form parameter using the giving name .
 * @ param name Parameter name .
 * @ return Form parameter . */
public RamlParameter formParameter ( String name ) { } }

implementation: if ( formParameters == null ) { formParameters = new LinkedHashMap < > ( ) ; } RamlParameter param = formParameters . get ( name ) ; if ( param == null ) { param = new RamlParameter ( name ) ; formParameters . put ( name , param ) ; } return param ;


signature:
public class RamlMethod { /** * Get or create a header parameter using the giving name .
 * @ param name Parameter name .
 * @ return Header parameter . */
public RamlParameter headerParameter ( String name ) { } }

implementation: if ( headers == null ) { headers = new LinkedHashMap < > ( ) ; } RamlParameter param = headers . get ( name ) ; if ( param == null ) { param = new RamlParameter ( name ) ; headers . put ( name , param ) ; } return param ;


signature:
public class RamlMethod { /** * Get or create a response using the given status code .
 * @ param status Status code .
 * @ return RAML response . */
public RamlResponse response ( Integer status ) { } }

implementation: if ( responses == null ) { responses = new LinkedHashMap < > ( ) ; } RamlResponse response = responses . get ( status ) ; if ( response == null ) { response = new RamlResponse ( ) ; responses . put ( status , response ) ; } return response ;


signature:
public class RequestLogger { /** * Override the default date formatter .
 * @ param formatter New formatter to use .
 * @ return This instance . */
public RequestLogger dateFormatter ( final DateTimeFormatter formatter ) { } }

implementation: requireNonNull ( formatter , "Formatter required." ) ; return dateFormatter ( ts -> formatter . format ( Instant . ofEpochMilli ( ts ) ) ) ;


signature:
public class RequestLogger { /** * Override the default date formatter .
 * @ param formatter New formatter to use .
 * @ return This instance . */
public RequestLogger dateFormatter ( final Function < Long , String > formatter ) { } }

implementation: requireNonNull ( formatter , "Formatter required." ) ; this . df = formatter ; return this ;


signature:
public class Hbv { /** * Setup a configurer callback .
 * @ param configurer Configurer callback .
 * @ return This module . */
public Hbv doWith ( final Consumer < HibernateValidatorConfiguration > configurer ) { } }

implementation: requireNonNull ( configurer , "Configurer callback is required." ) ; this . configurer = ( hvc , conf ) -> configurer . accept ( hvc ) ; return this ;


signature:
public class ReaderInputStream { /** * Read the specified number of bytes into an array .
 * @ param b the byte array to read into
 * @ param off the offset to start reading bytes into
 * @ param len the number of bytes to read
 * @ return the number of bytes read or < code > - 1 < / code > if the end of the stream has been reached
 * @ throws IOException if an I / O error occurs */
@ Override public int read ( final byte [ ] b , int off , int len ) throws IOException { } }

implementation:
int read = 0 ; while ( len > 0 ) { if ( encoderOut . position ( ) > 0 ) { encoderOut . flip ( ) ; int c = Math . min ( encoderOut . remaining ( ) , len ) ; encoderOut . get ( b , off , c ) ; off += c ; len -= c ; read += c ; encoderOut . compact ( ) ; } else { if ( ! endOfInput && ( lastCoderResult == null || lastCoderResult . isUnderflow ( ) ) ) { encoderIn . compact ( ) ; int position = encoderIn . position ( ) ; // We don ' t use Reader # read ( CharBuffer ) here because it is more efficient
// to write directly to the underlying char array ( the default implementation
// copies data to a temporary char array ) .
int c = reader . read ( encoderIn . array ( ) , position , encoderIn . remaining ( ) ) ; if ( c == - 1 ) { endOfInput = true ; } else { encoderIn . position ( position + c ) ; } encoderIn . flip ( ) ; } lastCoderResult = encoder . encode ( encoderIn , encoderOut , endOfInput ) ; if ( endOfInput && encoderOut . position ( ) == 0 ) { break ; } } } return read == 0 && endOfInput ? - 1 : read ;


signature:
public class FileWatcher { /** * Register the given directory tree and execute the given handler whenever a file / folder has been
 * created , modified or delete .
 * @ param path Directory to register .
 * @ param handler Handler to execute .
 * @ return This module . */
public FileWatcher register ( final Path path , final Class < ? extends FileEventHandler > handler ) { } }

implementation: return register ( path , handler , EMPTY ) ;


signature:
public class FileWatcher { /** * Register the given directory tree and execute the given handler whenever a file / folder has been
 * created , modified or delete . The configurer callback allow you to customize default event
 * kinds , filter specific file types and restrict the watch scope lookup to direct files .
 * @ param path Directory to register .
 * @ param handler Handler to execute .
 * @ param configurer Configurer callback .
 * @ return This module .
 * @ see FileEventOptions */
public FileWatcher register ( final Path path , final Class < ? extends FileEventHandler > handler , final Consumer < FileEventOptions > configurer ) { } }

implementation: return register ( c -> path , p -> new FileEventOptions ( p , handler ) , configurer ) ;


signature:
public class FileWatcher { /** * Register the given directory tree and execute the given handler whenever a file / folder has been
 * created , modified or delete .
 * @ param path Directory to register .
 * @ param handler Handler to execute .
 * @ return This module . */
public FileWatcher register ( final Path path , final FileEventHandler handler ) { } }

implementation: return register ( c -> path , p -> new FileEventOptions ( p , handler ) , EMPTY ) ;


signature:
public class FileWatcher { /** * Register the given directory tree and execute the given handler whenever a file / folder has been
 * created , modified or delete .
 * @ param property Directory to register .
 * @ param handler Handler to execute .
 * @ return This module . */
public FileWatcher register ( final String property , final FileEventHandler handler ) { } }

implementation: return register ( c -> Paths . get ( c . getString ( property ) ) , p -> new FileEventOptions ( p , handler ) , EMPTY ) ;


signature:
public class FileWatcher { /** * Register the given directory tree and execute the given handler whenever a file / folder has been
 * created , modified or delete .
 * @ param property Directory to register .
 * @ param handler Handler to execute .
 * @ return This module . */
public FileWatcher register ( final String property , final Class < ? extends FileEventHandler > handler ) { } }

implementation: return register ( property , handler , EMPTY ) ;


signature:
public class Requery { /** * Advanced configuration callback :
 * < pre > { @ code
 * use ( new Requery ( Models . DEFAULT )
 * . doWith ( builder - > {
 * builder . useDefaultLogging ( ) ;
 * } < / pre >
 * @ param configurer Configurer callback .
 * @ return This module . */
public Requery doWith ( final Consumer < ConfigurationBuilder > configurer ) { } }

implementation: requireNonNull ( configurer , "Configurer callback required." ) ; return doWith ( ( c , b ) -> configurer . accept ( b ) ) ;


signature:
public class Requery { /** * Creates a Requery module with RxJava data store .
 * < pre > { @ code
 * use ( Requery . reactive ( Models . DEFAULT ) ) ;
 * get ( " / " , ( ) - > {
 * ReactiveEntityStore store = require ( ReactiveEntityStore . class ) ;
 * / / work with reactive store
 * } < / pre >
 * @ param name Database name .
 * @ param model Entity model .
 * @ return A new { @ link Requery } module . */
public static Requery reactive ( final String name , final EntityModel model ) { } }

implementation: return new Requery ( name , ReactiveEntityStore . class , model , conf -> ReactiveSupport . toReactiveStore ( new EntityDataStore < > ( conf ) ) ) ;


signature:
public class Requery { /** * Creates a Requery module with Reactor data store .
 * < pre > { @ code
 * use ( Requery . reactor ( Models . DEFAULT ) ) ;
 * get ( " / " , ( ) - > {
 * ReactorEntityStore store = require ( ReactorEntityStore . class ) ;
 * / / work with reactive store
 * } < / pre >
 * @ param name Database name .
 * @ param model Entity model .
 * @ return A new { @ link Requery } module . */
public static Requery reactor ( final String name , final EntityModel model ) { } }

implementation: return new Requery ( name , ReactorEntityStore . class , model , conf -> new ReactorEntityStore < > ( new EntityDataStore < > ( conf ) ) ) ;


signature:
public class Requery { /** * Creates an async Requery module with Java 8 data store .
 * < pre > { @ code
 * use ( Requery . completionStage ( Models . DEFAULT ) ) ;
 * get ( " / " , ( ) - > {
 * CompletionStageEntityStore store = require ( CompletionStageEntityStore . class ) ;
 * / / work with reactive store
 * } < / pre >
 * @ param name Database name .
 * @ param model Entity model .
 * @ return A new { @ link Requery } module . */
public static Requery completionStage ( final String name , final EntityModel model ) { } }

implementation: return new Requery ( name , CompletionStageEntityStore . class , model , conf -> new CompletableEntityStore ( new EntityDataStore < > ( conf ) ) ) ;


signature:
public class Requery { /** * Creates a Kotlin Requery module .
 * < pre > { @ code
 * use ( Requery . kotlin ( Models . DEFAULT ) ) ;
 * get ( " / " , ( ) - > {
 * KotlinEntityDataStore store = require ( KotlinEntityDataStore . class ) ;
 * / / work with kotlin store
 * } < / pre >
 * @ param name Database name .
 * @ param model Entity model .
 * @ return A new { @ link Requery } module . */
public static Requery kotlin ( final String name , final EntityModel model ) { } }

implementation: return new Requery ( name , KotlinEntityDataStore . class , model , conf -> new KotlinEntityDataStore < > ( conf ) ) ;


signature:
public class XSS { /** * Set JavaScript escape type and level .
 * @ param type Type .
 * @ param level Level .
 * @ return This module . */
public XSS js ( final JavaScriptEscapeType type , final JavaScriptEscapeLevel level ) { } }

implementation: this . jslevel = requireNonNull ( level , "Level required." ) ; this . jstype = requireNonNull ( type , "Type required." ) ; return this ;


signature:
public class XSS { /** * Set HTML escape type and level .
 * @ param type Type .
 * @ param level Level .
 * @ return This module . */
public XSS html ( final HtmlEscapeType type , final HtmlEscapeLevel level ) { } }

implementation: this . htmllevel = requireNonNull ( level , "Level required." ) ; this . htmltype = requireNonNull ( type , "Type required." ) ; return this ;


signature:
public class XSS { /** * Set JSON escape type and level .
 * @ param type Type .
 * @ param level Level .
 * @ return This module . */
public XSS json ( final JsonEscapeType type , final JsonEscapeLevel level ) { } }

implementation: this . jsonlevel = requireNonNull ( level , "Level required." ) ; this . jsontype = requireNonNull ( type , "Type required." ) ; return this ;


signature:
public class XSS { /** * Set CSS escape type and level .
 * @ param type Type .
 * @ param level Level .
 * @ return This module . */
public XSS css ( final CssStringEscapeType type , final CssStringEscapeLevel level ) { } }

implementation: this . csslevel = requireNonNull ( level , "Level required." ) ; this . csstype = requireNonNull ( type , "Type required." ) ; return this ;


signature:
public class Lambda { /** * Creates a new lambda and set a pattern prefix .
 * @ param prefix Prefix .
 * @ return A new lambda . */
public Lambda prefix ( String prefix ) { } }

implementation: return new Lambda ( declaringClass , owner , desc , implementationName , name , Route . normalize ( prefix + "/" + pattern ) , method . orElse ( null ) , tag ) ;


signature:
public class Lambda { /** * Creates a new lambda and set a pattern prefix .
 * @ param method Method node .
 * @ return A new lambda . */
public Lambda method ( MethodNode method ) { } }

implementation: return new Lambda ( declaringClass , owner , desc , implementationName , name , pattern , method , tag ) ;


signature:
public class SvgSymbol { /** * Read an object path and optionally filter some child paths .
 * @ param path Path to read .
 * @ param without Properties to filter .
 * @ return Properties . */
private Map < String , Object > attrs ( final String path , final String ... without ) { } }

implementation: Map < String , Object > attrs = new LinkedHashMap < > ( get ( path ) ) ; Arrays . asList ( without ) . forEach ( attrs :: remove ) ; return attrs ;


signature:
public class SvgSymbol { /** * Read a svg file and return the svg element ( original ) and a new symbol element ( created from
 * original ) .
 * @ param file Svg file .
 * @ param id ID to use .
 * @ return Svg element ( original ) and a symbol element ( converted ) .
 * @ throws IOException If something goes wrong . */
private Tuple < Element , Element > symbol ( final Path file , final String id ) throws IOException { } }

implementation: Element svg = Jsoup . parse ( file . toFile ( ) , "UTF-8" ) . select ( "svg" ) . first ( ) ; Element symbol = new Element ( Tag . valueOf ( "symbol" ) , "" ) . attr ( "id" , id ) . attr ( "viewBox" , svg . attr ( "viewBox" ) ) ; new ArrayList < > ( svg . childNodes ( ) ) . forEach ( symbol :: appendChild ) ; return new Tuple ( svg , symbol ) ;


signature:
public class SvgSymbol { /** * Generate a CSS rule , it reads the width and height attributes of the svg element or fallback to
 * viewBox attribute .
 * @ param id ID to use .
 * @ param svg Svg element to convert .
 * @ return A css rule . */
private CharSequence css ( final String id , final Element svg ) { } }

implementation: Throwing . Function < String , Tuple < Tuple < Number , String > , Tuple < Number , String > > > viewBox = Throwing . < String , Tuple < Tuple < Number , String > , Tuple < Number , String > > > throwingFunction ( name -> { String vbox = svg . attr ( name ) ; String [ ] dimension = vbox . split ( "\\s+" ) ; return new Tuple ( parse ( dimension [ 2 ] ) , parse ( dimension [ _3 ] ) ) ; } ) . memoized ( ) ; Tuple < Number , String > w = Optional . ofNullable ( Strings . emptyToNull ( svg . attr ( "width" ) ) ) . map ( this :: parse ) . orElseGet ( ( ) -> viewBox . apply ( "viewBox" ) . _1 ) ; Tuple < Number , String > h = Optional . ofNullable ( Strings . emptyToNull ( svg . attr ( "height" ) ) ) . map ( this :: parse ) . orElseGet ( ( ) -> viewBox . apply ( "viewBox" ) . _2 ) ; StringBuilder css = new StringBuilder ( ) ; css . append ( get ( "css.prefix" ) . toString ( ) ) . append ( "." ) . append ( id ) . append ( " {\n  width: " ) . append ( w . _1 ) . append ( w . _2 ) . append ( ";\n" ) . append ( "  height: " ) . append ( h . _1 ) . append ( h . _2 ) . append ( ";\n}" ) ; return css ;


signature:
public class SvgSymbol { /** * Parse a css size unit value , like 10px or 18.919px and optionally round the value to the
 * closest integer .
 * @ param value Value to parse .
 * @ return A tuple with a number and unit ( px , em , etc . . . ) */
private Tuple < Number , String > parse ( final String value ) { } }

implementation: Matcher matcher = SIZE . matcher ( value ) ; if ( matcher . find ( ) ) { String number = matcher . group ( 1 ) ; String unit = matcher . group ( _3 ) ; boolean round = get ( "css.round" ) ; Number num = Double . parseDouble ( number ) ; return new Tuple ( round ? Math . round ( num . doubleValue ( ) ) : num , unit ) ; } return null ;


signature:
public class SvgSymbol { /** * Write content to file .
 * @ param path Target file .
 * @ param sequence File content .
 * @ throws IOException If something goes wrong . */
private void write ( final Path path , final List < CharSequence > sequence ) throws IOException { } }

implementation: log . debug ( "writing: {}" , path . normalize ( ) . toAbsolutePath ( ) ) ; path . toFile ( ) . getParentFile ( ) . mkdirs ( ) ; Files . write ( path , sequence ) ;


signature:
public class TransactionalRequest { /** * Use a named key for accessing to the request scoped Handle .
 * @ param name Name of request scoped Handle .
 * @ return This object . */
public TransactionalRequest handle ( String name ) { } }

implementation: this . handleKey = Key . get ( Handle . class , Names . named ( name ) ) ; return this ;


signature:
public class SwaggerBuilder { /** * Mostly for kotlin null safe operator and immutable properties .
 * @ param type Target type .
 * @ param model Model .
 * @ return Input model . */
private Model doModel ( Type type , Model model ) { } }

implementation: Map < String , Property > properties = model . getProperties ( ) ; if ( properties != null ) { BeanDescription desc = Json . mapper ( ) . getSerializationConfig ( ) . introspect ( Json . mapper ( ) . constructType ( type ) ) ; for ( BeanPropertyDefinition beanProperty : desc . findProperties ( ) ) { Property property = properties . get ( beanProperty . getName ( ) ) ; if ( property != null ) { property . setRequired ( beanProperty . isRequired ( ) ) ; } } } return model ;


signature:
public class AppModuleLoader { /** * Build a flat jboss module , with some minor exceptions ( like j2v8 ) .
 * @ param name module name .
 * @ param cp Classpath .
 * @ return A new app module loader .
 * @ throws Exception If something goes wrong . */
public static AppModuleLoader build ( final String name , final File ... cp ) throws Exception { } }

implementation: Map < ModuleIdentifier , ModuleSpec > modules = newModule ( name , 0 , "" , cp ) ; return new AppModuleLoader ( modules ) ;


signature:
public class Sse { /** * Server sent event will send a Last - Event - ID header if the server goes down .
 * @ param type Last event id type .
 * @ param < T > Event id type .
 * @ return Last event id . */
@ Nonnull public < T > Optional < T > lastEventId ( final Class < T > type ) { } }

implementation: return lastEventId . toOptional ( type ) ;


signature:
public class Sse { /** * Send an event and set media type .
 * < pre > { @ code
 * sse . send ( new MyObject ( ) , " json " ) ;
 * } < / pre >
 * < pre > { @ code
 * sse . send ( new MyObject ( ) , " json " ) . whenComplete ( ( id , x ) - > {
 * if ( x = = null ) {
 * handleSuccess ( ) ;
 * } else {
 * handleError ( x ) ;
 * } < / pre >
 * The < code > id < / code > of the success callback correspond to the { @ link Event # id ( ) } .
 * @ param data Event data .
 * @ param type Media type , like : json , xml .
 * @ return A future . The success callback contains the { @ link Event # id ( ) } . */
@ Nonnull public CompletableFuture < Optional < Object > > send ( final Object data , final String type ) { } }

implementation: return send ( data , MediaType . valueOf ( type ) ) ;


signature:
public class Sse { /** * Send an event and set media type .
 * < pre > { @ code
 * sse . send ( new MyObject ( ) , " json " ) ;
 * } < / pre >
 * < pre > { @ code
 * sse . send ( new MyObject ( ) , " json " ) . whenComplete ( ( id , x ) - > {
 * if ( x = = null ) {
 * handleSuccess ( ) ;
 * } else {
 * handleError ( x ) ;
 * } < / pre >
 * The < code > id < / code > of the success callback correspond to the { @ link Event # id ( ) } .
 * @ param data Event data .
 * @ param type Media type , like : json , xml .
 * @ return A future . The success callback contains the { @ link Event # id ( ) } . */
@ Nonnull public CompletableFuture < Optional < Object > > send ( final Object data , final MediaType type ) { } }

implementation: return event ( data ) . type ( type ) . send ( ) ;


signature:
public class Sse { /** * Send an event .
 * < pre > { @ code
 * sse . send ( new MyObject ( ) ) ;
 * } < / pre >
 * < pre > { @ code
 * sse . send ( new MyObject ( ) , " json " ) . whenComplete ( ( id , x ) - > {
 * if ( x = = null ) {
 * handleSuccess ( ) ;
 * } else {
 * handleError ( x ) ;
 * } < / pre >
 * The < code > id < / code > of the success callback correspond to the { @ link Event # id ( ) } .
 * @ param data Event data .
 * @ return A future . The success callback contains the { @ link Event # id ( ) } . */
@ Nonnull public CompletableFuture < Optional < Object > > send ( final Object data ) { } }

implementation: return event ( data ) . send ( ) ;


signature:
public class Sse { /** * Ask Guice for the given type .
 * @ param type A service type .
 * @ param < T > Service type .
 * @ return A ready to use object . */
@ Nonnull public < T > T require ( final Class < T > type ) { } }

implementation: return require ( Key . get ( type ) ) ;


signature:
public class Sse { /** * Ask Guice for the given type .
 * @ param name A service name .
 * @ param type A service type .
 * @ param < T > Service type .
 * @ return A ready to use object . */
@ Nonnull public < T > T require ( final String name , final Class < T > type ) { } }

implementation: return require ( Key . get ( type , Names . named ( name ) ) ) ;


signature:
public class Sse { /** * Ask Guice for the given type .
 * @ param type A service type .
 * @ param < T > Service type .
 * @ return A ready to use object . */
@ Nonnull public < T > T require ( final TypeLiteral < T > type ) { } }


signature:
public class Sse { /** * Ask Guice for the given type .
 * @ param key A service key .
 * @ param < T > Service type .
 * @ return A ready to use object . */
@ Nonnull public < T > T require ( final Key < T > key ) { } }

implementation: return injector . getInstance ( key ) ;


signature:
public class Sse { /** * The keep alive time can be used to prevent connections from timing out :
 * < pre > { @ code
 * sse ( " / events / : id " , sse - > {
 * sse . keepAlive ( 15 , TimeUnit . SECONDS ) ;
 * } < / pre >
 * The previous example will sent a < code > ' : ' < / code > message ( empty comment ) every 15 seconds to
 * keep the connection alive . If the client drop the connection , then the
 * { @ link # onClose ( Throwing . Runnable ) } event will be fired it .
 * This feature is useful when you want to detect { @ link # onClose ( Throwing . Runnable ) } events without
 * waiting until you send a new event . But for example , if your application already generate
 * events
 * every 15s , then the use of keep alive is useless and you should avoid it .
 * @ param time Keep alive time .
 * @ param unit Time unit .
 * @ return This instance . */
@ Nonnull public Sse keepAlive ( final int time , final TimeUnit unit ) { } }

implementation: return keepAlive ( unit . toMillis ( time ) ) ;


signature:
public class Sse { /** * The keep alive time can be used to prevent connections from timing out :
 * < pre > { @ code
 * sse ( " / events / : id " , sse - > {
 * sse . keepAlive ( 15 , TimeUnit . SECONDS ) ;
 * } < / pre >
 * The previous example will sent a < code > ' : ' < / code > message ( empty comment ) every 15 seconds to
 * keep the connection alive . If the client drop the connection , then the
 * { @ link # onClose ( Throwing . Runnable ) } event will be fired it .
 * This feature is useful when you want to detect { @ link # onClose ( Throwing . Runnable ) } events without
 * waiting until you send a new event . But for example , if your application already generate
 * events
 * every 15s , then the use of keep alive is useless and you should avoid it .
 * @ param millis Keep alive time in millis .
 * @ return This instance . */
@ Nonnull public Sse keepAlive ( final long millis ) { } }

implementation: scheduler . schedule ( new KeepAlive ( this , millis ) , millis , TimeUnit . MILLISECONDS ) ; return this ;


signature:
public class View { /** * Set a model attribute and override existing attribute .
 * @ param name Attribute ' s name .
 * @ param value Attribute ' s value .
 * @ return This view . */
@ Nonnull public View put ( final String name , final Object value ) { } }

implementation: requireNonNull ( name , "Model name is required." ) ; model . put ( name , value ) ; return this ;


signature:
public class View { /** * Set model attributes and override existing values .
 * @ param values Attribute ' s value .
 * @ return This view . */
@ Nonnull public View put ( final Map < String , ? > values ) { } }

implementation: values . forEach ( ( k , v ) -> model . put ( k , v ) ) ; return this ;


signature:
public class MongoRx { /** * Allow further configuration on the { @ link MongoClientSettings } .
 * @ param configurer Configurer callback .
 * @ return This module . */
public MongoRx doWith ( final BiConsumer < MongoClientSettings . Builder , Config > configurer ) { } }

implementation: this . configurer = requireNonNull ( configurer , "Configurer is required." ) ; return this ;


signature:
public class MongoRx { /** * Allow further configuration on the { @ link MongoClientSettings } .
 * @ param configurer Configurer callback .
 * @ return This module . */
public MongoRx doWith ( final Consumer < MongoClientSettings . Builder > configurer ) { } }

implementation: requireNonNull ( configurer , "Configurer is required." ) ; return doWith ( ( s , c ) -> configurer . accept ( s ) ) ;


signature:
public class MongoRx { /** * Set a { @ link ObservableAdapter } to the { @ link MongoDatabase } created by this module .
 * @ param adapter An { @ link ObservableAdapter } .
 * @ return This module . */
@ SuppressWarnings ( "rawtypes" ) public MongoRx observableAdapter ( final Function < Observable , Observable > adapter ) { } }

implementation: this . adapter = toAdapter ( requireNonNull ( adapter , "Adapter is required." ) ) ; return this ;


signature:
public class LiveCompiler { /** * Add a virtual / fake stacktrace element with the offending file , useful for whoops .
 * @ param ex Stack trace to rewrite .
 * @ return Same exception with new stacktrace . */
private AssetException rewrite ( final AssetException ex ) { } }

implementation: List < StackTraceElement > stacktrace = Lists . newArrayList ( ex . getStackTrace ( ) ) ; List < AssetProblem > problems = ex . getProblems ( ) ; AssetProblem head = problems . get ( 0 ) ; stacktrace . add ( 0 , new StackTraceElement ( head . getFilename ( ) , "" , head . getFilename ( ) , head . getLine ( ) ) ) ; ex . setStackTrace ( stacktrace . toArray ( new StackTraceElement [ stacktrace . size ( ) ] ) ) ; return ex ;


signature:
public class AssetClassLoader { /** * Constructs a new AssetClassLoader that includes the ' public ' dir if present in the current working dir
 * @ param parent parent classloader
 * @ return classloader that includes the public dir if present
 * @ throws IOException if an exception occurred */
public static ClassLoader classLoader ( final ClassLoader parent ) throws IOException { } }

implementation: return classLoader ( parent , new File ( System . getProperty ( "user.dir" ) ) ) ;


signature:
public class AssetClassLoader { /** * Constructs a new AssetClassLoader that includes the ' public ' dir if present in the provided working dir
 * @ param parent parent classloader
 * @ param projectDir working dir to use
 * @ return classloader that includes the public dir if present
 * @ throws IOException if an exception occurred */
public static ClassLoader classLoader ( final ClassLoader parent , File projectDir ) throws IOException { } }

implementation: requireNonNull ( parent , "ClassLoader required." ) ; File publicDir = new File ( projectDir , "public" ) ; if ( publicDir . exists ( ) ) { return new URLClassLoader ( new URL [ ] { publicDir . toURI ( ) . toURL ( ) } , parent ) ; } return parent ;


signature:
public class RouteMethod { /** * Route attributes , copy of { @ link Route . Definition # attributes ( ) }
 * @ return Attributes . */
public Map < String , Object > attributes ( ) { } }

implementation: return Optional . ofNullable ( attributes ) . orElse ( ImmutableMap . of ( ) ) ;


signature:
public class RouteMethod { /** * Set route attributes .
 * @ param attributes Attributes .
 * @ return This method . */
public RouteMethod attributes ( Map < String , Object > attributes ) { } }

implementation: if ( attributes != null ) { if ( this . attributes == null ) { this . attributes = new LinkedHashMap < > ( ) ; } this . attributes . putAll ( attributes ) ; } return this ;


signature:
public class RouteMethod { /** * Set route attribute .
 * @ param name Attribute name .
 * @ param value Attribute value .
 * @ return This method . */
public RouteMethod attribute ( String name , Object value ) { } }

implementation: if ( this . attributes == null ) { this . attributes = new LinkedHashMap < > ( ) ; } this . attributes . put ( name , value ) ; return this ;


signature:
public class RouteMethod { /** * Find a parameter by name and invoke the given callback .
 * @ param name Parameter name .
 * @ param customizer Success callback .
 * @ return This method . */
public RouteMethod param ( String name , Consumer < RouteParameter > customizer ) { } }

implementation: parameters ( ) . stream ( ) . filter ( p -> name . equals ( p . name ( ) ) ) . findFirst ( ) . ifPresent ( customizer ) ; return this ;


signature:
public class Rx { /** * Map a rx object like { @ link Observable } , { @ link Single } or { @ link Completable } into a
 * { @ link Deferred } object .
 * < pre > { @ code
 * import org . jooby . rx . Rx ;
 * use ( new Rx ( ) ) ;
 * with ( ( ) - > {
 * get ( " / 1 " , req - > Observable . . . ) ;
 * get ( " / 2 " , req - > Observable . . . ) ;
 * get ( " / N " , req - > Observable . . . ) ;
 * } ) . map ( Rx . rx (
 * observable - > observable . observeOn ( Scheduler . io ( ) ) ,
 * single - > single . observeOn ( Scheduler . io ( ) ) ,
 * completable - > completable . observeOn ( Scheduler . io ( ) ) ) ) ;
 * } < / pre >
 * @ param observable Observable adapter .
 * @ param single Single adapter .
 * @ return A new mapper . */
public static Route . Mapper < Object > rx ( final Function < Observable , Observable > observable , final Function < Single , Single > single ) { } }

implementation: return rx ( observable , single , Function . identity ( ) ) ;


signature:
public class Rx { /** * Map a rx object like { @ link Observable } , { @ link Single } or { @ link Completable } into a
 * { @ link Deferred } object .
 * < pre > { @ code
 * import org . jooby . rx . Rx ;
 * use ( new Rx ( ) ) ;
 * with ( ( ) - > {
 * get ( " / 1 " , req - > Observable . . . ) ;
 * get ( " / 2 " , req - > Observable . . . ) ;
 * get ( " / N " , req - > Observable . . . ) ;
 * } ) . map ( Rx . rx (
 * observable - > observable . observeOn ( Scheduler . io ( ) ) ,
 * single - > single . observeOn ( Scheduler . io ( ) ) ,
 * completable - > completable . observeOn ( Scheduler . io ( ) ) ) ) ;
 * } < / pre >
 * @ param observable Observable adapter .
 * @ param single Single adapter .
 * @ param completable Completable adapter .
 * @ return A new mapper . */
@ SuppressWarnings ( "unchecked" ) public static Route . Mapper < Object > rx ( final Function < Observable , Observable > observable , final Function < Single , Single > single , final Function < Completable , Completable > completable ) { } }

implementation: requireNonNull ( observable , "Observable's adapter is required." ) ; requireNonNull ( single , "Single's adapter is required." ) ; requireNonNull ( completable , "Completable's adapter is required." ) ; return Route . Mapper . create ( "rx" , v -> { if ( v instanceof Observable ) { return new Deferred ( deferred -> observable . apply ( ( Observable ) v ) . subscribe ( new DeferredSubscriber ( deferred ) ) ) ; } else if ( v instanceof Single ) { return new Deferred ( deferred -> single . apply ( ( Single ) v ) . subscribe ( new DeferredSubscriber ( deferred ) ) ) ; } else if ( v instanceof Completable ) { return new Deferred ( deferred -> completable . apply ( ( Completable ) v ) . subscribe ( new DeferredSubscriber ( deferred ) ) ) ; } return v ; } ) ;


signature:
public class Datastore { /** * Fetch an entity based on its primary key .
 * @ param entityClass Entity class .
 * @ param id Object id .
 * @ return An entity or < code > null < / code > . */
public < T > T get ( final Class < T > entityClass , final Object id ) { } }

implementation: return mapper ( entityClass ) . get ( id ) ;


signature:
public class Datastore { /** * Fetch an entity based on its primary key .
 * @ param entityClass Entity class .
 * @ param id Object id .
 * @ return A ListenableFuture containing an entity or < code > null < / code > */
public < T > ListenableFuture < T > getAsync ( final Class < T > entityClass , final Object id ) { } }

implementation: return mapper ( entityClass ) . getAsync ( id ) ;


signature:
public class Datastore { /** * Delete an entity by ID .
 * @ param entityClass Entity class .
 * @ param id entity ID .
 * @ param options Options . */
public void delete ( final Class < ? > entityClass , final Object id , final Mapper . Option ... options ) { } }

implementation: Mapper mapper = mapper ( entityClass ) ; mapper . delete ( id , options ) ;


signature:
public class Datastore { /** * Delete an entity by ID .
 * @ param entityClass Entity class .
 * @ param id Entity id .
 * @ param options Options .
 * @ return An empty listenable future . */
public ListenableFuture < Void > deleteAsync ( final Class < ? > entityClass , final Object id , final Mapper . Option ... options ) { } }

implementation: Mapper mapper = mapper ( entityClass ) ; return mapper . deleteAsync ( id , options ) ;


signature:
public class Datastore { /** * Delete an entity .
 * @ param entity Entity to delete .
 * @ param options Options . */
public void delete ( final Object entity , final Mapper . Option ... options ) { } }

implementation: Mapper mapper = mapper ( entity . getClass ( ) ) ; mapper . delete ( entity , options ) ;


signature:
public class Datastore { /** * Delete an entity .
 * @ param entity Entity to delete .
 * @ param options Options .
 * @ return An empty listenable future . */
public ListenableFuture < Void > deleteAsync ( final Object entity , final Mapper . Option ... options ) { } }

implementation: Mapper mapper = mapper ( entity . getClass ( ) ) ; return mapper . deleteAsync ( entity , options ) ;


signature:
public class Datastore { /** * Save an entity .
 * @ param entity Entity to save .
 * @ param options Options . */
public < T > void save ( final T entity , final Mapper . Option ... options ) { } }

implementation: Class entityClass = entity . getClass ( ) ; Mapper mapper = mapper ( entityClass ) ; mapper . save ( entity , options ) ;


signature:
public class Datastore { /** * Save an entity .
 * @ param entity Entity to save .
 * @ param options Options .
 * @ return An empty listenable future . */
public < T > ListenableFuture < Void > saveAsync ( final T entity , final Mapper . Option ... options ) { } }

implementation: Class entityClass = entity . getClass ( ) ; Mapper mapper = mapper ( entityClass ) ; return mapper . saveAsync ( entity , options ) ;


signature:
public class Datastore { /** * Execute a query and map result to entityClass .
 * @ param entityClass Entity class .
 * @ param statement Statement to execute .
 * @ param values Statement parameters .
 * @ return A query result . */
public < T > Result < T > query ( final Class < T > entityClass , final String statement , final Map < String , Object > values ) { } }

implementation: return query ( entityClass , new SimpleStatement ( statement , values ) ) ;


signature:
public class Datastore { /** * Execute a query and map result to entityClass .
 * @ param entityClass Entity class .
 * @ param statement Statement to execute .
 * @ return A query result . */
public < T > Result < T > query ( final Class < T > entityClass , final Statement statement ) { } }

implementation: Mapper < T > mapper = mapper ( entityClass ) ; Session session = mapper . getManager ( ) . getSession ( ) ; ResultSet rs = session . execute ( statement ) ; return mapper . map ( rs ) ;


signature:
public class Datastore { /** * Execute a query and map result to entityClass .
 * @ param entityClass Entity class .
 * @ param statement Statement to execute .
 * @ param values Statement parameters .
 * @ return A listenable future holding the result . */
public < T > ListenableFuture < Result < T > > queryAsync ( final Class < T > entityClass , final String statement , final Map < String , Object > values ) { } }

implementation: return queryAsync ( entityClass , new SimpleStatement ( statement , values ) ) ;


signature:
public class Datastore { /** * Execute a query and map result to entityClass .
 * @ param entityClass Entity class .
 * @ param statement Statement to execute .
 * @ return A listenable future holding the result . */
public < T > ListenableFuture < Result < T > > queryAsync ( final Class < T > entityClass , final Statement statement ) { } }

implementation: Mapper < T > mapper = mapper ( entityClass ) ; Session session = mapper . getManager ( ) . getSession ( ) ; ResultSetFuture rs = session . executeAsync ( statement ) ; return Futures . transformAsync ( rs , rs1 -> Futures . immediateFuture ( mapper . map ( rs1 ) ) ) ;


signature:
public class Status { /** * Return the enum constant of this type with the specified numeric value .
 * @ param statusCode the numeric value of the enum to be returned
 * @ return the enum constant with the specified numeric value
 * @ throws IllegalArgumentException if this enum has no constant for the specified numeric value */
public static Status valueOf ( final int statusCode ) { } }

implementation: Integer key = Integer . valueOf ( statusCode ) ; Status status = statusMap . get ( key ) ; return status == null ? new Status ( key , key . toString ( ) ) : status ;


signature:
public class NettyWebSocket { /** * Make sure hankshake / connect is set . */
private void ready ( ) { } }

implementation: try { ready . await ( ) ; } catch ( InterruptedException ex ) { log . error ( "Connect call was inturrupted" , ex ) ; Thread . currentThread ( ) . interrupt ( ) ; }


signature:
public class Hcast { /** * Set a configurer callback .
 * @ param configurer A configurer callback .
 * @ return This instance . */
public Hcast doWith ( final BiConsumer < com . hazelcast . config . Config , Config > configurer ) { } }

implementation: this . configurer = requireNonNull ( configurer , "Configurer callback is required." ) ; return this ;


signature:
public class Hcast { /** * Set a configurer callback .
 * @ param configurer A configurer callback .
 * @ return This instance . */
public Hcast doWith ( final Consumer < com . hazelcast . config . Config > configurer ) { } }

implementation: requireNonNull ( configurer , "Configurer callback is required." ) ; return doWith ( ( config , conf ) -> configurer . accept ( config ) ) ;


signature:
public class Jdbi3 { /** * Configurer a jdbi instance .
 * @ param configurer Configurer callback .
 * @ return This module . */
public Jdbi3 doWith ( Consumer < Jdbi > configurer ) { } }

implementation: return doWith ( ( jdbi , conf ) -> configurer . accept ( jdbi ) ) ;


signature:
public class ExpandedStmtRewriter { /** * Munge up the SQL as desired . Responsible for figuring out ow to bind any
 * arguments in to the resultant prepared statement .
 * @ param sql The SQL to rewrite
 * @ param params contains the arguments which have been bound to this statement .
 * @ param ctx The statement context for the statement being executed
 * @ return somethign which can provde the actual SQL to prepare a statement from
 * and which can bind the correct arguments to that prepared statement */
@ Override public RewrittenStatement rewrite ( final String sql , final Binding params , final StatementContext ctx ) { } }

implementation: final ParsedStatement stmt = new ParsedStatement ( ) ; try { final String parsedSql = parseString ( sql , stmt , params ) ; return new MyRewrittenStatement ( parsedSql , stmt , ctx ) ; } catch ( IllegalArgumentException e ) { throw new UnableToCreateStatementException ( "Exception parsing for named parameter replacement" , e , ctx ) ; }


signature:
public class AssetHandler { /** * Parse value as { @ link Duration } . If the value is already a number then it uses as seconds .
 * Otherwise , it parse expressions like : 8m , 1h , 365d , etc . . .
 * @ param maxAge Set the cache header max - age value in seconds .
 * @ return This handler . */
public AssetHandler maxAge ( final String maxAge ) { } }

implementation: Try . apply ( ( ) -> Long . parseLong ( maxAge ) ) . recover ( x -> ConfigFactory . empty ( ) . withValue ( "v" , ConfigValueFactory . fromAnyRef ( maxAge ) ) . getDuration ( "v" ) . getSeconds ( ) ) . onSuccess ( this :: maxAge ) ; return this ;


signature:
public class AssetHandler { /** * Send an asset to the client .
 * @ param req Request .
 * @ param rsp Response .
 * @ param asset Resolve asset .
 * @ throws Exception If send fails . */
protected void send ( final Request req , final Response rsp , final Asset asset ) throws Throwable { } }

implementation: rsp . send ( asset ) ;


signature:
public class Metrics { /** * Instrument request using { @ link InstrumentedHandler } .
 * @ param method Method to filter for . Default is : < code > GET < / code > .
 * @ param pattern A pattern to filter for . Default is : < code > * < / code > ( all the requests ) .
 * @ return This metrics module . */
public Metrics request ( final String method , final String pattern ) { } }

implementation: routes . add ( r -> r . use ( method , pattern , new InstrumentedHandler ( ) ) ) ; return this ;


signature:
public class Metrics { /** * Append a simple ping handler that results in a < code > 200 < / code > responses with a
 * < code > pong < / code > body . See { @ link PingHandler }
 * @ return This metrics module . */
public Metrics ping ( ) { } }

implementation: bindings . add ( ( binder , routes , conf ) -> { routes . use ( "GET" , this . pattern + "/ping" , new PingHandler ( ) ) ; } ) ; return this ;


signature:
public class Metrics { /** * Append a handler that prints thread states ( a . k . a thread dump ) . See { @ link ThreadDumpHandler } .
 * @ return This metrics module . */
public Metrics threadDump ( ) { } }

implementation: bindings . add ( ( binder , routes , conf ) -> { routes . use ( "GET" , this . pattern + "/thread-dump" , new ThreadDumpHandler ( ) ) ; } ) ; return this ;


signature:
public class Metrics { /** * Append a metric to the { @ link MetricRegistry } , this call is identical to
 * { @ link MetricRegistry # register ( String , Metric ) } .
 * @ param name Name of the metric .
 * @ param metric A metric object
 * @ return This metrics module . */
public Metrics metric ( final String name , final Metric metric ) { } }

implementation: bindings . add ( ( binder , routes , conf ) -> { MapBinder . newMapBinder ( binder , String . class , Metric . class ) . addBinding ( name ) . toInstance ( metric ) ; } ) ; return this ;


signature:
public class Metrics { /** * Append a metric to the { @ link MetricRegistry } . The metric will be resolved by Guice . This call
 * is identical to { @ link MetricRegistry # register ( String , Metric ) } .
 * @ param name Name of the metric .
 * @ param metric A metric object .
 * @ param < M > Metric type .
 * @ return This metrics module . */
public < M extends Metric > Metrics metric ( final String name , final Class < M > metric ) { } }

implementation: bindings . add ( ( binder , routes , conf ) -> { MapBinder . newMapBinder ( binder , String . class , Metric . class ) . addBinding ( name ) . to ( metric ) ; } ) ; return this ;


signature:
public class Metrics { /** * Append a health check to the { @ link HealthCheckRegistry } . This call is identical to
 * { @ link HealthCheckRegistry # register ( String , HealthCheck ) } .
 * @ param name Name of the check .
 * @ param check A check object .
 * @ return This metrics module . */
public Metrics healthCheck ( final String name , final HealthCheck check ) { } }

implementation: bindings . add ( ( binder , routes , conf ) -> { MapBinder . newMapBinder ( binder , String . class , HealthCheck . class ) . addBinding ( name ) . toInstance ( check ) ; } ) ; return this ;


signature:
public class Metrics { /** * Append a health check to the { @ link HealthCheckRegistry } . The metric will be resolved by Guice .
 * This call is identical to { @ link HealthCheckRegistry # register ( String , HealthCheck ) } .
 * @ param name Name of the check .
 * @ param check A check object .
 * @ param < H > { @ link HealthCheck } type .
 * @ return This metrics module . */
public < H extends HealthCheck > Metrics healthCheck ( final String name , final Class < H > check ) { } }

implementation: bindings . add ( ( binder , routes , conf ) -> { MapBinder . newMapBinder ( binder , String . class , HealthCheck . class ) . addBinding ( name ) . to ( check ) ; } ) ; return this ;


signature:
public class Metrics { /** * Append a { @ link Reporter } to the { @ link MetricRegistry } .
 * @ param callback Reporter callback .
 * @ return This metrics module . */
public Metrics reporter ( final BiFunction < MetricRegistry , Config , Reporter > callback ) { } }

implementation: this . reporters . add ( requireNonNull ( callback , "Callback is required." ) ) ; return this ;


signature:
public class Metrics { /** * Append a { @ link Reporter } to the { @ link MetricRegistry } .
 * @ param callback Reporter callback .
 * @ return This metrics module . */
public Metrics reporter ( final Function < MetricRegistry , Reporter > callback ) { } }

implementation: return reporter ( ( registry , conf ) -> callback . apply ( registry ) ) ;


signature:
public class Eh { /** * Configure callback to manipulate a { @ link Configuration } programmatically .
 * @ param configurer A configure callback .
 * @ return This { @ link Eh } cache . */
public Eh doWith ( final Consumer < Configuration > configurer ) { } }

implementation: requireNonNull ( configurer , "Configurer callback is required." ) ; return doWith ( ( ehconf , conf ) -> configurer . accept ( ehconf ) ) ;


signature:
public class MediaType { /** * Convert one or more media types expressed as String into a { @ link MediaType } .
 * @ param types Media types to parse .
 * @ return An list of immutable { @ link MediaType } .
 * @ throws Err . BadMediaType For bad media types . */
public static List < MediaType > valueOf ( final String ... types ) throws Err . BadMediaType { } }

implementation: requireNonNull ( types , "Types are required." ) ; List < MediaType > result = new ArrayList < > ( ) ; for ( String type : types ) { result . add ( valueOf ( type ) ) ; } return result ;


signature:
public class MediaType { /** * Convert a string separated by comma into one or more { @ link MediaType } .
 * @ param value The string separated by commas .
 * @ return One ore more { @ link MediaType } .
 * @ throws Err . BadMediaType For bad media types . */
public static List < MediaType > parse ( final String value ) throws Err . BadMediaType { } }

implementation: return cache . computeIfAbsent ( value , MediaType :: parseInternal ) ;


signature:
public class MediaType { /** * Get a { @ link MediaType } for a file .
 * @ param file A candidate file .
 * @ return A { @ link MediaType } or { @ link MediaType # octetstream } for unknown file extensions . */
public static Optional < MediaType > byFile ( final File file ) { } }

implementation: requireNonNull ( file , "A file is required." ) ; return byPath ( file . getName ( ) ) ;


signature:
public class MediaType { /** * Get a { @ link MediaType } for a file path .
 * @ param path A candidate file path .
 * @ return A { @ link MediaType } or empty optional for unknown file extensions . */
public static Optional < MediaType > byPath ( final Path path ) { } }

implementation: requireNonNull ( path , "A path is required." ) ; return byPath ( path . toString ( ) ) ;


signature:
public class MediaType { /** * Get a { @ link MediaType } for a file path .
 * @ param path A candidate file path : like < code > myfile . js < / code > or < code > / js / myfile . js < / code > .
 * @ return A { @ link MediaType } or empty optional for unknown file extensions . */
public static Optional < MediaType > byPath ( final String path ) { } }

implementation: requireNonNull ( path , "A path is required." ) ; int idx = path . lastIndexOf ( '.' ) ; if ( idx != - 1 ) { String ext = path . substring ( idx + 1 ) ; return byExtension ( ext ) ; } return Optional . empty ( ) ;


signature:
public class MediaType { /** * Get a { @ link MediaType } for a file extension .
 * @ param ext A file extension , like < code > js < / code > or < code > css < / code > .
 * @ return A { @ link MediaType } or empty optional for unknown file extensions . */
public static Optional < MediaType > byExtension ( final String ext ) { } }

implementation: requireNonNull ( ext , "An ext is required." ) ; String key = "mime." + ext ; if ( types . hasPath ( key ) ) { return Optional . of ( MediaType . valueOf ( types . getString ( "mime." + ext ) ) ) ; } return Optional . empty ( ) ;


signature:
public class Jdbi { /** * Configure DBI instance .
 * @ param configurer Configurer .
 * @ return This module . */
public Jdbi doWith ( Consumer < DBI > configurer ) { } }

implementation: return doWith ( ( dbi , conf ) -> configurer . accept ( dbi ) ) ;


signature:
public class Aws { /** * Bind an { @ link AmazonWebServiceClient } instances as Guice service .
 * < pre >
 * use ( new Aws ( )
 * . with ( creds { @ literal - > } new AmazonS3Client ( creds ) )
 * < / pre >
 * @ param callback A creation callback .
 * @ return This module . */
public Aws with ( final BiFunction < AWSCredentialsProvider , Config , Object > callback ) { } }

implementation: requireNonNull ( callback , "Callback is required." ) ; callbacks . add ( callback ) ; return this ;


signature:
public class Aws { /** * Bind an { @ link AmazonWebServiceClient } instances as Guice service .
 * < pre >
 * use ( new Aws ( )
 * . with ( ( creds , conf ) { @ literal - > } {
 * AmazonS3Client s3 = new AmazonS3Client ( creds ) ;
 * s3 . setXXX ( conf . getString ( " XXXX " ) ) ;
 * return s3;
 * < / pre >
 * @ param callback A creation callback .
 * @ return This module . */
public Aws with ( final Function < AWSCredentialsProvider , Object > callback ) { } }

implementation: return with ( ( creds , conf ) -> callback . apply ( creds ) ) ;


signature:
public class Aws { /** * Like { @ link # with ( BiFunction ) } but it depends on a previously created service .
 * < pre >
 * use ( new Aws ( )
 * . with ( creds { @ literal - > } new AmazonS3Client ( creds ) )
 * . with ( creds { @ literal - > } new AmazonSQSClient ( creds ) )
 * . doWith ( ( AmazonS3Client s3 ) { @ literal - > } new TransferManager ( s3 ) )
 * < / pre >
 * It will bind a < code > TransferManager < / code > as a Guice service .
 * @ param callback A creation callback .
 * @ param < T > Aws service type .
 * @ return This module . */
public < T extends AmazonWebServiceClient > Aws doWith ( final BiFunction < T , Config , Object > callback ) { } }

implementation: requireNonNull ( callback , "Callback is required." ) ; after . add ( callback ) ; return this ;


signature:
public class Aws { /** * Like { @ link # with ( Function ) } but it depends on a previously created service .
 * < pre >
 * use ( new Aws ( )
 * . with ( creds { @ literal - > } new AmazonS3Client ( creds ) )
 * . with ( creds { @ literal - > } new AmazonSQSClient ( creds ) )
 * . doWith ( ( AmazonS3Client s3 ) { @ literal - > } new TransferManager ( s3 ) )
 * < / pre >
 * It will bind a < code > TransferManager < / code > as a Guice service .
 * @ param callback A creation callback .
 * @ param < T > Aws service type .
 * @ return This module . */
public < T extends AmazonWebServiceClient > Aws doWith ( final Function < T , Object > callback ) { } }

implementation: requireNonNull ( callback , "Callback is required." ) ; return doWith ( ( s , c ) -> callback . apply ( ( T ) s ) ) ;


signature:
public class jOOQ { /** * Configuration callback .
 * @ param configurer Callback .
 * @ return This module . */
public jOOQ doWith ( Consumer < Configuration > configurer ) { } }

implementation: return doWith ( ( configuration , conf ) -> configurer . accept ( configuration ) ) ;


signature:
public class Quartz { /** * Schedule the provided job and trigger .
 * @ param job A job to schedule .
 * @ param trigger A trigger for provided job .
 * @ return This quartz instance . */
public Quartz with ( final JobDetail job , final Trigger trigger ) { } }

implementation: requireNonNull ( job , "Job is required." ) ; requireNonNull ( trigger , "Trigger is required." ) ; jobMap . put ( job , trigger ) ; return this ;


signature:
public class Quartz { /** * Schedule the provided job and trigger . This method will setup a default name and group for
 * both .
 * @ param jobClass A jobClass to setup and schedule .
 * @ param configurer A callback to setup the job and trigger .
 * @ return This quartz instance . */
public Quartz with ( final Class < ? extends Job > jobClass , final BiConsumer < JobBuilder , TriggerBuilder < Trigger > > configurer ) { } }

implementation: requireNonNull ( jobClass , "Job class is required." ) ; JobBuilder job = JobBuilder . newJob ( jobClass ) . withIdentity ( JobKey . jobKey ( jobClass . getSimpleName ( ) , jobClass . getPackage ( ) . getName ( ) ) ) ; TriggerBuilder < Trigger > trigger = TriggerBuilder . newTrigger ( ) . withIdentity ( TriggerKey . triggerKey ( jobClass . getSimpleName ( ) , jobClass . getPackage ( ) . getName ( ) ) ) ; configurer . accept ( job , trigger ) ; return with ( job . build ( ) , trigger . build ( ) ) ;


signature:
public class NettyServer { /** * Shutdown executor in order .
 * @ param iterator Executors to shutdown . */
private void shutdownGracefully ( final Iterator < EventExecutorGroup > iterator ) { } }

implementation: if ( iterator . hasNext ( ) ) { EventExecutorGroup group = iterator . next ( ) ; if ( ! group . isShuttingDown ( ) ) { group . shutdownGracefully ( ) . addListener ( future -> { if ( ! future . isSuccess ( ) ) { log . debug ( "shutdown of {} resulted in exception" , group , future . cause ( ) ) ; } shutdownGracefully ( iterator ) ; } ) ; } }


signature:
public class Cassandra { /** * Configure a cluster before creating it .
 * @ param configurer Configurer callback .
 * @ return This module . */
public Cassandra doWithClusterBuilder ( final BiConsumer < Cluster . Builder , Config > configurer ) { } }

implementation: this . ccbuilder = requireNonNull ( configurer , "ClusterBuilder conf callback required." ) ; return this ;


signature:
public class Cassandra { /** * Configure a cluster before creating it .
 * @ param configurer Configurer callback .
 * @ return This module . */
public Cassandra doWithClusterBuilder ( final Consumer < Cluster . Builder > configurer ) { } }

implementation: requireNonNull ( configurer , "ClusterBuilder conf callback required." ) ; return doWithClusterBuilder ( ( b , c ) -> configurer . accept ( b ) ) ;


signature:
public class Cassandra { /** * Configure a cluster after creation .
 * @ param configurer Configurer callback .
 * @ return This module . */
public Cassandra doWithCluster ( final Consumer < Cluster > configurer ) { } }

implementation: requireNonNull ( configurer , "Cluster conf callbackrequired." ) ; return doWithCluster ( ( cc , c ) -> configurer . accept ( cc ) ) ;


signature:
public class Yasson { /** * Configurer callback .
 * < pre >
 * use ( new Yasson ( ) . doWith ( ( builder , config ) { @ literal - > } {
 * builder . withFormatting ( true ) ;
 * < / pre >
 * @ param configurer A callback .
 * @ return This instance . */
public Yasson doWith ( final Consumer < JsonbConfig > configurer ) { } }

implementation: requireNonNull ( configurer , "Configurer callback is required." ) ; this . configurer = ( jsonConfig , conf ) -> configurer . accept ( jsonConfig ) ; return this ;


signature:
public class Results { /** * Set the result
 * @ param entity A result value .
 * @ param status A HTTP status .
 * @ return A new result . */
@ Nonnull public static Result with ( final Object entity , final Status status ) { } }

implementation: return new Result ( ) . status ( status ) . set ( entity ) ;


signature:
public class Results { /** * Set the result
 * @ param entity A result value .
 * @ param status A HTTP status .
 * @ return A new result . */
@ Nonnull public static Result with ( final Object entity , final int status ) { } }

implementation: return with ( entity , Status . valueOf ( status ) ) ;


signature:
public class Results { /** * Set the response status .
 * @ param status A status !
 * @ return A new result . */
@ Nonnull public static Result with ( final Status status ) { } }

implementation: requireNonNull ( status , "A HTTP status is required." ) ; return new Result ( ) . status ( status ) ;


signature:
public class Results { /** * Performs content - negotiation on the Accept HTTP header on the request object . It select a
 * handler for the request , based on the acceptable types ordered by their quality values .
 * If the header is not specified , the first callback is invoked . When no match is found ,
 * the server responds with 406 " Not Acceptable " , or invokes the default callback : { @ code * * / * } .
 * < pre >
 * get ( " / jsonOrHtml " , ( ) { @ literal - > }
 * Results
 * . when ( " text / html " , ( ) { @ literal - > } Results . html ( " view " ) . put ( " model " , model ) ) )
 * . when ( " application / json " , ( ) { @ literal - > } model )
 * . when ( " * " , ( ) { @ literal - > } { throw new Err ( Status . NOT _ ACCEPTABLE ) ; } )
 * < / pre >
 * @ param type A media type .
 * @ param supplier A result supplier .
 * @ return A new result . */
@ Nonnull public static Result when ( final String type , final Supplier < Object > supplier ) { } }

implementation: return new Result ( ) . when ( type , supplier ) ;


signature:
public class Results { /** * Produces a redirect ( 302 ) status code and set the < code > Location < / code > header too .
 * @ param status A HTTP redirect status .
 * @ param location A location .
 * @ return A new result . */
private static Result redirect ( final Status status , final String location ) { } }

implementation: requireNonNull ( location , "A location is required." ) ; return with ( status ) . header ( "location" , location ) ;


signature:
public class SSIHandler { /** * Set / override delimiters .
 * @ param start Start delimiter .
 * @ param end Stop / end delimiter .
 * @ return This handler . */
public SSIHandler delimiters ( final String start , final String end ) { } }

implementation: this . startDelimiter = start ; this . endDelimiter = end ; return this ;


signature:
public class Couchbase { /** * Set a shared { @ link CouchbaseEnvironment } . The environment will shutdown automatically .
 * @ param env Environment provider .
 * @ return This module . */
public Couchbase environment ( final java . util . function . Supplier < CouchbaseEnvironment > env ) { } }

implementation: return environment ( c -> env . get ( ) ) ;


signature:
public class Jackson { /** * Register the provided module .
 * @ param module A module instance .
 * @ return This module . */
public Jackson module ( final Module module ) { } }

implementation: requireNonNull ( module , "Jackson Module is required." ) ; modules . add ( binder -> binder . addBinding ( ) . toInstance ( module ) ) ; return this ;


signature:
public class Jackson { /** * Register the provided { @ link Module } . The module will be instantiated by Guice .
 * @ param module Module type .
 * @ return This module . */
public Jackson module ( final Class < ? extends Module > module ) { } }

implementation: requireNonNull ( module , "Jackson Module is required." ) ; modules . add ( binder -> binder . addBinding ( ) . to ( module ) ) ; return this ;


signature:
public class Nodejs { /** * Force to unpack library files every { @ link # exec ( String ) } call . This is useful for development
 * and testing . By default files are unpacked just once ( overwrite = false ) .
 * @ param overwrite True , to force overwrite .
 * @ return */
public Nodejs overwrite ( final boolean overwrite ) { } }

implementation: if ( overwrite ) { this . coptions = EnumSet . of ( StandardCopyOption . REPLACE_EXISTING ) ; } else { this . coptions = Collections . emptySet ( ) ; } return this ;


signature:
public class Nodejs { /** * Unpack and execute a nodejs library . Once unpack this method will execute one of these scripts
 * in the following order : 1 ) [ library ] . js ; 2 ) main . js ; 3 ) index . js .
 * The first file found will be executed .
 * @ param library Library to unpack and execute this library .
 * @ throws Throwable If something goes wrong . */
public void exec ( final String library , final Throwing . Consumer < V8 > callback ) throws Throwable { } }

implementation: Path basedir = deploy ( library ) ; List < String > candidates = Arrays . asList ( basedir . getFileName ( ) . toString ( ) + ".js" , "main.js" , "index.js" ) ; Path main = candidates . stream ( ) . map ( basedir :: resolve ) . filter ( Files :: exists ) . findFirst ( ) . orElseThrow ( ( ) -> new FileNotFoundException ( candidates . toString ( ) ) ) ; callback . accept ( node . getRuntime ( ) ) ; node . exec ( main . toFile ( ) ) ; while ( node . isRunning ( ) ) { node . handleMessage ( ) ; }


signature:
public class Nodejs { /** * Execute the given nodejs callback and automatically releaseNow v8 and nodejs resources .
 * @ param callback Nodejs callback . */
public static void run ( final Throwing . Consumer < Nodejs > callback ) { } }

implementation: run ( new File ( System . getProperty ( "java.io.tmpdir" ) ) , callback ) ;


signature:
public class Nodejs { /** * Execute the given nodejs callback and automatically releaseNow v8 and nodejs resources .
 * @ param basedir Base dir where to deploy a library .
 * @ param callback Nodejs callback . */
public static void run ( final File basedir , final Throwing . Consumer < Nodejs > callback ) { } }

implementation: Nodejs node = new Nodejs ( basedir ) ; Try . run ( ( ) -> callback . accept ( node ) ) . onComplete ( node :: release ) . throwException ( ) ;


signature:
public class Pebble { /** * Advanced configuration callback for { @ link PebbleEngine . Builder } .
 * @ param callback A callback to finish setup .
 * @ return This module . */
public Pebble doWith ( final BiConsumer < PebbleEngine . Builder , Config > callback ) { } }

implementation: this . callback = requireNonNull ( callback , "Callback is required." ) ; return this ;


signature:
public class Pebble { /** * Advanced configuration callback for { @ link PebbleEngine . Builder } .
 * @ param callback A callback to finish setup .
 * @ return This module . */
public Pebble doWith ( final Consumer < PebbleEngine . Builder > callback ) { } }

implementation: requireNonNull ( callback , "Callback is required." ) ; return doWith ( ( p , c ) -> callback . accept ( p ) ) ;


signature:
public class Pac4j { /** * Configurer pa4j options , only necessary it you want to provide your own pac4j components .
 * < pre > { @ code
 * use ( new Pac4j ( )
 * . doWith ( pac4j - > {
 * pac4j . setSecurityLogic ( . . . ) ;
 * pac4j . setHttpActionAdapter ( . . . ) ;
 * } < / pre >
 * @ param configurer Configurer callback .
 * @ return This module . */
public Pac4j doWith ( Consumer < org . pac4j . core . config . Config > configurer ) { } }

implementation: return doWith ( ( pac4j , conf ) -> configurer . accept ( pac4j ) ) ;


signature:
public class Pac4j { /** * Configurer pa4j options , only necessary it you want to provide your own pac4j components .
 * < pre > { @ code
 * use ( new Pac4j ( )
 * . doWith ( ( pac4j , conf ) - > {
 * pac4j . setSecurityLogic ( . . . ) ;
 * pac4j . setHttpActionAdapter ( . . . ) ;
 * } < / pre >
 * @ param configurer Configurer callback .
 * @ return This module . */
public Pac4j doWith ( BiConsumer < org . pac4j . core . config . Config , Config > configurer ) { } }

implementation: this . configurer = configurer ; return this ;


signature:
public class Pac4j { /** * Add a pac4j client , protected all the routes defined after that matches the pattern and attach
 * an authorizer :
 * < pre > { @ code
 * use ( new Pac4j ( )
 * . client ( " * " , new MyAuthorizer ( ) , conf - > {
 * return new FacebookClient ( conf . getString ( " fb . key " ) , conf . getString ( " fb . secret " ) ) ;
 * } < / pre >
 * @ param pattern Pattern to protect .
 * @ param authorizer Authorizer .
 * @ param client Client provider .
 * @ param < C > Credential type .
 * @ param < U > User profile type .
 * @ return This module . */
public < C extends Credentials , U extends CommonProfile > Pac4j client ( String pattern , Authorizer < U > authorizer , Function < Config , Client < C , U > > client ) { } }

implementation: return clientInternal ( pattern , client , authorizer ) ;


signature:
public class Pac4j { /** * Set a default action which is execute when no user is logged in .
 * < pre > { @ code
 * use ( new Pac4j ( )
 * . unauthenticated ( ( ) - > {
 * UserProfile anonymous = . . .
 * return anonymous ;
 * get ( " / " , ( ) - > {
 * / / might or might not be anonymous
 * UserProfile profile = require ( UserProfile . class ) ;
 * return . . . ;
 * } < / pre >
 * The default action throws a < code > 403 < / code > error .
 * @ param provider Unauthenticated user provider .
 * @ return This module . */
public Pac4j unauthenticated ( Supplier < UserProfile > provider ) { } }

implementation: requireNonNull ( provider , "Unauthenticated provider required." ) ; return unauthenticated ( req -> provider . get ( ) ) ;


signature:
public class Pac4j { /** * Add a simple login form . Useful for development and quick startup .
 * @ param pattern Pattern to protect . ver
 * @ return This module . */
public Pac4j form ( String pattern ) { } }

implementation: return clientInternal ( pattern , conf -> { showDevLogin = true ; return new FormClient ( "/login" , new SimpleTestUsernamePasswordAuthenticator ( ) ) ; } , null ) ;


signature:
public class JdkSslContext { /** * Build a { @ link KeyManagerFactory } based upon a key file , key file password , and a certificate
 * chain .
 * @ param certChainFile a X . 509 certificate chain file in PEM format
 * @ param keyFile a PKCS # 8 private key file in PEM format
 * @ param keyPassword the password of the { @ code keyFile } .
 * { @ code null } if it ' s not password - protected .
 * @ param kmf The existing { @ link KeyManagerFactory } that will be used if not { @ code null }
 * @ return A { @ link KeyManagerFactory } based upon a key file , key file password , and a certificate
 * chain . */
protected static KeyManagerFactory buildKeyManagerFactory ( final File certChainFile , final File keyFile , final String keyPassword ) throws UnrecoverableKeyException , KeyStoreException , NoSuchAlgorithmException , NoSuchPaddingException , InvalidKeySpecException , InvalidAlgorithmParameterException , CertificateException , KeyException , IOException { } }

implementation: String algorithm = Security . getProperty ( "ssl.KeyManagerFactory.algorithm" ) ; if ( algorithm == null ) { algorithm = "SunX509" ; } return buildKeyManagerFactory ( certChainFile , algorithm , keyFile , keyPassword ) ;


signature:
public class JdkSslContext { /** * Build a { @ link KeyManagerFactory } based upon a key algorithm , key file , key file password ,
 * and a certificate chain .
 * @ param certChainFile a X . 509 certificate chain file in PEM format
 * @ param keyAlgorithm the standard name of the requested algorithm . See the Java Secure Socket
 * Extension
 * Reference Guide for information about standard algorithm names .
 * @ param keyFile a PKCS # 8 private key file in PEM format
 * @ param keyPassword the password of the { @ code keyFile } .
 * { @ code null } if it ' s not password - protected .
 * @ return A { @ link KeyManagerFactory } based upon a key algorithm , key file , key file password ,
 * and a certificate chain . */
protected static KeyManagerFactory buildKeyManagerFactory ( final File certChainFile , final String keyAlgorithm , final File keyFile , final String keyPassword ) throws KeyStoreException , NoSuchAlgorithmException , NoSuchPaddingException , InvalidKeySpecException , InvalidAlgorithmParameterException , IOException , CertificateException , KeyException , UnrecoverableKeyException { } }

implementation: char [ ] keyPasswordChars = keyPassword == null ? EMPTY_CHARS : keyPassword . toCharArray ( ) ; KeyStore ks = buildKeyStore ( certChainFile , keyFile , keyPasswordChars ) ; KeyManagerFactory kmf = KeyManagerFactory . getInstance ( keyAlgorithm ) ; kmf . init ( ks , keyPasswordChars ) ; return kmf ;


signature:
public class ApiParser { /** * Parse application bytecode , build route methods from it and merge output with the given routes .
 * @ param application Application to parse .
 * @ return List of route methods .
 * @ throws Exception If something goes wrong . */
public List < RouteMethod > parseFully ( Jooby application ) throws Exception { } }

implementation: List < RouteMethod > methods = parseFully ( application . getClass ( ) . getName ( ) , Jooby . exportRoutes ( application ) ) ; return methods ;


signature:
public class ApiParser { /** * Parse application bytecode , build route methods from it and export all metadata to < code > . json < / code > .
 * @ param outputBaseDir Output base directory . This method appends the java package of the given
 * application .
 * @ param application Application to parse .
 * @ return List of route methods .
 * @ throws Exception If something goes wrong . */
public Path export ( Path outputBaseDir , String application ) throws Exception { } }

implementation: return new BytecodeRouteParser ( loader , dir ) . export ( outputBaseDir , application ) ;


signature:
public class ApiParser { /** * Parse application bytecode and build route methods from it .
 * @ param application Application to parse .
 * @ return List of route methods .
 * @ throws Exception If something goes wrong . */
public List < RouteMethod > parse ( String application ) throws Exception { } }

implementation: return new BytecodeRouteParser ( loader , dir ) . parse ( application ) . stream ( ) . filter ( filter ) . collect ( Collectors . toList ( ) ) ;


signature:
public class ApiParser { /** * Parse application bytecode , build route methods from it and merge output with the given routes .
 * @ param application Application to parse .
 * @ param routes Application routes .
 * @ return List of route methods .
 * @ throws Exception If something goes wrong . */
public List < RouteMethod > parseFully ( String application , List < Route . Definition > routes ) throws Exception { } }

implementation: List < RouteMethod > methods = parse ( application ) ; BiFunction < String , String , OptionalInt > routeIndex = ( verb , pattern ) -> { RouteMethod it = new RouteMethod ( verb , pattern , new RouteResponse ( void . class ) ) ; return IntStream . range ( 0 , methods . size ( ) ) . filter ( i -> methods . get ( i ) . equals ( it ) ) . findFirst ( ) ; } ; List < RouteMethod > result = new ArrayList < > ( routes . size ( ) ) ; for ( Route . Definition route : routes ) { routeIndex . apply ( route . method ( ) , route . pattern ( ) ) . ifPresent ( i -> result . add ( complement ( route , methods . remove ( i ) ) ) ) ; } customizer . entrySet ( ) . forEach ( it -> result . stream ( ) . filter ( it . getKey ( ) ) . forEach ( it . getValue ( ) ) ) ; return result ;


signature:
public class ApiParser { /** * Modify one or more route method who matches the filter . Work as a API to fix possible missing
 * metadata .
 * @ param matcher Route matcher .
 * @ param customizer Customizer .
 * @ return This parser . */
public ApiParser modify ( final Predicate < RouteMethod > matcher , final Consumer < RouteMethod > customizer ) { } }

implementation: this . customizer . put ( matcher , customizer ) ; return this ;


signature:
public class Scanner { /** * Add a scan criteria like an annotation , interface or class .
 * @ param type A scan criteria / type .
 * @ return This module . */
public Scanner scan ( final Class < ? > type ) { } }

implementation:
// standard vs guice annotations
if ( type == Named . class || type == com . google . inject . name . Named . class ) { serviceTypes . add ( Named . class ) ; serviceTypes . add ( com . google . inject . name . Named . class ) ; } else if ( type == Singleton . class || type == com . google . inject . Singleton . class ) { serviceTypes . add ( Singleton . class ) ; serviceTypes . add ( com . google . inject . Singleton . class ) ; } else { serviceTypes . add ( type ) ; } return this ;


signature:
public class ApiTool { /** * Mount Swagger at the given path and customize Swagger objects .
 * @ param path Path to mount swagger .
 * @ param swagger Customizer .
 * @ return This tool . */
public ApiTool swagger ( String path , Consumer < Swagger > swagger ) { } }

implementation: return swagger ( new Options ( path , options ) , swagger ) ;


signature:
public class ApiTool { /** * Mount Swagger using the given options .
 * @ param options Swagger options .
 * @ param swagger Customizer .
 * @ return This tool . */
public ApiTool swagger ( Options options , Consumer < Swagger > swagger ) { } }

implementation: this . swaggerOptions = Objects . requireNonNull ( options , "Options required." ) ; this . swagger = swagger ; return this ;


signature:
public class ApiTool { /** * Mount RAML at the given path and customize RAML objects .
 * @ param path Path to mount raml .
 * @ param raml RAML customizer .
 * @ return This tool . */
public ApiTool raml ( String path , Consumer < Raml > raml ) { } }

implementation: return raml ( new Options ( path , options ) , raml ) ;


signature:
public class ApiTool { /** * Mount RAML using the given options .
 * @ param options RAML options .
 * @ param raml RAML customizer .
 * @ return This tool . */
public ApiTool raml ( Options options , Consumer < Raml > raml ) { } }

implementation: this . ramlOptions = Objects . requireNonNull ( options , "Options required." ) ; this . raml = raml ; return this ;


signature:
public class ApiTool { /** * Modify one or more route method who matches the filter . Work as a API to fix possible missing
 * metadata .
 * @ param matcher Route matcher .
 * @ param customizer Customizer .
 * @ return This tool . */
public ApiTool modify ( final Predicate < RouteMethod > matcher , final Consumer < RouteMethod > customizer ) { } }


signature:
public class N1Q { /** * Creates a new { @ link N1qlQuery } for the given class , this method build a query like :
 * < pre >
 * select b . * from bucket b where b . _ class = ' model . Beer '
 * < / pre >
 * @ param bucket Bucket name .
 * @ param entityClass Entity class .
 * @ return A query . */
public static GroupByPath from ( final String bucket , final Class < ? > entityClass ) { } }

implementation: String alias = String . valueOf ( entityClass . getSimpleName ( ) . charAt ( 0 ) ) ; return Select . select ( alias + ".*" ) . from ( i ( bucket ) + " " + alias ) . where ( path ( alias , CLASS ) . eq ( s ( entityClass . getName ( ) ) ) ) ;


signature:
public class N1Q { /** * Qualify and ID to construct and unique ID . Given : model . Beer and " ipa " this method returns :
 * < code > model . Beer : : ipa < / code > .
 * @ param entityClass Entity class .
 * @ param id Entity id .
 * @ return Qualified ID . */
public static String qualifyId ( final Class < ? > entityClass , final Object id ) { } }

implementation: return qualifyId ( entityClass . getName ( ) , id ) ;


signature:
public class AssetProcessor { /** * Method that processes the provided source and returns the processed contents .
 * @ param filename name of the file
 * @ param source contents of the file
 * @ param conf application configuration
 * @ return the processed file contents
 * @ throws Exception if any error occurred */
public String process ( String filename , String source , Config conf ) throws Exception { } }

implementation: return process ( filename , source , conf , getClass ( ) . getClassLoader ( ) ) ;


signature:
public class CteRecepcaoOSCallbackHandler { /** * auto generated Axis2 call back method for cteRecepcaoOS method
 * override this method for handling normal response from cteRecepcaoOS operation */
public void receiveResultcteRecepcaoOS ( com . fincatto . documentofiscal . cte300 . webservices . recepcaoOS . CteRecepcaoOSStub . CteRecepcaoOSResult result ) { } }


signature:
public class MDFeRecepcaoCallbackHandler { /** * auto generated Axis2 call back method for mdfeRecepcaoLote method
 * override this method for handling normal response from mdfeRecepcaoLote operation */
public void receiveResultmdfeRecepcaoLote ( com . fincatto . documentofiscal . mdfe3 . webservices . recepcao . MDFeRecepcaoStub . MdfeRecepcaoLoteResult result ) { } }


signature:
public class MDFInfo { /** * Identificador da tag a ser assinada < br >
 * Informar a chave de acesso do MDF - e e precedida do literal " MDFe " */
public void setIdentificador ( final String identificador ) { } }

implementation: StringValidador . exatamente44N ( identificador , "Identificador" ) ; this . identificador = MDFInfo . IDENT + identificador ;


signature:
public class MDFInfo { /** * Versão do leiaute */
public void setVersao ( final String versao ) { } }

implementation: StringValidador . equals ( MDFe . VERSAO , versao ) ; this . versao = versao ;


signature:
public class CteInutilizacaoCallbackHandler { /** * auto generated Axis2 call back method for cteInutilizacaoCT method
 * override this method for handling normal response from cteInutilizacaoCT operation */
public void receiveResultcteInutilizacaoCT ( com . fincatto . documentofiscal . cte300 . webservices . inutilizacao . CteInutilizacaoStub . CteInutilizacaoCTResult result ) { } }


signature:
public class MDFeRecepcaoEventoCallbackHandler { /** * auto generated Axis2 call back method for mdfeRecepcaoEvento method
 * override this method for handling normal response from mdfeRecepcaoEvento operation */
public void receiveResultmdfeRecepcaoEvento ( com . fincatto . documentofiscal . mdfe3 . webservices . recepcaoevento . MDFeRecepcaoEventoStub . MdfeRecepcaoEventoResult result ) { } }


signature:
public class CTeNotaInfoRecebedorCarga { /** * Endereço de email */
public void setEmail ( final String email ) { } }

implementation: StringValidador . tamanho60 ( email , "Endereço de email" ) ; StringValidador . email ( email ) ; this . email = email ;


signature:
public class WSDistribuicaoCTe { /** * Metodo para consultar os conhecimentos de transporte e retorna uma String < br >
 * É importante salvar esta String para não perder nenhuma informacao < br >
 * A receita não disponibiliza o conhecimento várias vezes para consultar , retorna rejeicao : Consumo indevido */
public static String consultar ( final CTDistribuicaoInt distDFeInt , final NFeConfig config ) throws Exception { } }

implementation: Protocol . registerProtocol ( "https" , new Protocol ( "https" , new DFSocketFactory ( config ) , 443 ) ) ; try { final OMElement ome = AXIOMUtil . stringToOM ( distDFeInt . toString ( ) ) ; final CTeDistribuicaoDFeSoapStub . CteDadosMsg_type0 dadosMsgType0 = new CTeDistribuicaoDFeSoapStub . CteDadosMsg_type0 ( ) ; dadosMsgType0 . setExtraElement ( ome ) ; final CTeDistribuicaoDFeSoapStub . CteDistDFeInteresse distDFeInteresse = new CTeDistribuicaoDFeSoapStub . CteDistDFeInteresse ( ) ; distDFeInteresse . setCteDadosMsg ( dadosMsgType0 ) ; final CTeDistribuicaoDFeSoapStub stub = new CTeDistribuicaoDFeSoapStub ( CTAutorizador . AN . getDistribuicaoDFe ( config . getAmbiente ( ) ) ) ; final CTeDistribuicaoDFeSoapStub . CteDistDFeInteresseResponse result = stub . cteDistDFeInteresse ( distDFeInteresse ) ; return result . getCteDistDFeInteresseResult ( ) . getExtraElement ( ) . toString ( ) ; } catch ( RemoteException | XMLStreamException e ) { throw new Exception ( e . getMessage ( ) ) ; }


signature:
public class DFParser { /** * NFe / NFCe */
public NFNota notaParaObjeto ( final File xml ) { } }

implementation: try { return this . persister . read ( NFNota . class , xml ) ; } catch ( final Exception e ) { throw new IllegalArgumentException ( String . format ( "Nao foi possivel parsear o xml: %s" , e . getMessage ( ) ) ) ; }


signature:
public class DFParser { /** * CTe */
public CTeEnvioLote cteRecepcaoParaObjeto ( final String xml ) { } }

implementation: try { return this . persister . read ( CTeEnvioLote . class , xml ) ; } catch ( final Exception e ) { throw new IllegalArgumentException ( String . format ( "Nao foi possivel parsear o xml: %s" , e . getMessage ( ) ) ) ; }


signature:
public class DFParser { /** * MDFe */
public MDFEnvioLote mdfeRecepcaoParaObjeto ( final String xml ) { } }

implementation: try { return this . persister . read ( MDFEnvioLote . class , xml ) ; } catch ( final Exception e ) { throw new IllegalArgumentException ( String . format ( "Nao foi possivel parsear o xml do Lote MDFe: %s" , e . getMessage ( ) ) ) ; }