forked from metaschema-framework/metaschema-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Custom constraint messages (metaschema-framework#218)
* Added message support for all classes supporting reading and writing constraints in various forms. * Relocated classes in gov/nist/secauto/metaschema/databind/model/binding/metaschema to gov/nist/secauto/metaschema/databind/model/metaschema/binding. * Improved Javadocs. * Added support for custom constraint messages in all but allowed values constraints (see metaschema-framework/metaschema#43). Resolves metaschema-framework#215. * Enhanced logging to include the constraint identifier if it exists. Co-authored-by: A.J. Stein <[email protected]> Co-authored-by: A.J. Stein <[email protected]>
- Loading branch information
1 parent
5114dc5
commit d85e17b
Showing
128 changed files
with
1,386 additions
and
540 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
...ecauto/metaschema/core/model/constraint/AbstractConfigurableMessageConstraintBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* SPDX-FileCopyrightText: none | ||
* SPDX-License-Identifier: CC0-1.0 | ||
*/ | ||
|
||
package gov.nist.secauto.metaschema.core.model.constraint; | ||
|
||
import edu.umd.cs.findbugs.annotations.NonNull; | ||
import edu.umd.cs.findbugs.annotations.Nullable; | ||
|
||
/** | ||
* Provides builder methods for the core data elements of an | ||
* {@link IConstraint}. | ||
* <p> | ||
* The base class of all constraint builders. | ||
* | ||
* @param <T> | ||
* the Java type of the implementing builder | ||
* @param <R> | ||
* the Java type of the resulting built object | ||
* @since 2.0.0 | ||
*/ | ||
public abstract class AbstractConfigurableMessageConstraintBuilder< | ||
T extends AbstractConfigurableMessageConstraintBuilder<T, R>, | ||
R extends IConfigurableMessageConstraint> | ||
extends AbstractConstraintBuilder<T, R> { | ||
private String message; | ||
|
||
/** | ||
* A message to emit when the constraint is violated. Allows embedded Metapath | ||
* expressions using the syntax {@code \{ metapath \}}. | ||
* | ||
* @param message | ||
* the message if defined or {@code null} otherwise | ||
* @return this builder | ||
*/ | ||
@NonNull | ||
public T message(@NonNull String message) { | ||
this.message = message; | ||
return getThis(); | ||
} | ||
|
||
/** | ||
* Get the constraint message provided to the builder. | ||
* | ||
* @return the message or {@code null} if no message is set | ||
*/ | ||
@Nullable | ||
protected String getMessage() { | ||
return message; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.