Module dev.metaschema.core
Class AbstractConstraintBuilder<T extends AbstractConstraintBuilder<T,R>,R extends IConstraint>
java.lang.Object
dev.metaschema.core.model.constraint.AbstractConstraintBuilder<T,R>
- Type Parameters:
T- the Java type of the implementing builderR- the Java type of the resulting built object
- Direct Known Subclasses:
AbstractConfigurableMessageConstraintBuilder,IAllowedValuesConstraint.Builder
public abstract class AbstractConstraintBuilder<T extends AbstractConstraintBuilder<T,R>,R extends IConstraint>
extends Object
Provides builder methods for the core data elements of an
IConstraint.
The base class of all constraint builders.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Generate the built instance after validating the provided data.description(MarkupLine description) Set a description for the constraint.formalName(String name) Set a formal name for the constraint.protected MarkupLineGet the constraint description provided to the builder.protected StringGet the constraint formal name provided to the builder.protected StringgetId()Get the constraint identifier provided to the builder.protected IConstraint.LevelgetLevel()Get the constraint severity level provided to the builder.protected Map<IAttributable.Key,Set<String>> Get the constraint properties provided to the builder.protected MarkupMultilineGet the remarks provided to the builder.protected ISourceGet the constraint source provided to the builder.protected IMetapathExpressionGet the Metapath expression, provided to the builder, used to get the target(s) of the constraint.protected abstract TgetThis()Get the builder.identifier(String id) Set an identifier for the constraint.level(IConstraint.Level level) Set the severity level for when the constraint is violated.protected abstract RGet a new instance of the built object.properties(Map<IAttributable.Key, Set<String>> properties) Set the collection of properties associated with the constraint.property(IAttributable.Key key, String value) Set the values of the property with the providednameto the providedvalue.property(IAttributable.Key key, Set<String> values) Set the values of the property with the providednameto the providedvalues.remarks(MarkupMultiline remarks) Set the providedremarks.Set the source the constraint was parsed from.target(IMetapathExpression target) Set the Metapath expression used to get the target(s) of the constraint.protected voidvalidate()Validate the values provided to the builder.
-
Constructor Details
-
AbstractConstraintBuilder
public AbstractConstraintBuilder()
-
-
Method Details
-
getThis
Get the builder.Implementations of this method must return
this.- Returns:
- the builder instance
-
identifier
Set an identifier for the constraint.- Parameters:
id- the identifier to set- Returns:
- this builder
-
formalName
Set a formal name for the constraint.- Parameters:
name- the formal name to set- Returns:
- this builder
-
description
Set a description for the constraint.- Parameters:
description- the description to set- Returns:
- this builder
-
source
Set the source the constraint was parsed from.- Parameters:
source- the source to set- Returns:
- this builder
-
level
Set the severity level for when the constraint is violated.- Parameters:
level- the level to set- Returns:
- this builder
-
target
Set the Metapath expression used to get the target(s) of the constraint.- Parameters:
target- a Metapath expression, which will be evaluated relative to the definition it is declared on- Returns:
- this builder
-
properties
Set the collection of properties associated with the constraint.- Parameters:
properties- the properties to set- Returns:
- this builder
-
property
Set the values of the property with the providednameto the providedvalue.- Parameters:
key- the property's namevalue- the value to set- Returns:
- this builder
-
property
Set the values of the property with the providednameto the providedvalues.- Parameters:
key- the property's namevalues- the values to set- Returns:
- this builder
-
remarks
Set the providedremarks.- Parameters:
remarks- the remarks to set- Returns:
- this builder
-
validate
protected void validate()Validate the values provided to the builder.- Throws:
NullPointerException- if a required value isnullConstraintInitializationException- in other cases where the combination of values is inappropriate
-
newInstance
Get a new instance of the built object.- Returns:
- the built instance
-
build
Generate the built instance after validating the provided data.- Returns:
- the built instance
- Throws:
ConstraintInitializationException- if the underlying data is incomplete or invalid
-
getId
Get the constraint identifier provided to the builder.- Returns:
- the identifier or
nullif no identifier has been set
-
getFormalName
Get the constraint formal name provided to the builder.- Returns:
- the formal name or
nullif no formal name has been set
-
getDescription
Get the constraint description provided to the builder.- Returns:
- the description or
nullif no description has been set
-
getSource
Get the constraint source provided to the builder.- Returns:
- the source or
nullif no source has been set
-
getLevel
Get the constraint severity level provided to the builder.- Returns:
- the severity level
-
getTarget
Get the Metapath expression, provided to the builder, used to get the target(s) of the constraint.- Returns:
- the target Metapath expression
-
getProperties
Get the constraint properties provided to the builder.- Returns:
- the properties or an empty Map if no properties are set
-
getRemarks
Get the remarks provided to the builder.- Returns:
- the remarks
-