Class JsDefinitionProxy
JsDefinition that extend JsInvokers or
JsSnippets, which turn a call of a declared method into a
JsCall and give it to whoever runs it.
The interface is checked here rather than when a method is called, so one that can not work says so when the implementation is handed out.
For internal use only. Call Element.executeJs(Class), which runs the
call on the element the implementation was obtained from, or
JsSnippets.of(Class) for an interface that declares snippets.
- Since:
- 25.4
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumWhat a JavaScript definition declares. -
Method Summary
Modifier and TypeMethodDescriptionstatic JsDefinitionProxy.KindcheckDefinition(Class<?> definitionType) Checks that the given type is a JavaScript definition that can work, and tells what it declares.static <T extends JsInvokers>
Tcreate(Class<T> definitionType, SerializableFunction<JsCall, PendingJavaScriptResult> runner) Creates an implementation of the given JavaScript definition, which hands every call of it to the given function and answers with what the function answers, for a method that declares a result.static <T extends JsSnippets>
TcreateSnippets(Class<T> definitionType) Creates an implementation of the given JavaScript definition whose methods declaresnippets, which answers every call of it with the snippet that the call declares rather than running anything.static @Nullable JsCallfindDeclaredCall(JsSnippet snippet) Gets the call that declared the given snippet, if it is an implementation of a snippet type of the application, which is sent to the client as the function the call names and the arguments of the call.static booleanisApplicationSnippetType(Class<?> type) Checks whether the given type is a snippet type that an application or a component declares, as an interface that extendsJsSnippet, and that a proxy implements when a snippet method returns it.static booleanisDefinition(Class<?> type) Checks whether the given type is a JavaScript definition, an interface annotated withJsDefinition, which the build collects the JavaScript of.
-
Method Details
-
create
public static <T extends JsInvokers> T create(Class<T> definitionType, SerializableFunction<JsCall, PendingJavaScriptResult> runner) Creates an implementation of the given JavaScript definition, which hands every call of it to the given function and answers with what the function answers, for a method that declares a result.A call of a method that the frontend build left out, because it could not find a module that the interface declaring the method imports with
JsDefinitionImport, throws anIllegalStateExceptionnaming the module instead, as the browser has no function to run.- Type Parameters:
T- the JavaScript definition type- Parameters:
definitionType- the JavaScript definition, notnullrunner- what runs a call of the interface, notnull- Returns:
- an implementation of the interface, not
null - Throws:
IllegalArgumentException- if the type is not an interface, is not annotated withJsDefinition, also extendsJsSnippets, or has a method that can not be answered
-
createSnippets
Creates an implementation of the given JavaScript definition whose methods declaresnippets, which answers every call of it with the snippet that the call declares rather than running anything.- Type Parameters:
T- the JavaScript definition type- Parameters:
definitionType- the JavaScript definition, notnull- Returns:
- an implementation of the interface, not
null - Throws:
IllegalArgumentException- if the type is not an interface, is not annotated withJsDefinition, also extendsJsInvokers, or has a method that does not declare a snippet
-
checkDefinition
Checks that the given type is a JavaScript definition that can work, and tells what it declares. The same rules apply to the build, which generates the JavaScript of a definition only when it passes, and to the implementations handed out at runtime.Not cached, so that the build, which checks every definition once, holds no reference to the classes of the project it builds.
For internal use only. May be renamed or removed in a future release.
- Parameters:
definitionType- the type to check, notnull- Returns:
- what the definition declares, not
null - Throws:
IllegalArgumentException- if the type is not an interface, is not annotated withJsDefinition, extends neither or both ofJsInvokersandJsSnippets, is annotated withJsFunctionParameterNames, has a method that does not fit what the definition declares, or has a method declared by an interface whoseimportscan not be generated
-
isDefinition
Checks whether the given type is a JavaScript definition, an interface annotated withJsDefinition, which the build collects the JavaScript of. Whether the definition can work is up tocheckDefinition(Class).For internal use only. May be renamed or removed in a future release.
- Parameters:
type- the type to check, notnull- Returns:
trueif the type is a JavaScript definition,falseotherwise
-
isApplicationSnippetType
Checks whether the given type is a snippet type that an application or a component declares, as an interface that extendsJsSnippet, and that a proxy implements when a snippet method returns it.For internal use only. May be renamed or removed in a future release.
- Parameters:
type- the type to check, notnull- Returns:
trueif the type is a snippet type of the application,falseotherwise
-
findDeclaredCall
Gets the call that declared the given snippet, if it is an implementation of a snippet type of the application, which is sent to the client as the function the call names and the arguments of the call.For internal use only. May be renamed or removed in a future release.
- Parameters:
snippet- the snippet, notnull- Returns:
- the declaring call, or
nullif the snippet is of one of the snippet types of Flow
-