Interface IConstraint
-
- All Known Subinterfaces:
IAllowedValuesConstraint
,ICardinalityConstraint
,IExpectConstraint
,IIndexConstraint
,IIndexHasKeyConstraint
,IKeyConstraint
,IMatchesConstraint
,IUniqueConstraint
- All Known Implementing Classes:
AbstractConstraint
,AbstractKeyConstraint
,DefaultAllowedValuesConstraint
,DefaultCardinalityConstraint
,DefaultExpectConstraint
,DefaultIndexConstraint
,DefaultIndexHasKeyConstraint
,DefaultMatchesConstraint
,DefaultUniqueConstraint
public interface IConstraint
Represents a rule constraining the model of a Metaschema assembly, field or flag. Provides a common interface for all constraint definitions.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
IConstraint.ExternalModelSource
static class
IConstraint.ExternalSource
static class
IConstraint.InternalModelSource
static interface
IConstraint.ISource
static class
IConstraint.Level
The degree to which a constraint violation is significant.
-
Field Summary
Fields Modifier and Type Field Description static IConstraint.Level
DEFAULT_LEVEL
The default level to use if no level is provided.static MetapathExpression
DEFAULT_TARGET
The default target Metapath expression to use if no target is provided.static String
DEFAULT_TARGET_METAPATH
The default target Metapath expression to use if no target is provided.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description <T,R>
Raccept(IConstraintVisitor<T,R> visitor, T state)
MarkupLine
getDescription()
String
getFormalName()
String
getId()
Retrieve the unique identifier for the constraint.IConstraint.Level
getLevel()
The significance of a violation of this constraint.Map<QName,Set<String>>
getProperties()
MarkupMultiline
getRemarks()
Retrieve the remarks associated with the constraint.IConstraint.ISource
getSource()
Get information about the source of the constraint.MetapathExpression
getTarget()
Retrieve the Metapath expression to use to query the targets of the constraint.default ISequence<? extends IDefinitionNodeItem<?,?>>
matchTargets(IDefinitionNodeItem<?,?> contextNodeItem)
Based on the providedcontextNodeItem
, find all nodes matching the target expression.default ISequence<? extends IDefinitionNodeItem<?,?>>
matchTargets(IDefinitionNodeItem<?,?> item, DynamicContext dynamicContext)
Based on the providedcontextNodeItem
, find all nodes matching the target expression.
-
-
-
Field Detail
-
DEFAULT_LEVEL
@NonNull static final IConstraint.Level DEFAULT_LEVEL
The default level to use if no level is provided.
-
DEFAULT_TARGET
@NonNull static final MetapathExpression DEFAULT_TARGET
The default target Metapath expression to use if no target is provided.
-
DEFAULT_TARGET_METAPATH
@NonNull static final String DEFAULT_TARGET_METAPATH
The default target Metapath expression to use if no target is provided.- See Also:
- Constant Field Values
-
-
Method Detail
-
getId
@Nullable String getId()
Retrieve the unique identifier for the constraint.- Returns:
- the identifier or
null
if no identifier is defined
-
getDescription
@Nullable MarkupLine getDescription()
-
getFormalName
@Nullable String getFormalName()
-
getSource
@NonNull IConstraint.ISource getSource()
Get information about the source of the constraint.- Returns:
- the source information
-
getLevel
@NonNull IConstraint.Level getLevel()
The significance of a violation of this constraint.- Returns:
- the level
-
getProperties
@NonNull Map<QName,Set<String>> getProperties()
-
getTarget
@NonNull MetapathExpression getTarget()
Retrieve the Metapath expression to use to query the targets of the constraint.- Returns:
- a Metapath expression
-
matchTargets
@NonNull default ISequence<? extends IDefinitionNodeItem<?,?>> matchTargets(@NonNull IDefinitionNodeItem<?,?> contextNodeItem)
Based on the providedcontextNodeItem
, find all nodes matching the target expression.- Parameters:
contextNodeItem
- the node item to evaluate the target expression against- Returns:
- the matching nodes as a sequence
- See Also:
getTarget()
-
matchTargets
@NonNull default ISequence<? extends IDefinitionNodeItem<?,?>> matchTargets(@NonNull IDefinitionNodeItem<?,?> item, @NonNull DynamicContext dynamicContext)
Based on the providedcontextNodeItem
, find all nodes matching the target expression.- Parameters:
item
- the node item to evaluate the target expression againstdynamicContext
- the Metapath evaluation context to use- Returns:
- the matching nodes as a sequence
- See Also:
getTarget()
-
getRemarks
MarkupMultiline getRemarks()
Retrieve the remarks associated with the constraint.- Returns:
- the remarks or
null
if no remarks are defined
-
accept
<T,R> R accept(@NonNull IConstraintVisitor<T,R> visitor, T state)
-
-