Skip to content

Commit a31a138

Browse files
author
yevhenii-nadtochii
committed
Update docs to ValidationPlugin and its implementation
1 parent 60ce73a commit a31a138

File tree

4 files changed

+14
-8
lines changed

4 files changed

+14
-8
lines changed

java/src/main/kotlin/io/spine/validation/java/JavaValidationPlugin.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,12 @@ import io.spine.validation.ValidationPlugin
3030
import io.spine.validation.java.setonce.SetOnceRenderer
3131

3232
/**
33-
* A plugin that sets up everything needed to generate Java validation code.
33+
* An implementation of [ValidationPlugin] for Java language.
3434
*
35-
* This plugin uses a delegate plugin to set up some of the components needed for
36-
* code generation. By default, a [ValidationPlugin] is used. However, API users may
37-
* extend this plugin's behavior and supply a more rich base plugin.
35+
* Note: [`(set_once)`][SetOnceRenderer] option is rendered with its own
36+
* renderer because it significantly differs from the rest of constraints.
37+
* This option modifies the message builder behavior. The rest of
38+
* the constraints are more about message state assertions.
3839
*/
3940
@Suppress("unused") // Accessed via reflection.
4041
public class JavaValidationPlugin : ValidationPlugin(

model/src/main/kotlin/io/spine/validation/ValidationPlugin.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,14 @@ import io.spine.validation.required.RequiredIdPatternPolicy
3636
import io.spine.validation.required.RequiredPolicy
3737

3838
/**
39-
* A ProtoData plugin which attaches validation-related policies and views.
39+
* The basic implementation of ProtoData validation plugin, which builds
40+
* language-agnostic representation of the declared constraints.
41+
*
42+
* The concrete implementations should provide [renderers], which will
43+
* implement these constraints for a specific programming language.
44+
* For example, Java, Dart, or TypeScript.
4045
*/
41-
public open class ValidationPlugin(renderers: List<Renderer<*>> = emptyList()) : Plugin(
46+
public abstract class ValidationPlugin(renderers: List<Renderer<*>> = emptyList()) : Plugin(
4247
renderers = renderers,
4348
views = setOf(),
4449
viewRepositories = setOf<ViewRepository<*, *, *>>(

model/src/test/kotlin/io/spine/validation/PolicySpec.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class PolicySpec {
8787
ProtoFileList(emptyList()),
8888
emptySet()
8989
)
90-
val plugin = ValidationPlugin()
90+
val plugin = object : ValidationPlugin() {}
9191
codegenContext = CodeGenerationContext(Pipeline.generateId(), typeSystem) {
9292
// Mimic what a `Pipeline` does to its plugins.
9393
plugin.applyTo(this, typeSystem)

model/src/testFixtures/kotlin/io/spine/validation/ValidationTestFixture.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ import java.nio.file.Path
5050
class ValidationTestFixture(
5151
descriptor: GenericDescriptor,
5252
workingDir: Path,
53-
plugin: Plugin = ValidationPlugin()
53+
plugin: Plugin = object : ValidationPlugin() {}
5454
) {
5555
val setup: PipelineSetup
5656

0 commit comments

Comments
 (0)