I am using OCL constraints on ecore model and generating code. So the thing is as simple as this
I have a class Task having attribute startDate
and endDate
it has an ocl constraint :- invariant which states startDate < endDate
.
I have generated java code for this project and there is a java class :
public class TmsValidator extends EObjectValidator {
//what is diagnosticChain and context in the below method
public boolean validateTask_C2(Task task, DiagnosticChain diagnostics, Map<Object, Object context) {
return validate(TmsPackage.Literals.TASK,
task,
diagnostics,
context,
"http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot",
"C2",
TASK__C2__EEXPRESSION,
Diagnostic.ERROR,
DIAGNOSTIC_SOURCE,
0);
}
}
So from my main class, how do I validate my task here . I want to call the OCL
constraint to check if startDate
is less than endDate
public class {
public static void main(String []a){
Task t = new
Task ();
// How do I validate my task here . I want to call the
//OCL constraint to check if startDate is less than endDate
}
}