signature:
public class DefaultFutures { /** * Create a CompletionStage which , after a delay , will be redeemed with the result of a given
 * supplier . The supplier will be called after the delay .
 * @ param callable the input completion stage that is delayed .
 * @ param duration to wait .
 * @ param < A > the type of the completion ' s result .
 * @ return the delayed CompletionStage wrapping supplier . */
@ Override public < A > CompletionStage < A > delayed ( final Callable < CompletionStage < A > > callable , Duration duration ) { } }

implementation: requireNonNull ( callable , "Null callable" ) ; requireNonNull ( duration , "Null duration" ) ; FiniteDuration finiteDuration = FiniteDuration . apply ( duration . toMillis ( ) , TimeUnit . MILLISECONDS ) ; return toJava ( delegate . delayed ( finiteDuration , Scala . asScalaWithFuture ( callable ) ) ) ;


signature:
public class ClassUtils { /** * Checks if an array of Classes can be assigned to another array of Classes .
 * < p > This method calls { @ link # isAssignable ( Class , Class ) isAssignable } for each Class pair in
 * the input arrays . It can be used to check if a set of arguments ( the first parameter ) are
 * suitably compatible with a set of method parameter types ( the second parameter ) .
 * < p > Unlike the { @ link Class # isAssignableFrom ( java . lang . Class ) } method , this method takes into
 * account widenings of primitive classes and { @ code null } s .
 * < p > Primitive widenings allow an int to be assigned to a { @ code long } , { @ code float } or { @ code
 * double } . This method returns the correct result for these cases .
 * < p > { @ code Null } may be assigned to any reference type . This method will return { @ code true } if
 * { @ code null } is passed in and the toClass is non - primitive .
 * < p > Specifically , this method tests whether the type represented by the specified { @ code Class }
 * parameter can be converted to the type represented by this { @ code Class } object via an identity
 * conversion widening primitive or widening reference conversion . See < em > < a
 * href = " http : / / java . sun . com / docs / books / jls / " > The Java Language Specification < / a > < / em > , sections
 * 5.1.1 , 5.1.2 and 5.1.4 for details .
 * @ param classArray the array of Classes to check , may be { @ code null }
 * @ param toClassArray the array of Classes to try to assign into , may be { @ code null }
 * @ param autoboxing whether to use implicit autoboxing / unboxing between primitives and wrappers
 * @ return { @ code true } if assignment possible */
public static boolean isAssignable ( Class < ? > [ ] classArray , Class < ? > [ ] toClassArray , boolean autoboxing ) { } }

implementation: if ( arrayGetLength ( classArray ) != arrayGetLength ( toClassArray ) ) { return false ; } if ( classArray == null ) { classArray = EMPTY_CLASS_ARRAY ; } if ( toClassArray == null ) { toClassArray = EMPTY_CLASS_ARRAY ; } for ( int i = 0 ; i < classArray . length ; i ++ ) { if ( isAssignable ( classArray [ i ] , toClassArray [ i ] , autoboxing ) == false ) { return false ; } } return true ;


signature:
public class Time { /** * Parses a CRON expression .
 * @ param cron the CRON String
 * @ return the next < code > Date < / code > that satisfies the expression */
public static Date parseCRONExpression ( String cron ) { } }

implementation: try { return new CronExpression ( cron ) . getNextValidTimeAfter ( new Date ( ) ) ; } catch ( Exception e ) { throw new IllegalArgumentException ( "Invalid CRON pattern : " + cron , e ) ; }


signature:
public class Time { /** * Compute the number of milliseconds between the next valid date and the one after .
 * @ param cron the CRON String
 * @ param date the date to start search
 * @ return the number of milliseconds between the next valid date and the one after , with an
 * invalid interval between */
public static long cronInterval ( String cron , Date date ) { } }

implementation: try { return new CronExpression ( cron ) . getNextInterval ( date ) ; } catch ( Exception e ) { throw new IllegalArgumentException ( "Invalid CRON pattern : " + cron , e ) ; }


signature:
public class AhcWSClient { /** * Creates WS client manually from configuration , internally creating a new instance of
 * AsyncHttpClient and managing its own thread pool .
 * < p > This client is not managed as part of Play ' s lifecycle , and < b > must < / b > be closed by calling
 * ws . close ( ) , otherwise you will run into memory leaks .
 * @ param config a config object , usually from AhcWSClientConfigFactory
 * @ param cache if not null , provides HTTP caching .
 * @ param materializer an Akka materializer
 * @ return a new instance of AhcWSClient . */
public static AhcWSClient create ( AhcWSClientConfig config , AhcHttpCache cache , Materializer materializer ) { } }

implementation: final StandaloneAhcWSClient client = StandaloneAhcWSClient . create ( config , cache , materializer ) ; return new AhcWSClient ( client , materializer ) ;


signature:
public class JavaRoutingDsl { /** * # inject */
@ Test public void createNewRoutingDsl ( ) { } }

implementation:
play . mvc . BodyParser . Default bodyParser = app . injector ( ) . instanceOf ( play . mvc . BodyParser . Default . class ) ; JavaContextComponents javaContextComponents = app . injector ( ) . instanceOf ( JavaContextComponents . class ) ; // # new - routing - dsl
RoutingDsl routingDsl = new RoutingDsl ( bodyParser , javaContextComponents ) ; // # new - routing - dsl
Router router = routingDsl . GET ( "/hello/:to" ) . routingTo ( ( request , to ) -> ok ( "Hello " + to ) ) . build ( ) ; assertThat ( makeRequest ( router , "GET" , "/hello/world" ) , equalTo ( "Hello world" ) ) ;


signature:
public class GuiceApplicationLoader { /** * Construct a builder to use for loading the given context .
 * @ param context the context the returned builder will load
 * @ return the builder */
public GuiceApplicationBuilder builder ( ApplicationLoader . Context context ) { } }

implementation: return initialBuilder . in ( context . environment ( ) ) . loadConfig ( context . initialConfig ( ) ) . overrides ( overrides ( context ) ) ;


signature:
public class GuiceApplicationLoader { /** * Identify some bindings that should be used as overrides when loading an application using this
 * context . The default implementation of this method provides bindings that most applications
 * should include .
 * @ param context the context that should be searched for overrides
 * @ return the bindings that should be used to override */
protected GuiceableModule [ ] overrides ( ApplicationLoader . Context context ) { } }

implementation: scala . collection . Seq < GuiceableModule > seq = play . api . inject . guice . GuiceApplicationLoader$ . MODULE$ . defaultOverrides ( context . asScala ( ) ) ; return Scala . asArray ( GuiceableModule . class , seq ) ;


signature:
public class Controller { /** * Generates a 501 NOT _ IMPLEMENTED simple result . */
public static Result TODO ( Request request ) { } }

implementation: return status ( NOT_IMPLEMENTED , views . html . defaultpages . todo . render ( request . asScala ( ) ) ) ;


signature:
public class Controller { /** * Puts a new value into the current session .
 * @ param key the key to set into the session
 * @ param value the value to set for < code > key < / code >
 * @ deprecated Deprecated as of 2.7.0 . Use { @ link Result } instead . */
@ Deprecated public static void session ( String key , String value ) { } }

implementation: session ( ) . put ( key , value ) ;


signature:
public class Controller { /** * Puts a new value into the flash scope .
 * @ param key the key to put into the flash scope
 * @ param value the value corresponding to < code > key < / code >
 * @ deprecated Deprecated as of 2.7.0 . Use { @ link Result } instead . */
@ Deprecated public static void flash ( String key , String value ) { } }

implementation: flash ( ) . put ( key , value ) ;


signature:
public class JavaActionsComposition { /** * # pass - arg - action - index */
@ With ( PassArgAction . class ) public static Result passArgIndex ( Http . Request request ) { } }

implementation: User user = request . attrs ( ) . get ( Attrs . USER ) ; return ok ( Json . toJson ( user ) ) ;


signature:
public class BindingKey { /** * Qualify this binding key with the given instance of an annotation .
 * < p > This can be used to specify bindings with annotations that have particular values . */
public < A extends Annotation > BindingKey < T > qualifiedWith ( final A instance ) { } }

implementation: return underlying . qualifiedWith ( instance ) . asJava ( ) ;


signature:
public class BindingKey { /** * Qualify this binding key with the given annotation .
 * < p > For example , you may have both a cached implementation , and a direct implementation of a
 * service . To differentiate between them , you may define a Cached annotation :
 * < pre > { @ code
 * bindClass ( Foo . class ) . qualifiedWith ( Cached . class ) . to ( FooCached . class ) ,
 * bindClass ( Foo . class ) . to ( FooImpl . class )
 * class MyController {
 * { @ literal @ } Inject
 * MyController ( { @ literal @ } Cached Foo foo ) {
 * } < / pre >
 * In the above example , the controller will get the cached { @ code Foo } service . */
public < A extends Annotation > BindingKey < T > qualifiedWith ( final Class < A > annotation ) { } }

implementation: return underlying . qualifiedWith ( annotation ) . asJava ( ) ;


signature:
public class BindingKey { /** * Bind this binding key to the given implementation class .
 * < p > This class will be instantiated and injected by the injection framework . */
public Binding < T > to ( final Class < ? extends T > implementation ) { } }

implementation: return underlying . to ( implementation ) . asJava ( ) ;


signature:
public class BindingKey { /** * Bind this binding key to the given provider instance .
 * < p > This provider instance will be invoked to obtain the implementation for the key . */
public Binding < T > to ( final Provider < ? extends T > provider ) { } }

implementation: return underlying . to ( provider ) . asJava ( ) ;


signature:
public class BindingKey { /** * Bind this binding key to the given instance . */
public < A extends T > Binding < T > to ( final Supplier < A > instance ) { } }

implementation: return underlying . to ( new FromJavaSupplier < > ( instance ) ) . asJava ( ) ;


signature:
public class BindingKey { /** * Bind this binding key to another binding key . */
public Binding < T > to ( final BindingKey < ? extends T > key ) { } }

implementation: return underlying . to ( key . asScala ( ) ) . asJava ( ) ;


signature:
public class BindingKey { /** * Bind this binding key to the given provider class .
 * < p > The dependency injection framework will instantiate and inject this provider , and then
 * invoke its ` get ` method whenever an instance of the class is needed . */
public < P extends Provider < ? extends T > > Binding < T > toProvider ( final Class < P > provider ) { } }

implementation: return underlying . toProvider ( provider ) . asJava ( ) ;


signature:
public class CaffeineParser { /** * Returns a configured { @ link Caffeine } cache builder . */
public static Caffeine < Object , Object > from ( Config config ) { } }

implementation: CaffeineParser parser = new CaffeineParser ( config ) ; config . entrySet ( ) . stream ( ) . map ( Map . Entry :: getKey ) . forEach ( parser :: parse ) ; return parser . cacheBuilder ;


signature:
public class Lang { /** * Create a Lang value from a code ( such as fr or en - US ) .
 * @ param code the language code
 * @ return the Lang for the code , or null of no matching lang was found . */
public static Lang forCode ( String code ) { } }

implementation: try { return new Lang ( play . api . i18n . Lang . apply ( code ) ) ; } catch ( Exception e ) { return null ; }


signature:
public class Lang { /** * Retrieve Lang availables from the application configuration .
 * @ param app the current application .
 * @ return the list of available Lang . */
public static List < Lang > availables ( Application app ) { } }

implementation: play . api . i18n . Langs langs = app . injector ( ) . instanceOf ( play . api . i18n . Langs . class ) ; List < play . api . i18n . Lang > availableLangs = Scala . asJava ( langs . availables ( ) ) ; return availableLangs . stream ( ) . map ( Lang :: new ) . collect ( toList ( ) ) ;


signature:
public class Lang { /** * Guess the preferred lang in the langs set passed as argument . The first Lang that matches an
 * available Lang wins , otherwise returns the first Lang available in this application .
 * @ param app the currept application
 * @ param availableLangs the set of langs from which to guess the preferred
 * @ return the preferred lang . */
public static Lang preferred ( Application app , List < Lang > availableLangs ) { } }

implementation: play . api . i18n . Langs langs = app . injector ( ) . instanceOf ( play . api . i18n . Langs . class ) ; Stream < Lang > stream = availableLangs . stream ( ) ; List < play . api . i18n . Lang > langSeq = stream . map ( l -> new play . api . i18n . Lang ( l . toLocale ( ) ) ) . collect ( toList ( ) ) ; return new Lang ( langs . preferred ( Scala . toSeq ( langSeq ) ) ) ;


signature:
public class Evolutions { /** * Create an evolutions reader that reads evolution files from a classloader .
 * @ param classLoader The classloader to read from .
 * @ return the evolutions reader . */
public static play . api . db . evolutions . EvolutionsReader fromClassLoader ( ClassLoader classLoader ) { } }

implementation: return fromClassLoader ( classLoader , "" ) ;


signature:
public class Evolutions { /** * Create an evolutions reader that reads evolution files from a classloader .
 * @ param classLoader The classloader to read from .
 * @ param prefix A prefix that gets added to the resource file names , for example , this could be
 * used to namespace evolutions in different environments to work with different databases .
 * @ return the evolutions reader . */
public static play . api . db . evolutions . EvolutionsReader fromClassLoader ( ClassLoader classLoader , String prefix ) { } }

implementation: return new play . api . db . evolutions . ClassLoaderEvolutionsReader ( classLoader , prefix ) ;


signature:
public class Evolutions { /** * Create an evolutions reader based on a simple map of database names to evolutions .
 * @ param evolutions The map of database names to evolutions .
 * @ return the evolutions reader . */
public static play . api . db . evolutions . EvolutionsReader fromMap ( Map < String , List < Evolution > > evolutions ) { } }

implementation: return new SimpleEvolutionsReader ( evolutions ) ;


signature:
public class Evolutions { /** * Create an evolutions reader for the default database from a list of evolutions .
 * @ param evolutions The list of evolutions .
 * @ return the evolutions reader . */
public static play . api . db . evolutions . EvolutionsReader forDefault ( Evolution ... evolutions ) { } }

implementation: Map < String , List < Evolution > > map = new HashMap < String , List < Evolution > > ( ) ; map . put ( "default" , Arrays . asList ( evolutions ) ) ; return fromMap ( map ) ;


signature:
public class Evolutions { /** * Apply evolutions for the given database .
 * @ param database The database to apply the evolutions to .
 * @ param reader The reader to read the evolutions .
 * @ param autocommit Whether autocommit should be used .
 * @ param schema The schema where all the play evolution tables are saved in */
public static void applyEvolutions ( Database database , play . api . db . evolutions . EvolutionsReader reader , boolean autocommit , String schema ) { } }

implementation: DatabaseEvolutions evolutions = new DatabaseEvolutions ( database . asScala ( ) , schema ) ; evolutions . evolve ( evolutions . scripts ( reader ) , autocommit ) ;


signature:
public class Evolutions { /** * Apply evolutions for the given database .
 * @ param database The database to apply the evolutions to .
 * @ param reader The reader to read the evolutions .
 * @ param schema The schema where all the play evolution tables are saved in */
public static void applyEvolutions ( Database database , play . api . db . evolutions . EvolutionsReader reader , String schema ) { } }

implementation: applyEvolutions ( database , reader , true , schema ) ;


signature:
public class Evolutions { /** * Cleanup evolutions for the given database .
 * < p > This will run the down scripts for all the applied evolutions .
 * @ param database The database to apply the evolutions to .
 * @ param autocommit Whether autocommit should be used .
 * @ param schema The schema where all the play evolution tables are saved in */
public static void cleanupEvolutions ( Database database , boolean autocommit , String schema ) { } }

implementation: DatabaseEvolutions evolutions = new DatabaseEvolutions ( database . asScala ( ) , schema ) ; evolutions . evolve ( evolutions . resetScripts ( ) , autocommit ) ;


signature:
public class GuiceApplicationBuilder { /** * Set the initial configuration loader . Overrides the default or any previously configured
 * values .
 * @ param load the configuration loader
 * @ return the configured application builder */
public GuiceApplicationBuilder withConfigLoader ( Function < Environment , Config > load ) { } }

implementation: return newBuilder ( delegate . loadConfig ( func ( ( play . api . Environment env ) -> new play . api . Configuration ( load . apply ( new Environment ( env ) ) ) ) ) ) ;


signature:
public class GuiceApplicationBuilder { /** * Set the module loader . Overrides the default or any previously configured values .
 * @ param loader the configuration
 * @ return the configured application builder */
public GuiceApplicationBuilder withModuleLoader ( BiFunction < Environment , Config , List < GuiceableModule > > loader ) { } }

implementation: return newBuilder ( delegate . load ( func ( ( play . api . Environment env , play . api . Configuration conf ) -> Scala . toSeq ( loader . apply ( new Environment ( env ) , conf . underlying ( ) ) ) ) ) ) ;


signature:
public class GuiceApplicationBuilder { /** * Override the module loader with the given guiceable modules .
 * @ param modules the set of overriding modules
 * @ return an application builder that incorporates the overrides */
public GuiceApplicationBuilder load ( GuiceableModule ... modules ) { } }

implementation: return newBuilder ( delegate . load ( Scala . varargs ( modules ) ) ) ;


signature:
public class GuiceApplicationBuilder { /** * Override the module loader with the given Guice modules .
 * @ param modules the set of overriding modules
 * @ return an application builder that incorporates the overrides */
public GuiceApplicationBuilder load ( com . google . inject . Module ... modules ) { } }

implementation: return load ( Guiceable . modules ( modules ) ) ;


signature:
public class GuiceApplicationBuilder { /** * Override the module loader with the given Play modules .
 * @ param modules the set of overriding modules
 * @ return an application builder that incorporates the overrides */
public GuiceApplicationBuilder load ( play . api . inject . Module ... modules ) { } }


signature:
public class GuiceApplicationBuilder { /** * Override the module loader with the given Play bindings .
 * @ param bindings the set of binding override
 * @ return an application builder that incorporates the overrides */
public GuiceApplicationBuilder load ( play . api . inject . Binding < ? > ... bindings ) { } }

implementation: return load ( Guiceable . bindings ( bindings ) ) ;


signature:
public class GuiceApplicationBuilder { /** * Implementation of Self creation for GuiceBuilder .
 * @ return the application builder */
protected GuiceApplicationBuilder newBuilder ( play . api . inject . guice . GuiceApplicationBuilder builder ) { } }

implementation: return new GuiceApplicationBuilder ( builder ) ;


signature:
public class ClientCookieEncoder { /** * Encodes the specified cookie into a Cookie header value .
 * @ param cookie specified the cookie
 * @ return a Rfc6265 style Cookie header value */
public String encode ( Cookie cookie ) { } }

implementation: if ( cookie == null ) { throw new NullPointerException ( "cookie" ) ; } StringBuilder buf = new StringBuilder ( ) ; encode ( buf , cookie ) ; return stripTrailingSeparator ( buf ) ;


signature:
public class ClientCookieEncoder { /** * Encodes the specified cookies into a single Cookie header value .
 * @ param cookies some cookies
 * @ return a Rfc6265 style Cookie header value , null if no cookies are passed . */
public String encode ( Cookie ... cookies ) { } }

implementation: if ( cookies == null ) { throw new NullPointerException ( "cookies" ) ; } if ( cookies . length == 0 ) { return null ; } StringBuilder buf = new StringBuilder ( ) ; for ( Cookie c : cookies ) { if ( c == null ) { break ; } encode ( buf , c ) ; } return stripTrailingSeparatorOrNull ( buf ) ;


signature:
public class ClientCookieEncoder { /** * Encodes the specified cookies into a single Cookie header value .
 * @ param cookies some cookies
 * @ return a Rfc6265 style Cookie header value , null if no cookies are passed . */
public String encode ( Iterable < ? extends Cookie > cookies ) { } }

implementation: if ( cookies == null ) { throw new NullPointerException ( "cookies" ) ; } Iterator < ? extends Cookie > cookiesIt = cookies . iterator ( ) ; if ( ! cookiesIt . hasNext ( ) ) { return null ; } StringBuilder buf = new StringBuilder ( ) ; while ( cookiesIt . hasNext ( ) ) { Cookie c = cookiesIt . next ( ) ; if ( c == null ) { break ; } encode ( buf , c ) ; } return stripTrailingSeparatorOrNull ( buf ) ;


signature:
public class JPAEntityManagerContext { /** * Get the default EntityManager for this thread .
 * @ throws RuntimeException if no EntityManager is bound to the current Http . Context or the
 * current Thread .
 * @ return the EntityManager */
public EntityManager em ( ) { } }

implementation: Deque < EntityManager > ems = this . emStack ( true ) ; if ( ems . isEmpty ( ) ) { Http . Context . safeCurrent ( ) . map ( ctx -> { throw new RuntimeException ( "No EntityManager found in the context. Try to annotate your action method with @play.db.jpa.Transactional" ) ; } ) . orElseGet ( ( ) -> { throw new RuntimeException ( "No EntityManager bound to this thread. Try wrapping this call in JPAApi.withTransaction, or ensure that the HTTP context is setup on this thread." ) ; } ) ; } return ems . peekFirst ( ) ;


signature:
public class JPAEntityManagerContext { /** * Get the EntityManager stack .
 * @ param threadLocalFallback if true , fall back to a ThreadLocal queue of entity managers if no
 * HTTP . Context object is found .
 * @ return the queue of entity managers . */
@ SuppressWarnings ( "unchecked" ) public Deque < EntityManager > emStack ( boolean threadLocalFallback ) { } }

implementation:
return Http . Context . safeCurrent ( ) . map ( context -> { Object emsObject = context . args . get ( CURRENT_ENTITY_MANAGER ) ; if ( emsObject != null ) { return ( Deque < EntityManager > ) emsObject ; } else { Deque < EntityManager > ems = new ArrayDeque < > ( ) ; context . args . put ( CURRENT_ENTITY_MANAGER , ems ) ; return ems ; } } ) . orElseGet ( ( ) -> { // Not a web request
if ( threadLocalFallback ) { return this . get ( ) ; } else { throw new RuntimeException ( "No Http.Context is present. If you want to invoke this method outside of a HTTP request, you need to wrap the call with JPA.withTransaction instead." ) ; } } ) ;


signature:
public class JPAEntityManagerContext { /** * Pushes or pops the EntityManager stack depending on the value of the em argument . If em is
 * null , then the current EntityManager is popped . If em is non - null , then em is pushed onto the
 * stack and becomes the current EntityManager .
 * @ param em the entity manager to push , if null then will pop one off the stack .
 * @ param threadLocalFallback if true , fall back to a ThreadLocal queue of entity managers if no
 * HTTP . Context object is found . */
void pushOrPopEm ( EntityManager em , boolean threadLocalFallback ) { } }

implementation: Deque < EntityManager > ems = this . emStack ( threadLocalFallback ) ; if ( em != null ) { ems . push ( em ) ; } else { if ( ems . isEmpty ( ) ) { throw new IllegalStateException ( "Tried to remove the EntityManager, but none was set." ) ; } ems . pop ( ) ; }


signature:
public class JavaJsonActions { /** * # person - class */
@ Test public void fromJson ( ) { } }

implementation:
// # from - json
// parse the JSON as a JsonNode
JsonNode json = Json . parse ( "{\"firstName\":\"Foo\", \"lastName\":\"Bar\", \"age\":13}" ) ; // read the JsonNode as a Person
Person person = Json . fromJson ( json , Person . class ) ; // # from - json
assertThat ( person . firstName , equalTo ( "Foo" ) ) ; assertThat ( person . lastName , equalTo ( "Bar" ) ) ; assertThat ( person . age , equalTo ( 13 ) ) ;


signature:
public class JavaXmlRequests { /** * # xml - hello */
public Result sayHello ( Http . Request request ) { } }

implementation: Document dom = request . body ( ) . asXml ( ) ; if ( dom == null ) { return badRequest ( "Expecting Xml data" ) ; } else { String name = XPath . selectText ( "//name" , dom ) ; if ( name == null ) { return badRequest ( "Missing parameter [name]" ) ; } else { return ok ( "Hello " + name ) ; } }


signature:
public class JavaXmlRequests { /** * # xml - hello - bodyparser */
@ BodyParser . Of ( BodyParser . Xml . class ) public Result sayHelloBP ( Http . Request request ) { } }


signature:
public class AkkaStreams { /** * Bypass the given flow using the given splitter function .
 * < p > If the splitter function returns Left , they will go through the flow . If it returns Right ,
 * they will bypass the flow .
 * < p > Uses onlyFirstCanFinishMerge ( 2 ) by default .
 * @ param < In > the In type parameter for Flow
 * @ param < FlowIn > the FlowIn type parameter for the left branch in Either .
 * @ param < Out > the Out type parameter for Flow
 * @ param flow the original flow
 * @ param splitter the splitter function to use
 * @ return the flow with a bypass . */
public static < In , FlowIn , Out > Flow < In , Out , ? > bypassWith ( Function < In , F . Either < FlowIn , Out > > splitter , Flow < FlowIn , Out , ? > flow ) { } }

implementation: return bypassWith ( Flow . < In > create ( ) . map ( splitter :: apply ) , play . api . libs . streams . AkkaStreams . onlyFirstCanFinishMerge ( 2 ) , flow ) ;


signature:
public class AkkaStreams { /** * Using the given splitter flow , allow messages to bypass a flow .
 * < p > If the splitter flow produces Left , they will be fed into the flow . If it produces Right ,
 * they will bypass the flow .
 * @ param < In > the In type parameter for Flow
 * @ param < FlowIn > the FlowIn type parameter for the left branch in Either .
 * @ param < Out > the Out type parameter for Flow .
 * @ param flow the original flow .
 * @ param splitter the splitter function .
 * @ param mergeStrategy the merge strategy ( onlyFirstCanFinishMerge , ignoreAfterFinish ,
 * ignoreAfterCancellation )
 * @ return the flow with a bypass . */
public static < In , FlowIn , Out > Flow < In , Out , ? > bypassWith ( Flow < In , F . Either < FlowIn , Out > , ? > splitter , Graph < UniformFanInShape < Out , Out > , ? > mergeStrategy , Flow < FlowIn , Out , ? > flow ) { } }

implementation:
return splitter . via ( Flow . fromGraph ( GraphDSL . < FlowShape < F . Either < FlowIn , Out > , Out > > create ( builder -> { // Eager cancel must be true so that if the flow cancels , that will be propagated
// upstream .
// However , that means the bypasser must block cancel , since when this flow
// finishes , the merge
// will result in a cancel flowing up through the bypasser , which could lead to
// dropped messages .
// Using scaladsl here because of https : / / github . com / akka / akka / issues / 18384
UniformFanOutShape < F . Either < FlowIn , Out > , F . Either < FlowIn , Out > > broadcast = builder . add ( Broadcast . create ( 2 , true ) ) ; UniformFanInShape < Out , Out > merge = builder . add ( mergeStrategy ) ; Flow < F . Either < FlowIn , Out > , FlowIn , ? > collectIn = Flow . < F . Either < FlowIn , Out > > create ( ) . collect ( Scala . partialFunction ( x -> { if ( x . left . isPresent ( ) ) { return x . left . get ( ) ; } else { throw Scala . noMatch ( ) ; } } ) ) ; Flow < F . Either < FlowIn , Out > , Out , ? > collectOut = Flow . < F . Either < FlowIn , Out > > create ( ) . collect ( Scala . partialFunction ( x -> { if ( x . right . isPresent ( ) ) { return x . right . get ( ) ; } else { throw Scala . noMatch ( ) ; } } ) ) ; Flow < F . Either < FlowIn , Out > , F . Either < FlowIn , Out > , ? > blockCancel = play . api . libs . streams . AkkaStreams . < F . Either < FlowIn , Out > > ignoreAfterCancellation ( ) . asJava ( ) ; // Normal flow
builder . from ( broadcast . out ( 0 ) ) . via ( builder . add ( collectIn ) ) . via ( builder . add ( flow ) ) . toInlet ( merge . in ( 0 ) ) ; // Bypass flow , need to ignore downstream finish
builder . from ( broadcast . out ( 1 ) ) . via ( builder . add ( blockCancel ) ) . via ( builder . add ( collectOut ) ) . toInlet ( merge . in ( 1 ) ) ; return new FlowShape < > ( broadcast . in ( ) , merge . out ( ) ) ; } ) ) ) ;


signature:
public class ActorFlow { /** * Create a flow that is handled by an actor .
 * < p > Messages can be sent downstream by sending them to the actor passed into the props function .
 * This actor meets the contract of the actor returned by { @ link
 * akka . stream . javadsl . Source # actorRef } .
 * < p > The props function should return the props for an actor to handle the flow . This actor will
 * be created using the passed in { @ link akka . actor . ActorRefFactory } . Each message received will
 * be sent to the actor - there is no back pressure , if the actor is unable to process the
 * messages , they will queue up in the actors mailbox . The upstream can be cancelled by the actor
 * terminating itself .
 * @ param < In > the In type parameter for a Flow
 * @ param < Out > the Out type parameter for a Flow
 * @ param props A function that creates the props for actor to handle the flow .
 * @ param bufferSize The maximum number of elements to buffer .
 * @ param overflowStrategy The strategy for how to handle a buffer overflow .
 * @ param factory The Actor Factory used to create the actor to handle the flow - for example , an
 * ActorSystem .
 * @ param mat The materializer to materialize the flow .
 * @ return the flow itself . */
public static < In , Out > Flow < In , Out , ? > actorRef ( Function < ActorRef , Props > props , int bufferSize , OverflowStrategy overflowStrategy , ActorRefFactory factory , Materializer mat ) { } }

implementation: return play . api . libs . streams . ActorFlow . < In , Out > actorRef ( new AbstractFunction1 < ActorRef , Props > ( ) { @ Override public Props apply ( ActorRef v1 ) { return props . apply ( v1 ) ; } } , bufferSize , overflowStrategy , factory , mat ) . asJava ( ) ;


signature:
public class Form { /** * Binds request data to this form - that is , handles form submission .
 * @ param allowedFields the fields that should be bound to the form , all fields if not specified .
 * @ return a copy of this form filled with the new data
 * @ deprecated Deprecated as of 2.7.0 . Use { @ link # bindFromRequest ( Http . Request , String . . . ) }
 * instead . */
@ Deprecated public Form < T > bindFromRequest ( String ... allowedFields ) { } }

implementation: return bind ( play . mvc . Controller . ctx ( ) . messages ( ) . lang ( ) , play . mvc . Controller . request ( ) . attrs ( ) , requestData ( play . mvc . Controller . request ( ) ) , requestFileData ( play . mvc . Controller . request ( ) ) , allowedFields ) ;


signature:
public class Form { /** * Binds request data to this form - that is , handles form submission .
 * @ param request the request to bind data from .
 * @ param allowedFields the fields that should be bound to the form , all fields if not specified .
 * @ return a copy of this form filled with the new data */
public Form < T > bindFromRequest ( Http . Request request , String ... allowedFields ) { } }

implementation: return bind ( this . messagesApi . preferred ( request ) . lang ( ) , request . attrs ( ) , requestData ( request ) , requestFileData ( request ) , allowedFields ) ;


signature:
public class Form { /** * Binds request data to this form - that is , handles form submission .
 * @ param requestData the map of data to bind from
 * @ param allowedFields the fields that should be bound to the form , all fields if not specified .
 * @ return a copy of this form filled with the new data
 * @ deprecated Deprecated as of 2.7.0 . Use { @ link # bindFromRequestData ( Lang , TypedMap , Map ,
 * String . . . ) } instead . */
@ Deprecated public Form < T > bindFromRequest ( Map < String , String [ ] > requestData , String ... allowedFields ) { } }

implementation: return bindFromRequestData ( ctxLang ( ) , ctxRequestAttrs ( ) , requestData , allowedFields ) ;


signature:
public class Form { /** * Binds request data to this form - that is , handles form submission .
 * @ param lang used for validators and formatters during binding and is part of { @ link
 * ValidationPayload } . Later also used for formatting when retrieving a field ( via { @ link
 * # field ( String ) } or { @ link # apply ( String ) } ) and for translations in { @ link # errorsAsJson ( ) } .
 * For these methods the lang can be change via { @ link # withLang ( Lang ) } .
 * @ param attrs will be passed to validators via { @ link ValidationPayload }
 * @ param requestData the map of data to bind from
 * @ param allowedFields the fields that should be bound to the form , all fields if not specified .
 * @ return a copy of this form filled with the new data */
public Form < T > bindFromRequestData ( Lang lang , TypedMap attrs , Map < String , String [ ] > requestData , String ... allowedFields ) { } }

implementation: return bindFromRequestData ( lang , attrs , requestData , Collections . emptyMap ( ) , allowedFields ) ;


signature:
public class Form { /** * Binds Json data to this form - that is , handles form submission .
 * @ param data data to submit
 * @ param allowedFields the fields that should be bound to the form , all fields if not specified .
 * @ return a copy of this form filled with the new data
 * @ deprecated Deprecated as of 2.7.0 . Use { @ link # bind ( Lang , TypedMap , JsonNode , String . . . ) }
 * instead . */
@ Deprecated public Form < T > bind ( JsonNode data , String ... allowedFields ) { } }

implementation: return bind ( ctxLang ( ) , ctxRequestAttrs ( ) , data , allowedFields ) ;


signature:
public class Form { /** * Binds Json data to this form - that is , handles form submission .
 * @ param lang used for validators and formatters during binding and is part of { @ link
 * ValidationPayload } . Later also used for formatting when retrieving a field ( via { @ link
 * # field ( String ) } or { @ link # apply ( String ) } ) and for translations in { @ link # errorsAsJson ( ) } .
 * For these methods the lang can be change via { @ link # withLang ( Lang ) } .
 * @ param attrs will be passed to validators via { @ link ValidationPayload }
 * @ param data data to submit
 * @ param allowedFields the fields that should be bound to the form , all fields if not specified .
 * @ return a copy of this form filled with the new data */
public Form < T > bind ( Lang lang , TypedMap attrs , JsonNode data , String ... allowedFields ) { } }

implementation: return bind ( lang , attrs , play . libs . Scala . asJava ( play . api . data . FormUtils . fromJson ( "" , play . api . libs . json . Json . parse ( play . libs . Json . stringify ( data ) ) ) ) , allowedFields ) ;


signature:
public class Form { /** * When dealing with @ ValidateWith or @ ValidatePayloadWith annotations , and message parameter is
 * not used in the annotation , extract the message from validator ' s getErrorMessageKey ( ) method
 * @ param violation the constraint violation .
 * @ return the message associated with the constraint violation . */
protected String getMessageForConstraintViolation ( ConstraintViolation < Object > violation ) { } }

implementation: String errorMessage = violation . getMessage ( ) ; Annotation annotation = violation . getConstraintDescriptor ( ) . getAnnotation ( ) ; if ( annotation instanceof Constraints . ValidateWith ) { Constraints . ValidateWith validateWithAnnotation = ( Constraints . ValidateWith ) annotation ; if ( violation . getMessage ( ) . equals ( Constraints . ValidateWithValidator . defaultMessage ) ) { Constraints . ValidateWithValidator validateWithValidator = new Constraints . ValidateWithValidator ( ) ; validateWithValidator . initialize ( validateWithAnnotation ) ; Tuple < String , Object [ ] > errorMessageKey = validateWithValidator . getErrorMessageKey ( ) ; if ( errorMessageKey != null && errorMessageKey . _1 != null ) { errorMessage = errorMessageKey . _1 ; } } } if ( annotation instanceof Constraints . ValidatePayloadWith ) { Constraints . ValidatePayloadWith validatePayloadWithAnnotation = ( Constraints . ValidatePayloadWith ) annotation ; if ( violation . getMessage ( ) . equals ( Constraints . ValidatePayloadWithValidator . defaultMessage ) ) { Constraints . ValidatePayloadWithValidator validatePayloadWithValidator = new Constraints . ValidatePayloadWithValidator ( ) ; validatePayloadWithValidator . initialize ( validatePayloadWithAnnotation ) ; Tuple < String , Object [ ] > errorMessageKey = validatePayloadWithValidator . getErrorMessageKey ( ) ; if ( errorMessageKey != null && errorMessageKey . _1 != null ) { errorMessage = errorMessageKey . _1 ; } } } return errorMessage ;


signature:
public class Form { /** * Binds data to this form - that is , handles form submission .
 * @ param data data to submit
 * @ param allowedFields the fields that should be bound to the form , all fields if not specified .
 * @ return a copy of this form filled with the new data
 * @ deprecated Deprecated as of 2.7.0 . Use { @ link # bind ( Lang , TypedMap , Map , String . . . ) } instead . */
@ SuppressWarnings ( "unchecked" ) @ Deprecated public Form < T > bind ( Map < String , String > data , String ... allowedFields ) { } }


signature:
public class Form { /** * Binds data to this form - that is , handles form submission .
 * @ param lang used for validators and formatters during binding and is part of { @ link
 * ValidationPayload } . Later also used for formatting when retrieving a field ( via { @ link
 * # field ( String ) } or { @ link # apply ( String ) } ) and for translations in { @ link # errorsAsJson ( ) } .
 * For these methods the lang can be change via { @ link # withLang ( Lang ) } .
 * @ param attrs will be passed to validators via { @ link ValidationPayload }
 * @ param data data to submit
 * @ param allowedFields the fields that should be bound to the form , all fields if not specified .
 * @ return a copy of this form filled with the new data */
@ SuppressWarnings ( "unchecked" ) public Form < T > bind ( Lang lang , TypedMap attrs , Map < String , String > data , String ... allowedFields ) { } }

implementation: return bind ( lang , attrs , data , Collections . emptyMap ( ) , allowedFields ) ;


signature:
public class Form { /** * Binds data to this form - that is , handles form submission .
 * @ param lang used for validators and formatters during binding and is part of { @ link
 * ValidationPayload } . Later also used for formatting when retrieving a field ( via { @ link
 * # field ( String ) } or { @ link # apply ( String ) } ) and for translations in { @ link # errorsAsJson ( ) } .
 * For these methods the lang can be change via { @ link # withLang ( Lang ) } .
 * @ param attrs will be passed to validators via { @ link ValidationPayload }
 * @ param data data to submit
 * @ param allowedFields the fields that should be bound to the form , all fields if not specified .
 * @ return a copy of this form filled with the new data */
@ SuppressWarnings ( "unchecked" ) public Form < T > bind ( Lang lang , TypedMap attrs , Map < String , String > data , Map < String , Http . MultipartFormData . FilePart < ? > > files , String ... allowedFields ) { } }

implementation: final DataBinder dataBinder = dataBinder ( allowedFields ) ; final Map < String , Object > objectDataFinal = getObjectData ( data , files ) ; final Set < ConstraintViolation < Object > > validationErrors = runValidation ( lang , attrs , dataBinder , objectDataFinal ) ; final BindingResult result = dataBinder . getBindingResult ( ) ; validationErrors . forEach ( violation -> addConstraintViolationToBindingResult ( violation , result ) ) ; boolean hasAnyError = result . hasErrors ( ) || result . getGlobalErrorCount ( ) > 0 ; if ( hasAnyError ) { final List < ValidationError > errors = getFieldErrorsAsValidationErrors ( lang , result ) ; final List < ValidationError > globalErrors = globalErrorsAsValidationErrors ( result ) ; errors . addAll ( globalErrors ) ; return new Form < > ( rootName , backedType , data , files , errors , Optional . ofNullable ( ( T ) result . getTarget ( ) ) , groups , messagesApi , formatters , this . validatorFactory , config , lang , directFieldAccess ) ; } return new Form < > ( rootName , backedType , data , files , errors , Optional . ofNullable ( ( T ) result . getTarget ( ) ) , groups , messagesApi , formatters , this . validatorFactory , config , lang , directFieldAccess ) ;


signature:
public class Form { /** * Convert the error arguments .
 * @ param arguments The arguments to convert .
 * @ return The converted arguments . */
private List < Object > convertErrorArguments ( Object [ ] arguments ) { } }

implementation: if ( arguments == null ) { return Collections . emptyList ( ) ; } List < Object > converted = Arrays . stream ( arguments ) . filter ( arg -> ! ( arg instanceof org . springframework . context . support . DefaultMessageSourceResolvable ) ) . collect ( Collectors . toList ( ) ) ; return Collections . unmodifiableList ( converted ) ;


signature:
public class Form { /** * Populates this form with an existing value , used for edit forms .
 * @ param value existing value of type < code > T < / code > used to fill this form
 * @ return a copy of this form filled with the new data */
public Form < T > fill ( T value ) { } }

implementation: if ( value == null ) { throw new RuntimeException ( "Cannot fill a form with a null value" ) ; } return new Form < > ( rootName , backedType , new HashMap < > ( ) , new HashMap < > ( ) , new ArrayList < > ( ) , Optional . ofNullable ( value ) , groups , messagesApi , formatters , validatorFactory , config , lang , directFieldAccess ) ;


signature:
public class Form { /** * Retrieve all global errors - errors without a key .
 * @ return All global errors . */
public List < ValidationError > globalErrors ( ) { } }

implementation: return Collections . unmodifiableList ( errors . stream ( ) . filter ( error -> error . key ( ) . isEmpty ( ) ) . collect ( Collectors . toList ( ) ) ) ;


signature:
public class Form { /** * Returns the form errors serialized as Json using the given Lang .
 * @ param lang the language to use .
 * @ return the JSON node containing the errors . */
public JsonNode errorsAsJson ( Lang lang ) { } }

implementation: Map < String , List < String > > allMessages = new HashMap < > ( ) ; errors . forEach ( error -> { if ( error != null ) { final List < String > messages = new ArrayList < > ( ) ; if ( messagesApi != null && lang != null ) { final List < String > reversedMessages = new ArrayList < > ( error . messages ( ) ) ; Collections . reverse ( reversedMessages ) ; messages . add ( messagesApi . get ( lang , reversedMessages , translateMsgArg ( error . arguments ( ) , messagesApi , lang ) ) ) ; } else { messages . add ( error . message ( ) ) ; } allMessages . put ( error . key ( ) , messages ) ; } } ) ; return play . libs . Json . toJson ( allMessages ) ;


signature:
public class Form { /** * Gets the concrete value only if the submission was a success . If the form is invalid because of
 * validation errors this method will throw an exception . If you want to retrieve the value even
 * when the form is invalid use { @ link # value ( ) } instead .
 * @ param lang if an IllegalStateException gets thrown it ' s used to translate the form errors
 * within that exception
 * @ throws IllegalStateException if there are errors binding the form , including the errors as
 * JSON in the message
 * @ return the concrete value . */
public T get ( Lang lang ) { } }

implementation: if ( ! errors . isEmpty ( ) ) { throw new IllegalStateException ( "Error(s) binding form: " + errorsAsJson ( lang ) ) ; } return value . get ( ) ;


signature:
public class Form { /** * Retrieves a field .
 * @ param key field name
 * @ param lang used for formatting
 * @ return the field ( even if the field does not exist you get a field ) */
public Field field ( final String key , final Lang lang ) { } }

implementation:
// Value
String fieldValue = null ; Http . MultipartFormData . FilePart file = null ; if ( rawData . containsKey ( key ) ) { fieldValue = rawData . get ( key ) ; } else if ( files . containsKey ( key ) ) { file = files . get ( key ) ; } else { if ( value . isPresent ( ) ) { BeanWrapper beanWrapper = new BeanWrapperImpl ( value . get ( ) ) ; beanWrapper . setAutoGrowNestedPaths ( true ) ; String objectKey = key ; if ( rootName != null && key . startsWith ( rootName + "." ) ) { objectKey = key . substring ( rootName . length ( ) + 1 ) ; } if ( beanWrapper . isReadableProperty ( objectKey ) ) { Object oValue = beanWrapper . getPropertyValue ( objectKey ) ; if ( oValue != null ) { if ( oValue instanceof Http . MultipartFormData . FilePart < ? > ) { file = ( Http . MultipartFormData . FilePart < ? > ) oValue ; } else { if ( formatters != null ) { final String objectKeyFinal = objectKey ; fieldValue = withRequestLocale ( lang , ( ) -> formatters . print ( beanWrapper . getPropertyTypeDescriptor ( objectKeyFinal ) , oValue ) ) ; } else { fieldValue = oValue . toString ( ) ; } } } } } } // Format
Tuple < String , List < Object > > format = null ; BeanWrapper beanWrapper = new BeanWrapperImpl ( blankInstance ( ) ) ; beanWrapper . setAutoGrowNestedPaths ( true ) ; try { for ( Annotation a : beanWrapper . getPropertyTypeDescriptor ( key ) . getAnnotations ( ) ) { Class < ? > annotationType = a . annotationType ( ) ; if ( annotationType . isAnnotationPresent ( play . data . Form . Display . class ) ) { play . data . Form . Display d = annotationType . getAnnotation ( play . data . Form . Display . class ) ; if ( d . name ( ) . startsWith ( "format." ) ) { List < Object > attributes = new ArrayList < > ( ) ; for ( String attr : d . attributes ( ) ) { Object attrValue = null ; try { attrValue = a . getClass ( ) . getDeclaredMethod ( attr ) . invoke ( a ) ; } catch ( Exception e ) { // do nothing
} attributes . add ( attrValue ) ; } format = Tuple ( d . name ( ) , Collections . unmodifiableList ( attributes ) ) ; } } } } catch ( NullPointerException e ) { // do nothing
} // Constraints
List < Tuple < String , List < Object > > > constraints = new ArrayList < > ( ) ; Class < ? > classType = backedType ; String leafKey = key ; if ( rootName != null && leafKey . startsWith ( rootName + "." ) ) { leafKey = leafKey . substring ( rootName . length ( ) + 1 ) ; } int p = leafKey . lastIndexOf ( '.' ) ; if ( p > 0 ) { classType = beanWrapper . getPropertyType ( leafKey . substring ( 0 , p ) ) ; leafKey = leafKey . substring ( p + 1 ) ; } if ( classType != null && this . validatorFactory != null ) { BeanDescriptor beanDescriptor = this . validatorFactory . getValidator ( ) . getConstraintsForClass ( classType ) ; if ( beanDescriptor != null ) { PropertyDescriptor property = beanDescriptor . getConstraintsForProperty ( leafKey ) ; if ( property != null ) { Annotation [ ] orderedAnnotations = null ; for ( Class < ? > c = classType ; c != null ; c = c . getSuperclass ( ) ) { // we also check the fields of all superclasses
java . lang . reflect . Field field = null ; try { field = c . getDeclaredField ( leafKey ) ; } catch ( NoSuchFieldException | SecurityException e ) { continue ; } // getDeclaredAnnotations also looks for private fields ; also it provides the
// annotations in a guaranteed order
orderedAnnotations = AnnotationUtils . unwrapContainerAnnotations ( field . getDeclaredAnnotations ( ) ) ; break ; } constraints = Constraints . displayableConstraint ( property . findConstraints ( ) . unorderedAndMatchingGroups ( groups != null ? groups : new Class [ ] { Default . class } ) . getConstraintDescriptors ( ) , orderedAnnotations ) ; } } } return new Field ( this , key , constraints , format , errors ( key ) , fieldValue , file ) ;


signature:
public class Form { /** * A copy of this form with the given lang set which is used for formatting when retrieving a
 * field ( via { @ link # field ( String ) } or { @ link # apply ( String ) } ) and for translations in { @ link
 * # errorsAsJson ( ) } . */
public Form < T > withLang ( Lang lang ) { } }

implementation: return new Form < T > ( this . rootName , this . backedType , this . rawData , this . files , this . errors , this . value , this . groups , this . messagesApi , this . formatters , this . validatorFactory , this . config , lang , this . directFieldAccess ) ;


signature:
public class Form { /** * Sets the locale of the current request ( if there is one ) into Spring ' s LocaleContextHolder .
 * @ param < T > the return type .
 * @ param code The code to execute while the locale is set
 * @ return the result of the code block */
private static < T > T withRequestLocale ( Lang lang , Supplier < T > code ) { } }

implementation:
try { LocaleContextHolder . setLocale ( lang != null ? lang . toLocale ( ) : null ) ; } catch ( Exception e ) { // Just continue ( Maybe there is no context or some internal error in LocaleContextHolder ) .
// System default locale will be used .
} try { return code . get ( ) ; } finally { LocaleContextHolder . resetLocaleContext ( ) ; // Clean up ThreadLocal
}


signature:
public class DynamicForm { /** * Gets the concrete value only if the submission was a success . If the form is invalid because of
 * validation errors or you try to access a file field this method will return null . If you want
 * to retrieve the value even when the form is invalid use { @ link # value ( String ) } instead . If you
 * want to retrieve a file field use { @ link # file ( String ) } instead .
 * @ param key the string key .
 * @ return the value , or null if there is no match . */
public String get ( String key ) { } }

implementation: try { return ( String ) get ( ) . getData ( ) . get ( asNormalKey ( key ) ) ; } catch ( Exception e ) { return null ; }


signature:
public class DynamicForm { /** * Gets the concrete value only if the submission was a success . If the form is invalid because of
 * validation errors or you try to access a non - file field this method will return null . If you
 * want to retrieve the value even when the form is invalid use { @ link # value ( String ) } instead . If
 * you want to retrieve a non - file field use { @ link # get ( String ) } instead .
 * @ param key the string key .
 * @ return the value , or null if there is no match . */
public < A > Http . MultipartFormData . FilePart < A > file ( String key ) { } }

implementation: try { return ( Http . MultipartFormData . FilePart < A > ) get ( ) . getData ( ) . get ( asNormalKey ( key ) ) ; } catch ( Exception e ) { return null ; }


signature:
public class DynamicForm { /** * Gets the concrete value
 * @ param key the string key .
 * @ return the value */
public Optional < Object > value ( String key ) { } }

implementation: return super . value ( ) . map ( v -> v . getData ( ) . get ( asNormalKey ( key ) ) ) ;


signature:
public class DynamicForm { /** * Fills the form with existing data .
 * @ param value the map of values to fill in the form .
 * @ return the modified form . */
public DynamicForm fill ( Map < String , Object > value ) { } }

implementation: Form < Dynamic > form = super . fill ( new Dynamic ( value ) ) ; return new DynamicForm ( form . rawData ( ) , form . files ( ) , form . errors ( ) , form . value ( ) , messagesApi , formatters , validatorFactory , config , lang ( ) . orElse ( null ) ) ;


signature:
public class DynamicForm { /** * - - tools */
static String asDynamicKey ( String key ) { } }

implementation: if ( key . isEmpty ( ) || MATCHES_DATA . matcher ( key ) . matches ( ) ) { return key ; } else { return "data[" + key + "]" ; }


signature:
public class Formatters { /** * Parses this string as instance of the given class .
 * @ param text the text to parse
 * @ param clazz class representing the required type
 * @ param < T > the type to parse out of the text
 * @ return the parsed value */
public < T > T parse ( String text , Class < T > clazz ) { } }

implementation: return conversion . convert ( text , clazz ) ;


signature:
public class Formatters { /** * Parses this string as instance of a specific field
 * @ param field the related field ( custom formatters are extracted from this field annotation )
 * @ param text the text to parse
 * @ param < T > the type to parse out of the text
 * @ return the parsed value */
@ SuppressWarnings ( "unchecked" ) public < T > T parse ( Field field , String text ) { } }

implementation: return ( T ) conversion . convert ( text , new TypeDescriptor ( field ) ) ;


signature:
public class Formatters { /** * Computes the display string for any value .
 * @ param t the value to print
 * @ param < T > the type to print
 * @ return the formatted string */
public < T > String print ( T t ) { } }

implementation: if ( t == null ) { return "" ; } if ( conversion . canConvert ( t . getClass ( ) , String . class ) ) { return conversion . convert ( t , String . class ) ; } else { return t . toString ( ) ; }


signature:
public class Formatters { /** * Computes the display string for any value , for a specific field .
 * @ param field the related field - custom formatters are extracted from this field annotation
 * @ param t the value to print
 * @ param < T > the type to print
 * @ return the formatted string */
public < T > String print ( Field field , T t ) { } }

implementation: return print ( new TypeDescriptor ( field ) , t ) ;


signature:
public class Formatters { /** * Computes the display string for any value , for a specific type .
 * @ param desc the field descriptor - custom formatters are extracted from this descriptor .
 * @ param t the value to print
 * @ param < T > the type to print
 * @ return the formatted string */
public < T > String print ( TypeDescriptor desc , T t ) { } }

implementation: if ( t == null ) { return "" ; } if ( desc != null && conversion . canConvert ( desc , TypeDescriptor . valueOf ( String . class ) ) ) { return ( String ) conversion . convert ( t , desc , TypeDescriptor . valueOf ( String . class ) ) ; } else if ( conversion . canConvert ( t . getClass ( ) , String . class ) ) { return conversion . convert ( t , String . class ) ; } else { return t . toString ( ) ; }


signature:
public class Formatters { /** * Converter for String - > Optional and Optional - > String */
private Formatters registerOptional ( ) { } }

implementation:
conversion . addConverter ( new GenericConverter ( ) { public Object convert ( Object source , TypeDescriptor sourceType , TypeDescriptor targetType ) { if ( sourceType . getObjectType ( ) . equals ( String . class ) ) { // From String to Optional
Object element = conversion . convert ( source , sourceType , targetType . elementTypeDescriptor ( source ) ) ; return Optional . ofNullable ( element ) ; } else if ( targetType . getObjectType ( ) . equals ( String . class ) ) { // From Optional to String
if ( source == null ) return "" ; Optional < ? > opt = ( Optional ) source ; return opt . map ( o -> conversion . convert ( source , sourceType . getElementTypeDescriptor ( ) , targetType ) ) . orElse ( "" ) ; } return null ; } public Set < GenericConverter . ConvertiblePair > getConvertibleTypes ( ) { Set < ConvertiblePair > result = new HashSet < > ( ) ; result . add ( new ConvertiblePair ( Optional . class , String . class ) ) ; result . add ( new ConvertiblePair ( String . class , Optional . class ) ) ; return result ; } } ) ; return this ;


signature:
public class Formatters { /** * Registers a simple formatter .
 * @ param clazz class handled by this formatter
 * @ param < T > the type that this formatter will parse and print
 * @ param formatter the formatter to register
 * @ return the modified Formatters object . */
public < T > Formatters register ( final Class < T > clazz , final SimpleFormatter < T > formatter ) { } }

implementation: conversion . addFormatterForFieldType ( clazz , new org . springframework . format . Formatter < T > ( ) { public T parse ( String text , Locale locale ) throws java . text . ParseException { return formatter . parse ( text , locale ) ; } public String print ( T t , Locale locale ) { return formatter . print ( t , locale ) ; } public String toString ( ) { return formatter . toString ( ) ; } } ) ; return this ;


signature:
public class Formatters { /** * Registers an annotation - based formatter .
 * @ param clazz class handled by this formatter
 * @ param formatter the formatter to register
 * @ param < A > the annotation type
 * @ param < T > the type that will be parsed or printed
 * @ return the modified Formatters object . */
@ SuppressWarnings ( "unchecked" ) public < A extends Annotation , T > Formatters register ( final Class < T > clazz , final AnnotationFormatter < A , T > formatter ) { } }

implementation: final Class < ? extends Annotation > annotationType = ( Class < ? extends Annotation > ) GenericTypeResolver . resolveTypeArguments ( formatter . getClass ( ) , AnnotationFormatter . class ) [ 0 ] ; conversion . addConverter ( new ConditionalGenericConverter ( ) { public Set < GenericConverter . ConvertiblePair > getConvertibleTypes ( ) { Set < GenericConverter . ConvertiblePair > types = new HashSet < > ( ) ; types . add ( new GenericConverter . ConvertiblePair ( clazz , String . class ) ) ; return types ; } public boolean matches ( TypeDescriptor sourceType , TypeDescriptor targetType ) { return ( sourceType . getAnnotation ( annotationType ) != null ) ; } public Object convert ( Object source , TypeDescriptor sourceType , TypeDescriptor targetType ) { final A a = ( A ) sourceType . getAnnotation ( annotationType ) ; Locale locale = LocaleContextHolder . getLocale ( ) ; try { return formatter . print ( a , ( T ) source , locale ) ; } catch ( Exception ex ) { throw new ConversionFailedException ( sourceType , targetType , source , ex ) ; } } public String toString ( ) { return "@" + annotationType . getName ( ) + " " + clazz . getName ( ) + " -> " + String . class . getName ( ) + ": " + formatter ; } } ) ; conversion . addConverter ( new ConditionalGenericConverter ( ) { public Set < GenericConverter . ConvertiblePair > getConvertibleTypes ( ) { Set < GenericConverter . ConvertiblePair > types = new HashSet < > ( ) ; types . add ( new GenericConverter . ConvertiblePair ( String . class , clazz ) ) ; return types ; } public boolean matches ( TypeDescriptor sourceType , TypeDescriptor targetType ) { return ( targetType . getAnnotation ( annotationType ) != null ) ; } public Object convert ( Object source , TypeDescriptor sourceType , TypeDescriptor targetType ) { final A a = ( A ) targetType . getAnnotation ( annotationType ) ; Locale locale = LocaleContextHolder . getLocale ( ) ; try { return formatter . parse ( a , ( String ) source , locale ) ; } catch ( Exception ex ) { throw new ConversionFailedException ( sourceType , targetType , source , ex ) ; } } public String toString ( ) { return String . class . getName ( ) + " -> @" + annotationType . getName ( ) + " " + clazz . getName ( ) + ": " + formatter ; } } ) ; return this ;


signature:
public class ServerCookieEncoder { /** * Encodes the specified cookie into a Set - Cookie header value .
 * @ param cookie the cookie
 * @ return a single Set - Cookie header value */
public String encode ( Cookie cookie ) { } }

implementation:
if ( cookie == null ) { throw new NullPointerException ( "cookie" ) ; } final String name = cookie . name ( ) ; final String value = cookie . value ( ) != null ? cookie . value ( ) : "" ; validateCookie ( name , value ) ; StringBuilder buf = new StringBuilder ( ) ; if ( cookie . wrap ( ) ) { addQuoted ( buf , name , value ) ; } else { add ( buf , name , value ) ; } if ( cookie . maxAge ( ) != Integer . MIN_VALUE ) { add ( buf , CookieHeaderNames . MAX_AGE , cookie . maxAge ( ) ) ; Date expires = cookie . maxAge ( ) <= 0 ? new Date ( 0 ) // Set expires to the Unix epoch
: new Date ( cookie . maxAge ( ) * 1000L + System . currentTimeMillis ( ) ) ; add ( buf , CookieHeaderNames . EXPIRES , HttpHeaderDateFormat . get ( ) . format ( expires ) ) ; } if ( cookie . sameSite ( ) != null ) { add ( buf , CookieHeaderNames . SAMESITE , cookie . sameSite ( ) ) ; } if ( cookie . path ( ) != null ) { add ( buf , CookieHeaderNames . PATH , cookie . path ( ) ) ; } if ( cookie . domain ( ) != null ) { add ( buf , CookieHeaderNames . DOMAIN , cookie . domain ( ) ) ; } if ( cookie . isSecure ( ) ) { add ( buf , CookieHeaderNames . SECURE ) ; } if ( cookie . isHttpOnly ( ) ) { add ( buf , CookieHeaderNames . HTTPONLY ) ; } return stripTrailingSeparator ( buf ) ;


signature:
public class ServerCookieEncoder { /** * Batch encodes cookies into Set - Cookie header values .
 * @ param cookies a bunch of cookies
 * @ return the corresponding bunch of Set - Cookie headers */
public List < String > encode ( Cookie ... cookies ) { } }

implementation: if ( cookies == null ) { throw new NullPointerException ( "cookies" ) ; } if ( cookies . length == 0 ) { return Collections . emptyList ( ) ; } List < String > encoded = new ArrayList < String > ( cookies . length ) ; for ( Cookie c : cookies ) { if ( c == null ) { break ; } encoded . add ( encode ( c ) ) ; } return encoded ;


signature:
public class ServerCookieEncoder { /** * Batch encodes cookies into Set - Cookie header values .
 * @ param cookies a bunch of cookies
 * @ return the corresponding bunch of Set - Cookie headers */
public List < String > encode ( Collection < ? extends Cookie > cookies ) { } }

implementation: if ( cookies == null ) { throw new NullPointerException ( "cookies" ) ; } if ( cookies . isEmpty ( ) ) { return Collections . emptyList ( ) ; } List < String > encoded = new ArrayList < String > ( cookies . size ( ) ) ; for ( Cookie c : cookies ) { if ( c == null ) { break ; } encoded . add ( encode ( c ) ) ; } return encoded ;


signature:
public class ServerCookieEncoder { /** * Batch encodes cookies into Set - Cookie header values .
 * @ param cookies a bunch of cookies
 * @ return the corresponding bunch of Set - Cookie headers */
public List < String > encode ( Iterable < ? extends Cookie > cookies ) { } }

implementation: if ( cookies == null ) { throw new NullPointerException ( "cookies" ) ; } if ( cookies . iterator ( ) . hasNext ( ) ) { return Collections . emptyList ( ) ; } List < String > encoded = new ArrayList < String > ( ) ; for ( Cookie c : cookies ) { if ( c == null ) { break ; } encoded . add ( encode ( c ) ) ; } return encoded ;


signature:
public class ServerCookieDecoder { /** * Decodes the specified Set - Cookie HTTP header value into a { @ link Cookie } .
 * @ param header the Set - Cookie header .
 * @ return the decoded { @ link Cookie } */
public Set < Cookie > decode ( String header ) { } }

implementation:
if ( header == null ) { throw new NullPointerException ( "header" ) ; } final int headerLen = header . length ( ) ; if ( headerLen == 0 ) { return Collections . emptySet ( ) ; } Set < Cookie > cookies = new TreeSet < Cookie > ( ) ; int i = 0 ; boolean rfc2965Style = false ; if ( header . regionMatches ( true , 0 , RFC2965_VERSION , 0 , RFC2965_VERSION . length ( ) ) ) { // RFC 2965 style cookie , move to after version value
i = header . indexOf ( ';' ) + 1 ; rfc2965Style = true ; } loop : for ( ; ; ) { // Skip spaces and separators .
for ( ; ; ) { if ( i == headerLen ) { break loop ; } char c = header . charAt ( i ) ; if ( c == '\t' || c == '\n' || c == 0x0b || c == '\f' || c == '\r' || c == ' ' || c == ',' || c == ';' ) { i ++ ; continue ; } break ; } int nameBegin = i ; int nameEnd = i ; int valueBegin = - 1 ; int valueEnd = - 1 ; if ( i != headerLen ) { keyValLoop : for ( ; ; ) { char curChar = header . charAt ( i ) ; if ( curChar == ';' ) { // NAME ; ( no value till ' ; ' )
nameEnd = i ; valueBegin = valueEnd = - 1 ; break keyValLoop ; } else if ( curChar == '=' ) { // NAME = VALUE
nameEnd = i ; i ++ ; if ( i == headerLen ) { // NAME = ( empty value , i . e . nothing after ' = ' )
valueBegin = valueEnd = 0 ; break keyValLoop ; } valueBegin = i ; // NAME = VALUE ;
int semiPos = header . indexOf ( ';' , i ) ; valueEnd = i = semiPos > 0 ? semiPos : headerLen ; break keyValLoop ; } else { i ++ ; } if ( i == headerLen ) { // NAME ( no value till the end of string )
nameEnd = headerLen ; valueBegin = valueEnd = - 1 ; break ; } } } if ( rfc2965Style && ( header . regionMatches ( nameBegin , RFC2965_PATH , 0 , RFC2965_PATH . length ( ) ) || header . regionMatches ( nameBegin , RFC2965_DOMAIN , 0 , RFC2965_DOMAIN . length ( ) ) || header . regionMatches ( nameBegin , RFC2965_PORT , 0 , RFC2965_PORT . length ( ) ) ) ) { // skip obsolete RFC2965 fields
continue ; } DefaultCookie cookie = initCookie ( header , nameBegin , nameEnd , valueBegin , valueEnd ) ; if ( cookie != null ) { cookies . add ( cookie ) ; } } return cookies ;


signature:
public class RangeResults { /** * Returns the stream as a result considering " Range " header . If the header is present and it is
 * satisfiable , then a Result containing just the requested part will be returned . If the header
 * is not present or is unsatisfiable , then a regular Result will be returned .
 * @ param request the request from which to retrieve the range header .
 * @ param stream the content stream
 * @ return range result if " Range " header is present and regular result if not */
public static Result ofStream ( Http . Request request , InputStream stream ) { } }

implementation: return JavaRangeResult . ofStream ( stream , rangeHeader ( request ) , null , Optional . empty ( ) ) ;


signature:
public class RangeResults { /** * Returns the stream as a result considering " Range " header . If the header is present and it is
 * satisfiable , then a Result containing just the requested part will be returned . If the header
 * is not present or is unsatisfiable , then a regular Result will be returned .
 * @ param stream the content stream
 * @ param contentLength the entity length
 * @ return range result if " Range " header is present and regular result if not
 * @ deprecated Deprecated as of 2.7.0 . Use { @ link # ofStream ( Http . Request , InputStream , long ) }
 * instead . */
@ Deprecated public static Result ofStream ( InputStream stream , long contentLength ) { } }

implementation: return ofStream ( Http . Context . current ( ) . request ( ) , stream , contentLength ) ;


signature:
public class RangeResults { /** * Returns the path as a result considering " Range " header . If the header is present and it is
 * satisfiable , then a Result containing just the requested part will be returned . If the header
 * is not present or is unsatisfiable , then a regular Result will be returned .
 * @ param request the request from which to retrieve the range header .
 * @ param path the content path
 * @ return range result if " Range " header is present and regular result if not */
public static Result ofPath ( Http . Request request , Path path ) { } }

implementation: return ofPath ( request , path , StaticFileMimeTypes . fileMimeTypes ( ) ) ;


signature:
public class RangeResults { /** * Returns the path as a result considering " Range " header . If the header is present and it is
 * satisfiable , then a Result containing just the requested part will be returned . If the header
 * is not present or is unsatisfiable , then a regular Result will be returned .
 * @ param request the request from which to retrieve the range header .
 * @ param path the content path
 * @ param fileMimeTypes Used for file type mapping .
 * @ return range result if " Range " header is present and regular result if not */
public static Result ofPath ( Http . Request request , Path path , FileMimeTypes fileMimeTypes ) { } }

implementation: return JavaRangeResult . ofPath ( path , rangeHeader ( request ) , fileMimeTypes . forFileName ( path . toFile ( ) . getName ( ) ) ) ;


signature:
public class RangeResults { /** * Returns the path as a result considering " Range " header . If the header is present and it is
 * satisfiable , then a Result containing just the requested part will be returned . If the header
 * is not present or is unsatisfiable , then a regular Result will be returned .
 * @ param path the content path
 * @ param fileName filename used at the Content - Disposition header .
 * @ return range result if " Range " header is present and regular result if not
 * @ deprecated Deprecated as of 2.7.0 . Use { link { @ link # ofPath ( Http . Request , Path , String ) }
 * instead . */
@ Deprecated public static Result ofPath ( Path path , String fileName ) { } }

implementation: return ofPath ( Http . Context . current ( ) . request ( ) , path , fileName ) ;


signature:
public class RangeResults { /** * Returns the path as a result considering " Range " header . If the header is present and it is
 * satisfiable , then a Result containing just the requested part will be returned . If the header
 * is not present or is unsatisfiable , then a regular Result will be returned .
 * @ param request the request from which to retrieve the range header .
 * @ param path the content path
 * @ param fileName filename used at the Content - Disposition header .
 * @ param fileMimeTypes Used for file type mapping .
 * @ return range result if " Range " header is present and regular result if not */
public static Result ofPath ( Http . Request request , Path path , String fileName , FileMimeTypes fileMimeTypes ) { } }

implementation: return JavaRangeResult . ofPath ( path , rangeHeader ( request ) , fileName , fileMimeTypes . forFileName ( fileName ) ) ;


signature:
public class RangeResults { /** * Returns the file as a result considering " Range " header . If the header is present and it is
 * satisfiable , then a Result containing just the requested part will be returned . If the header
 * is not present or is unsatisfiable , then a regular Result will be returned .
 * @ param file the content file
 * @ param fileName filename used at the Content - Disposition header
 * @ return range result if " Range " header is present and regular result if not
 * @ deprecated Deprecated as of 2.7.0 . Use { @ link # ofFile ( Http . Request , File , String ) } instead . */
@ Deprecated public static Result ofFile ( File file , String fileName ) { } }

implementation: return ofFile ( Http . Context . current ( ) . request ( ) , file , fileName ) ;


signature:
public class RangeResults { /** * Returns the file as a result considering " Range " header . If the header is present and it is
 * satisfiable , then a Result containing just the requested part will be returned . If the header
 * is not present or is unsatisfiable , then a regular Result will be returned .
 * @ param request the request from which to retrieve the range header .
 * @ param file the content file
 * @ param fileName filename used at the Content - Disposition header
 * @ return range result if " Range " header is present and regular result if not */
public static Result ofFile ( Http . Request request , File file , String fileName ) { } }

implementation: return ofFile ( request , file , fileName , StaticFileMimeTypes . fileMimeTypes ( ) ) ;


signature:
public class RangeResults { /** * Returns the file as a result considering " Range " header . If the header is present and it is
 * satisfiable , then a Result containing just the requested part will be returned . If the header
 * is not present or is unsatisfiable , then a regular Result will be returned .
 * @ param request the request from which to retrieve the range header .
 * @ param file the content file
 * @ param fileName filename used at the Content - Disposition header
 * @ param fileMimeTypes Used for file type mapping .
 * @ return range result if " Range " header is present and regular result if not */
public static Result ofFile ( Http . Request request , File file , String fileName , FileMimeTypes fileMimeTypes ) { } }

implementation: return JavaRangeResult . ofFile ( file , rangeHeader ( request ) , fileName , fileMimeTypes . forFileName ( fileName ) ) ;


signature:
public class RangeResults { /** * Returns the stream as a result considering " Range " header . If the header is present and it is
 * satisfiable , then a Result containing just the requested part will be returned . If the header
 * is not present or is unsatisfiable , then a regular Result will be returned .
 * @ param entityLength the entityLength
 * @ param source source of the entity
 * @ param fileName filename used at the Content - Disposition header
 * @ param contentType the content type for this stream
 * @ return range result if " Range " header is present and regular result if not
 * @ deprecated Deprecated as of 2.7.0 . Use { @ link # ofSource ( Http . Request , Long , Source , String ,
 * String ) } instead . */
@ Deprecated public static Result ofSource ( Long entityLength , Source < ByteString , ? > source , String fileName , String contentType ) { } }

implementation: return ofSource ( Http . Context . current ( ) . request ( ) , entityLength , source , fileName , contentType ) ;


signature:
public class RangeResults { /** * Returns the stream as a result considering " Range " header . If the header is present and it is
 * satisfiable , then a Result containing just the requested part will be returned . If the header
 * is not present or is unsatisfiable , then a regular Result will be returned .
 * @ param request the request from which to retrieve the range header .
 * @ param entityLength the entityLength
 * @ param source source of the entity
 * @ param fileName filename used at the Content - Disposition header
 * @ param contentType the content type for this stream
 * @ return range result if " Range " header is present and regular result if not */
public static Result ofSource ( Http . Request request , Long entityLength , Source < ByteString , ? > source , String fileName , String contentType ) { } }

implementation: return JavaRangeResult . ofSource ( entityLength , source , rangeHeader ( request ) , Optional . ofNullable ( fileName ) , Optional . ofNullable ( contentType ) ) ;


signature:
public class XPath { /** * Select all nodes that are selected by this XPath expression . If multiple nodes match , multiple
 * nodes will be returned . Nodes will be returned in document - order ,
 * @ param path the xpath expression
 * @ param node the starting node
 * @ return result of evaluating the xpath expression against node */
public static NodeList selectNodes ( String path , Object node ) { } }

implementation: return selectNodes ( path , node , null ) ;


signature:
public class CrossScala { /** * Converts a Java List to Scala Seq .
 * @ param list the java list .
 * @ return the converted Seq .
 * @ param < T > the element type . */
public static < T > scala . collection . immutable . Seq < T > toSeq ( java . util . List < T > list ) { } }

implementation: return scala . collection . JavaConverters . asScalaBufferConverter ( list ) . asScala ( ) . toList ( ) ;


signature:
public class CrossScala { /** * Converts a Java Array to Scala Seq .
 * @ param array the java array .
 * @ return the converted Seq .
 * @ param < T > the element type . */
public static < T > scala . collection . immutable . Seq < T > toSeq ( T [ ] array ) { } }

implementation: return toSeq ( java . util . Arrays . asList ( array ) ) ;


signature:
public class CrossScala { /** * Converts a Java varargs to Scala varargs .
 * @ param array the java array .
 * @ return the Scala varargs
 * @ param < T > the element type . */
@ SafeVarargs public static < T > scala . collection . immutable . Seq < T > varargs ( T ... array ) { } }

implementation: return toSeq ( array ) ;


signature:
public class WebSocket { /** * Acceptor for JSON WebSockets .
 * @ param in The class of the incoming messages , used to decode them from the JSON .
 * @ param < In > The websocket ' s input type ( what it receives from clients )
 * @ param < Out > The websocket ' s output type ( what it writes to clients )
 * @ return The WebSocket acceptor . */
public static < In , Out > MappedWebSocketAcceptor < In , Out > json ( Class < In > in ) { } }

implementation: return new MappedWebSocketAcceptor < > ( Scala . partialFunction ( message -> { try { if ( message instanceof Message . Binary ) { return F . Either . Left ( play . libs . Json . mapper ( ) . readValue ( ( ( Message . Binary ) message ) . data ( ) . iterator ( ) . asInputStream ( ) , in ) ) ; } else if ( message instanceof Message . Text ) { return F . Either . Left ( play . libs . Json . mapper ( ) . readValue ( ( ( Message . Text ) message ) . data ( ) , in ) ) ; } } catch ( Exception e ) { return F . Either . Right ( new Message . Close ( CloseCodes . Unacceptable ( ) , e . getMessage ( ) ) ) ; } throw Scala . noMatch ( ) ; } ) , outMessage -> { try { return new Message . Text ( play . libs . Json . mapper ( ) . writeValueAsString ( outMessage ) ) ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } } ) ;


signature:
public class WebSocket { /** * Helper to create handlers for WebSockets .
 * @ param inMapper Function to map input messages . If it produces left , the message will be passed
 * to the WebSocket flow , if it produces right , the message will be sent back out to the
 * client - this can be used to send errors directly to the client .
 * @ param f The function to handle the WebSocket .
 * @ param outMapper Function to map output messages .
 * @ return The WebSocket handler . */
private static < In , Out > WebSocket acceptOrResult ( PartialFunction < Message , F . Either < In , Message > > inMapper , Function < Http . RequestHeader , CompletionStage < F . Either < Result , Flow < In , Out , ? > > > > f , Function < Out , Message > outMapper ) { } }

implementation: return new WebSocket ( ) { @ Override public CompletionStage < F . Either < Result , Flow < Message , Message , ? > > > apply ( Http . RequestHeader request ) { return f . apply ( request ) . thenApply ( resultOrFlow -> { if ( resultOrFlow . left . isPresent ( ) ) { return F . Either . Left ( resultOrFlow . left . get ( ) ) ; } else { Flow < Message , Message , ? > flow = AkkaStreams . bypassWith ( Flow . < Message > create ( ) . collect ( inMapper ) , play . api . libs . streams . AkkaStreams . onlyFirstCanFinishMerge ( 2 ) , resultOrFlow . right . get ( ) . map ( outMapper :: apply ) ) ; return F . Either . Right ( flow ) ; } } ) ; } } ;


signature:
public class MemberUtils { /** * Returns whether a { @ link Member } is accessible .
 * @ param m Member to check
 * @ return { @ code true } if < code > m < / code > is accessible */
static boolean isAccessible ( final Member m ) { } }

implementation: return m != null && Modifier . isPublic ( m . getModifiers ( ) ) && ! m . isSynthetic ( ) ;


signature:
public class MemberUtils { /** * XXX Default access superclass workaround .
 * < p > When a { @ code public } class has a default access superclass with { @ code public } members ,
 * these members are accessible . Calling them from compiled code works fine . Unfortunately , on
 * some JVMs , using reflection to invoke these members seems to ( wrongly ) prevent access even when
 * the modifier is { @ code public } . Calling { @ code setAccessible ( true ) } solves the problem but will
 * only work from sufficiently privileged code . Better workarounds would be gratefully accepted .
 * @ param o the AccessibleObject to set as accessible
 * @ return a boolean indicating whether the accessibility of the object was set to true . */
static boolean setAccessibleWorkaround ( final AccessibleObject o ) { } }

implementation:
if ( o == null || o . isAccessible ( ) ) { return false ; } final Member m = ( Member ) o ; if ( ! o . isAccessible ( ) && Modifier . isPublic ( m . getModifiers ( ) ) && isPackageAccess ( m . getDeclaringClass ( ) . getModifiers ( ) ) ) { try { o . setAccessible ( true ) ; return true ; } catch ( final SecurityException e ) { // NOPMD
// ignore in favor of subsequent IllegalAccessException
} } return false ;


signature:
public class MemberUtils { /** * Compares the relative fitness of two Constructors in terms of how well they match a set of
 * runtime parameter types , such that a list ordered by the results of the comparison would return
 * the best match first ( least ) .
 * @ param left the " left " Constructor
 * @ param right the " right " Constructor
 * @ param actual the runtime parameter types to match against { @ code left } / { @ code right }
 * @ return int consistent with { @ code compare } semantics
 * @ since 3.5 */
static int compareConstructorFit ( final Constructor < ? > left , final Constructor < ? > right , final Class < ? > [ ] actual ) { } }

implementation: return compareParameterTypes ( Executable . of ( left ) , Executable . of ( right ) , actual ) ;


signature:
public class MemberUtils { /** * Compares the relative fitness of two Methods in terms of how well they match a set of runtime
 * parameter types , such that a list ordered by the results of the comparison would return the
 * best match first ( least ) .
 * @ param left the " left " Method
 * @ param right the " right " Method
 * @ param actual the runtime parameter types to match against { @ code left } / { @ code right }
 * @ return int consistent with { @ code compare } semantics
 * @ since 3.5 */
static int compareMethodFit ( final Method left , final Method right , final Class < ? > [ ] actual ) { } }


signature:
public class MemberUtils { /** * Compares the relative fitness of two Executables in terms of how well they match a set of
 * runtime parameter types , such that a list ordered by the results of the comparison would return
 * the best match first ( least ) .
 * @ param left the " left " Executable
 * @ param right the " right " Executable
 * @ param actual the runtime parameter types to match against { @ code left } / { @ code right }
 * @ return int consistent with { @ code compare } semantics */
private static int compareParameterTypes ( final Executable left , final Executable right , final Class < ? > [ ] actual ) { } }

implementation: final float leftCost = getTotalTransformationCost ( actual , left ) ; final float rightCost = getTotalTransformationCost ( actual , right ) ; return leftCost < rightCost ? - 1 : rightCost < leftCost ? 1 : 0 ;


signature:
public class MemberUtils { /** * Gets the number of steps required to promote a primitive number to another type .
 * @ param srcClass the ( primitive ) source class
 * @ param destClass the ( primitive ) destination class
 * @ return The cost of promoting the primitive */
private static float getPrimitivePromotionCost ( final Class < ? > srcClass , final Class < ? > destClass ) { } }

implementation:
float cost = 0.0f ; Class < ? > cls = srcClass ; if ( ! cls . isPrimitive ( ) ) { // slight unwrapping penalty
cost += 0.1f ; cls = ClassUtils . wrapperToPrimitive ( cls ) ; } for ( int i = 0 ; cls != destClass && i < ORDERED_PRIMITIVE_TYPES . length ; i ++ ) { if ( cls == ORDERED_PRIMITIVE_TYPES [ i ] ) { cost += 0.1f ; if ( i < ORDERED_PRIMITIVE_TYPES . length - 1 ) { cls = ORDERED_PRIMITIVE_TYPES [ i + 1 ] ; } } } return cost ;


signature:
public class MemberUtils { /** * Returns the sum of the object transformation cost for each class in the source argument list .
 * @ param srcArgs The source arguments
 * @ param executable The executable to calculate transformation costs for
 * @ return The total transformation cost */
private static float getTotalTransformationCost ( final Class < ? > [ ] srcArgs , final Executable executable ) { } }

implementation:
final Class < ? > [ ] destArgs = executable . getParameterTypes ( ) ; final boolean isVarArgs = executable . isVarArgs ( ) ; // " source " and " destination " are the actual and declared args respectively .
float totalCost = 0.0f ; final long normalArgsLen = isVarArgs ? destArgs . length - 1 : destArgs . length ; if ( srcArgs . length < normalArgsLen ) { return Float . MAX_VALUE ; } for ( int i = 0 ; i < normalArgsLen ; i ++ ) { totalCost += getObjectTransformationCost ( srcArgs [ i ] , destArgs [ i ] ) ; } if ( isVarArgs ) { // When isVarArgs is true , srcArgs and dstArgs may differ in length .
// There are two special cases to consider :
final boolean noVarArgsPassed = srcArgs . length < destArgs . length ; final boolean explicitArrayForVarags = srcArgs . length == destArgs . length && srcArgs [ srcArgs . length - 1 ] . isArray ( ) ; final float varArgsCost = 0.001f ; final Class < ? > destClass = destArgs [ destArgs . length - 1 ] . getComponentType ( ) ; if ( noVarArgsPassed ) { // When no varargs passed , the best match is the most generic matching type , not the most
// specific .
totalCost += getObjectTransformationCost ( destClass , Object . class ) + varArgsCost ; } else if ( explicitArrayForVarags ) { final Class < ? > sourceClass = srcArgs [ srcArgs . length - 1 ] . getComponentType ( ) ; totalCost += getObjectTransformationCost ( sourceClass , destClass ) + varArgsCost ; } else { // This is typical varargs case .
for ( int i = destArgs . length - 1 ; i < srcArgs . length ; i ++ ) { final Class < ? > srcClass = srcArgs [ i ] ; totalCost += getObjectTransformationCost ( srcClass , destClass ) + varArgsCost ; } } } return totalCost ;


signature:
public class MemberUtils { /** * Gets the number of steps required needed to turn the source class into the destination class .
 * This represents the number of steps in the object hierarchy graph .
 * @ param srcClass The source class
 * @ param destClass The destination class
 * @ return The cost of transforming an object */
private static float getObjectTransformationCost ( Class < ? > srcClass , final Class < ? > destClass ) { } }

implementation:
if ( destClass . isPrimitive ( ) ) { return getPrimitivePromotionCost ( srcClass , destClass ) ; } float cost = 0.0f ; while ( srcClass != null && ! destClass . equals ( srcClass ) ) { if ( destClass . isInterface ( ) && ClassUtils . isAssignable ( srcClass , destClass ) ) { // slight penalty for interface match .
// we still want an exact match to override an interface match ,
// but
// an interface match should override anything where we have to
// get a superclass .
cost += 0.25f ; break ; } cost ++ ; srcClass = srcClass . getSuperclass ( ) ; } /* * If the destination class is null , we ' ve traveled all the way up to
 * an Object match . We ' ll penalize this by adding 1.5 to the cost . */
if ( srcClass == null ) { cost += 1.5f ; } return cost ;


signature:
public class JavaI18N { /** * # explicit - messages - api */
private MessagesApi explicitMessagesApi ( ) { } }

implementation: return new play . i18n . MessagesApi ( new play . api . i18n . DefaultMessagesApi ( Collections . singletonMap ( Lang . defaultLang ( ) . code ( ) , Collections . singletonMap ( "foo" , "bar" ) ) , new play . api . i18n . DefaultLangs ( ) . asJava ( ) ) ) ;


signature:
public class MessagesImpl { /** * Get the message at the given key .
 * < p > Uses ` java . text . MessageFormat ` internally to format the message .
 * @ param key the message key
 * @ param args the message arguments
 * @ return the formatted message or a default rendering if the key wasn ' t defined */
public String at ( String key , Object ... args ) { } }

implementation: return messagesApi . get ( lang , key , args ) ;


signature:
public class MessagesImpl { /** * Get the message at the first defined key .
 * < p > Uses ` java . text . MessageFormat ` internally to format the message .
 * @ param keys the messages keys
 * @ param args the message arguments
 * @ return the formatted message or a default rendering if the key wasn ' t defined */
public String at ( List < String > keys , Object ... args ) { } }

implementation: return messagesApi . get ( lang , keys , args ) ;


signature:
public class Databases { /** * Create a pooled database with the given configuration .
 * @ param name the database name
 * @ param driver the database driver class
 * @ param url the database url
 * @ param config a map of extra database configuration
 * @ return a configured database */
public static Database createFrom ( String name , String driver , String url , Map < String , ? extends Object > config ) { } }

implementation: ImmutableMap . Builder < String , Object > dbConfig = new ImmutableMap . Builder < String , Object > ( ) ; dbConfig . put ( "driver" , driver ) ; dbConfig . put ( "url" , url ) ; dbConfig . putAll ( config ) ; return new DefaultDatabase ( name , dbConfig . build ( ) ) ;


signature:
public class Databases { /** * Create a pooled database with the given configuration .
 * @ param name the database name
 * @ param driver the database driver class
 * @ param url the database url
 * @ return a configured database */
public static Database createFrom ( String name , String driver , String url ) { } }

implementation: return createFrom ( name , driver , url , ImmutableMap . < String , Object > of ( ) ) ;


signature:
public class Databases { /** * Create a pooled database named " default " with the given configuration .
 * @ param driver the database driver class
 * @ param url the database url
 * @ param config a map of extra database configuration
 * @ return a configured database */
public static Database createFrom ( String driver , String url , Map < String , ? extends Object > config ) { } }

implementation: return createFrom ( "default" , driver , url , config ) ;


signature:
public class Databases { /** * Create an in - memory H2 database .
 * @ param name the database name
 * @ param url the database url
 * @ param config a map of extra database configuration
 * @ return a configured in - memory h2 database */
public static Database inMemory ( String name , String url , Map < String , ? extends Object > config ) { } }

implementation: return createFrom ( name , "org.h2.Driver" , url , config ) ;


signature:
public class Databases { /** * Create an in - memory H2 database .
 * @ param name the database name
 * @ param urlOptions a map of extra url options
 * @ param config a map of extra database configuration
 * @ return a configured in - memory h2 database */
public static Database inMemory ( String name , Map < String , String > urlOptions , Map < String , ? extends Object > config ) { } }

implementation: StringBuilder urlExtra = new StringBuilder ( ) ; for ( Map . Entry < String , String > option : urlOptions . entrySet ( ) ) { urlExtra . append ( ';' ) . append ( option . getKey ( ) ) . append ( '=' ) . append ( option . getValue ( ) ) ; } String url = "jdbc:h2:mem:" + name + urlExtra ; return inMemory ( name , url , config ) ;


signature:
public class Databases { /** * Create an in - memory H2 database .
 * @ param name the database name
 * @ param config a map of extra database configuration
 * @ return a configured in - memory h2 database */
public static Database inMemory ( String name , Map < String , ? extends Object > config ) { } }

implementation: return inMemory ( name , "jdbc:h2:mem:" + name , config ) ;


signature:
public class Databases { /** * Create an in - memory H2 database .
 * @ param name the database name
 * @ return a configured in - memory h2 database */
public static Database inMemory ( String name ) { } }

implementation: return inMemory ( name , ImmutableMap . < String , Object > of ( ) ) ;


signature:
public class Databases { /** * Create an in - memory H2 database with name " default " and with extra configuration provided by
 * the given entries .
 * @ param k1 an H2 configuration key .
 * @ param v1 configuration value corresponding to ` k1 `
 * @ return a configured in - memory H2 database */
public static Database inMemoryWith ( String k1 , Object v1 ) { } }

implementation: return inMemory ( ImmutableMap . of ( k1 , v1 ) ) ;


signature:
public class Databases { /** * Create an in - memory H2 database with name " default " and with extra configuration provided by
 * the given entries .
 * @ param k1 an H2 configuration key
 * @ param v1 H2 configuration value corresponding to ` k1 `
 * @ param k2 a second H2 configuration key
 * @ param v2 a configuration value corresponding to ` k2 `
 * @ param k3 a third H2 configuration key
 * @ param v3 a configuration value corresponding to ` k3 `
 * @ return a configured in - memory H2 database */
public static Database inMemoryWith ( String k1 , Object v1 , String k2 , Object v2 , String k3 , Object v3 ) { } }

implementation: return inMemory ( ImmutableMap . of ( k1 , v1 , k2 , v2 , k3 , v3 ) ) ;


signature:
public class BeanMap { /** * Helper method to create a new < code > BeanMap < / code > . For finer
 * control over the generated instance , use a new instance of
 * < code > BeanMap . Generator < / code > instead of this static method .
 * @ param bean the JavaBean underlying the map
 * @ return a new < code > BeanMap < / code > instance */
public static BeanMap create ( Object bean ) { } }

implementation: Generator gen = new Generator ( ) ; gen . setBean ( bean ) ; return gen . create ( ) ;


signature:
public class BeanMap { /** * TODO : optimize */
public Set entrySet ( ) { } }

implementation: HashMap copy = new HashMap ( ) ; for ( Iterator it = keySet ( ) . iterator ( ) ; it . hasNext ( ) ; ) { Object key = it . next ( ) ; copy . put ( key , get ( key ) ) ; } return Collections . unmodifiableMap ( copy ) . entrySet ( ) ;


signature:
public class ParallelSorter { /** * Create a new ParallelSorter object for a set of arrays . You may
 * sort the arrays multiple times via the same ParallelSorter object .
 * @ param arrays An array of arrays to sort . The arrays may be a mix
 * of primitive and non - primitive types , but should all be the same
 * length .
 * @ param loader ClassLoader for generated class , uses " current " if null */
public static ParallelSorter create ( Object [ ] arrays ) { } }

implementation: Generator gen = new Generator ( ) ; gen . setArrays ( arrays ) ; return gen . create ( ) ;


signature:
public class ParallelSorter { /** * Sort the arrays using the quicksort algorithm .
 * @ param index array ( column ) to sort by
 * @ param lo starting array index ( row ) , inclusive
 * @ param hi ending array index ( row ) , exclusive
 * @ param cmp Comparator to use if the specified column is non - primitive */
public void quickSort ( int index , int lo , int hi , Comparator cmp ) { } }

implementation: chooseComparer ( index , cmp ) ; super . quickSort ( lo , hi - 1 ) ;


signature:
public class ParallelSorter { /** * Sort the arrays using an in - place merge sort .
 * @ param index array ( column ) to sort by
 * @ param lo starting array index ( row ) , inclusive
 * @ param hi ending array index ( row ) , exclusive
 * @ param cmp Comparator to use if the specified column is non - primitive */
public void mergeSort ( int index , int lo , int hi , Comparator cmp ) { } }

implementation: chooseComparer ( index , cmp ) ; super . mergeSort ( lo , hi - 1 ) ;


signature:
public class FastClassEmitter { /** * TODO : support constructor indices ( " < init > " ) */
private void emitIndexBySignature ( List methods ) { } }

implementation: CodeEmitter e = begin_method ( Constants . ACC_PUBLIC , SIGNATURE_GET_INDEX , null ) ; List signatures = CollectionUtils . transform ( methods , new Transformer ( ) { public Object transform ( Object obj ) { return ReflectUtils . getSignature ( ( Method ) obj ) . toString ( ) ; } } ) ; e . load_arg ( 0 ) ; e . invoke_virtual ( Constants . TYPE_OBJECT , TO_STRING ) ; signatureSwitchHelper ( e , signatures ) ; e . end_method ( ) ;


signature:
public class FastClassEmitter { /** * TODO */
private void emitIndexByClassArray ( List methods ) { } }

implementation:
CodeEmitter e = begin_method ( Constants . ACC_PUBLIC , METHOD_GET_INDEX , null ) ; if ( methods . size ( ) > TOO_MANY_METHODS ) { // hack for big classes
List signatures = CollectionUtils . transform ( methods , new Transformer ( ) { public Object transform ( Object obj ) { String s = ReflectUtils . getSignature ( ( Method ) obj ) . toString ( ) ; return s . substring ( 0 , s . lastIndexOf ( ')' ) + 1 ) ; } } ) ; e . load_args ( ) ; e . invoke_static ( FAST_CLASS , GET_SIGNATURE_WITHOUT_RETURN_TYPE ) ; signatureSwitchHelper ( e , signatures ) ; } else { e . load_args ( ) ; List info = CollectionUtils . transform ( methods , MethodInfoTransformer . getInstance ( ) ) ; EmitUtils . method_switch ( e , info , new GetIndexCallback ( e , info ) ) ; } e . end_method ( ) ;


signature:
public class Mixin { /** * Helper method to create an interface mixin . For finer control over the
 * generated instance , use a new instance of < code > Mixin < / code >
 * instead of this static method .
 * TODO */
public static Mixin create ( Object [ ] delegates ) { } }

implementation: Generator gen = new Generator ( ) ; gen . setDelegates ( delegates ) ; return gen . create ( ) ;


signature:
public class Mixin { /** * Helper method to create an interface mixin . For finer control over the
 * generated instance , use a new instance of < code > Mixin < / code >
 * instead of this static method .
 * TODO */
public static Mixin create ( Class [ ] interfaces , Object [ ] delegates ) { } }

implementation: Generator gen = new Generator ( ) ; gen . setClasses ( interfaces ) ; gen . setDelegates ( delegates ) ; return gen . create ( ) ;


signature:
public class Mixin { /** * Helper method to create a bean mixin . For finer control over the
 * generated instance , use a new instance of < code > Mixin < / code >
 * instead of this static method .
 * TODO */
public static Mixin createBean ( ClassLoader loader , Object [ ] beans ) { } }

implementation: Generator gen = new Generator ( ) ; gen . setStyle ( STYLE_BEANS ) ; gen . setDelegates ( beans ) ; gen . setClassLoader ( loader ) ; return gen . create ( ) ;


signature: public class Mixin { private static Route route ( Object [ ] delegates ) { } }

implementation: Object key = ClassesKey . create ( delegates ) ; Route route = ( Route ) ROUTE_CACHE . get ( key ) ; if ( route == null ) { ROUTE_CACHE . put ( key , route = new Route ( delegates ) ) ; } return route ;


signature:
public class MethodProxy { /** * For internal use by { @ link Enhancer } only ; see the { @ link net . sf . cglib . reflect . FastMethod } class
 * for similar functionality . */
public static MethodProxy create ( Class c1 , Class c2 , String desc , String name1 , String name2 ) { } }

implementation: MethodProxy proxy = new MethodProxy ( ) ; proxy . sig1 = new Signature ( name1 , desc ) ; proxy . sig2 = new Signature ( name2 , desc ) ; proxy . createInfo = new CreateInfo ( c1 , c2 ) ; return proxy ;