@@ -346,10 +346,20 @@ different structure can implement the `Violation.Visitor` Interface with a suita
346
346
type `(String` used as an example here) and use the visitor to handle the different types of
347
347
Violations in a type-safe way.
348
348
349
+ The `AspectModelValidator` also provides the `loadModel(Supplier<AspectModel>)` method that can be used in
350
+ conjunction with `() -> new AspectModeLoader().load(...)` to have exceptions that might be created during the
351
+ Aspect Model loading process, for example due to model resolution failures or syntax errors in the input
352
+ files, be turned into a `List<Violation>` that can be passed to the aforementioned violation formatters. This
353
+ allows for custom structured handling of problems that occur during model loading.
354
+
355
+ To include the model validator, use the following dependencies:
356
+
357
+ include::esmf-developer-guide:ROOT:partial$esmf-aspect-model-validator-artifact.adoc[]
358
+
349
359
=== Custom Error Formatting
350
360
351
- In order to access validation violations in a type-safe way, implement the interface
352
- `org.eclipse.esmf.aspectmodel.shacl.violation.Violation.Visitor`. This allows you to handle each
361
+ In order to access validation violations in a type-safe way, implement the interface
362
+ `org.eclipse.esmf.aspectmodel.shacl.violation.Violation.Visitor`. This allows you to handle each
353
363
violation type specifically and format error messages according to your application's requirements.
354
364
355
365
++++
@@ -369,25 +379,39 @@ include::example$CustomViolationFormatter.java[tags=imports]
369
379
include::example$CustomViolationFormatter.java[tags=custom-formatter]
370
380
----
371
381
382
+ === Programmatic Access
383
+
384
+ When using the Java API, errors are available through the `Violation` interface:
385
+
386
+ [source,java]
387
+ ++++
388
+ <details>
389
+ <summary>Show used imports</summary>
390
+ ++++
391
+ [source,java,indent=0,subs="+macros,+quotes"]
392
+ ----
393
+ include::example$ValidateAspectModel.java[tags=imports]
394
+ ----
395
+ ++++
396
+ </details>
397
+ ++++
398
+
399
+ [source,java,indent=0,subs="+macros,+quotes"]
400
+ ----
401
+ include::example$ValidateAspectModel.java[tags=violations]
402
+ ----
403
+
404
+
372
405
=== Error Aggregation
373
406
374
- For applications that need to process multiple violations efficiently, you can group errors by type
407
+ For applications that need to process multiple violations efficiently, you can group errors by type
375
408
for batch processing:
376
409
377
410
[source,java,indent=0,subs="+macros,+quotes"]
378
411
----
379
412
include::example$CustomViolationFormatter.java[tags=error-aggregation]
380
413
----
381
414
382
- The `AspectModelValidator` also provides the `loadModel(Supplier<AspectModel>)` method that can be used in
383
- conjunction with `() -> new AspectModeLoader().load(...)` to have exceptions that might be created during the
384
- Aspect Model loading process, for example due to model resolution failures or syntax errors in the input
385
- files, be turned into a `List<Violation>` that can be passed to the aforementioned violation formatters. This
386
- allows for custom structured handling of problems that occur during model loading.
387
-
388
- To include the model validator, use the following dependencies:
389
-
390
- include::esmf-developer-guide:ROOT:partial$esmf-aspect-model-validator-artifact.adoc[]
391
415
392
416
[[generating-documentation]]
393
417
== Generating Documentation for Aspect Models
0 commit comments