AnyConstraint<T>
public class ValidationConstraint<T> extends AbstractConstraint<T>
ValidationFunction
object to
perform validation.
Notice that two ValidationConstraint
objects are equal if they have the same error Code.
Constructor | Description |
---|---|
ValidationConstraint(int errorCode,
ValidationFunction<T> func) |
Creates a new
ValidationConstraint instance. |
Modifier and Type | Method | Description |
---|---|---|
boolean |
check(ValidationContext context,
T t) |
Checks if the object conforms to the specific rule in the given context.
|
boolean |
equals(java.lang.Object obj) |
Returns
true if the two ValidationConstraint objects have the same error code. |
ValidationFunction<T> |
getValidationFunction() |
Returns the
ValidationFunction registered in this ValidationConstraint . |
static void |
logError(ValidationContext ctx,
int errorCode,
SBase source,
java.lang.String... args) |
Logs a new
SBMLError into a LoggingValidationContext . |
static void |
logErrorWithPostmessageCode(ValidationContext ctx,
int errorCode,
java.lang.String postErrorMessageKey,
SBase source,
java.lang.String... args) |
Logs a new
SBMLError into a LoggingValidationContext . |
getErrorCode
public ValidationConstraint(int errorCode, ValidationFunction<T> func)
ValidationConstraint
instance.errorCode
- the error codefunc
- the ValidationFunction
that will perform the validationpublic static void logError(ValidationContext ctx, int errorCode, SBase source, java.lang.String... args)
SBMLError
into a LoggingValidationContext
.ctx
- the contexterrorCode
- the error codeargs
- the arguments that will be passed to MessageFormat.format(String, Object...)
to build the final post message.public static void logErrorWithPostmessageCode(ValidationContext ctx, int errorCode, java.lang.String postErrorMessageKey, SBase source, java.lang.String... args)
SBMLError
into a LoggingValidationContext
.ctx
- the contexterrorCode
- the error codepostErrorMessageKey
- the key to be used to get the message from the SBMLErrorPostMessage
bundle. In some cases,
we need several different post messages so we need several different keys.args
- the arguments that will be passed to MessageFormat.format(String, Object...)
to build the final post message.public boolean equals(java.lang.Object obj)
true
if the two ValidationConstraint
objects have the same error code.equals
in class java.lang.Object
public boolean check(ValidationContext context, T t)
AnyConstraint
If the rule behaves different for each level/version, the level and version of the context will be used.
context
- the validation contextt
- the object to validatefalse
if the object does not respect the constraintpublic ValidationFunction<T> getValidationFunction()
ValidationFunction
registered in this ValidationConstraint
.ValidationFunction
registered in this ValidationConstraint
.