Skip to content

Commit

Permalink
Fix Kotlin example for static factory method
Browse files Browse the repository at this point in the history
Closes gh-28399
  • Loading branch information
sbrannen committed May 11, 2022
1 parent be782a2 commit 48c797e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/docs/asciidoc/core/core-beans.adoc
Expand Up @@ -693,10 +693,11 @@ able to call this method (with optional arguments, as described later) and retur
object, which subsequently is treated as if it had been created through a constructor.
One use for such a bean definition is to call `static` factories in legacy code.

The following bean definition specifies that the bean be created by calling a
The following bean definition specifies that the bean will be created by calling a
factory method. The definition does not specify the type (class) of the returned object,
only the class containing the factory method. In this example, the `createInstance()`
method must be a static method. The following example shows how to specify a factory method:
but rather the class containing the factory method. In this example, the
`createInstance()` method must be a `static` method. The following example shows how to
specify a factory method:

[source,xml,indent=0,subs="verbatim,quotes"]
----
Expand Down Expand Up @@ -725,6 +726,7 @@ The following example shows a class that would work with the preceding bean defi
class ClientService private constructor() {
companion object {
private val clientService = ClientService()
@JvmStatic
fun createInstance() = clientService
}
}
Expand Down

0 comments on commit 48c797e

Please sign in to comment.