1 /*
2 * SPDX-FileCopyrightText: none
3 * SPDX-License-Identifier: CC0-1.0
4 */
5
6 package dev.metaschema.core.model.constraint;
7
8 import dev.metaschema.core.configuration.AbstractConfigurationFeature;
9 import edu.umd.cs.findbugs.annotations.NonNull;
10
11 /**
12 * A set of configurable features that adjust Metaschema constraint validation
13 * behavior.
14 *
15 * @param <V>
16 * the Java type of the configuration value
17 */
18 public final class ValidationFeature<V>
19 extends AbstractConfigurationFeature<V> {
20 /**
21 * If enabled, generate findings for passing constraints.
22 */
23 @NonNull
24 public static final ValidationFeature<Boolean> VALIDATE_GENERATE_PASS_FINDINGS
25 = new ValidationFeature<>("include-pass-findings", Boolean.class, false);
26 /**
27 * If enabled, throw an exception when an error occurs.
28 */
29 @NonNull
30 public static final ValidationFeature<Boolean> THROW_EXCEPTION_ON_ERROR
31 = new ValidationFeature<>("throw-exception-on-error", Boolean.class, false);
32 /**
33 * The number of threads to use for parallel constraint validation.
34 * <p>
35 * A value of 1 (the default) means sequential validation. Values greater than 1
36 * enable experimental parallel validation with the specified number of threads.
37 * <p>
38 * <b>Warning:</b> Parallel validation is an experimental feature. Results
39 * should be verified against sequential validation.
40 */
41 @NonNull
42 public static final ValidationFeature<Integer> PARALLEL_THREADS
43 = new ValidationFeature<>("parallel-threads", Integer.class, 1);
44 /**
45 * An optional event listener to receive callbacks during constraint validation.
46 * <p>
47 * This allows external instrumentation (e.g., timing collection) to observe
48 * validation events without modifying the validator itself. The default is a
49 * no-op listener with zero overhead.
50 *
51 * @see TimingCollector
52 * @see ValidationEventListener
53 */
54 @NonNull
55 public static final ValidationFeature<ValidationEventListener> EVENT_LISTENER
56 = new ValidationFeature<>("event-listener", ValidationEventListener.class,
57 NoOpValidationEventListener.INSTANCE);
58
59 private ValidationFeature(
60 @NonNull String name,
61 @NonNull Class<V> valueClass,
62 @NonNull V defaultValue) {
63 super(name, valueClass, defaultValue);
64 }
65 }