In the Validation code in EObjectValidator.java:
protected boolean validate_DataValueConforms
(EObject eObject, EAttribute eAttribute, DiagnosticChain diagnostics, Map<Object, Object> context)
{
if (!eObject.eIsSet(eAttribute))
{
return true;
}
boolean result = true;
EDataType eDataType = eAttribute.getEAttributeType();
. . .
The code checks is the EAttribute is set regardless if it is derived or not.
The code should be something like this:
protected boolean validate_DataValueConforms
(EObject eObject, EAttribute eAttribute, DiagnosticChain diagnostics, Map<Object, Object> context)
{
if (eAttribute.isDerived() || !eObject.eIsSet(eAttribute))
{
return true;
}
boolean result = true;
EDataType eDataType = eAttribute.getEAttributeType();
. . .
Since my derived attribute in the model has complex calculation, I do not wish to run the calculation every time the model is validated.
How can I make validation skip the derived attributes?
Derived Attributes are really not important for validation
Another option is to generate in the implementation of the class under eIsSet(), return always false for derived attributes:
public boolean eIsSet(int featureID) {
switch (featureID) {
case FSDModelPackage.WIDGET_PART_LAYOUT__WIDTH:
return getWidth() != WIDTH_EDEFAULT;
case FSDModelPackage.WIDGET_PART_LAYOUT__HEIGHT:
return getHeight() != HEIGHT_EDEFAULT;
case FSDModelPackage.WIDGET_PART_LAYOUT__OVERRIDE_WIDTH:
return overrideWidth != OVERRIDE_WIDTH_EDEFAULT;
case FSDModelPackage.WIDGET_PART_LAYOUT__OVERRIDE_HEIGHT:
return overrideHeight != OVERRIDE_HEIGHT_EDEFAULT;
case FSDModelPackage.WIDGET_PART_LAYOUT__COLUMN_POSITION:
return columnPosition != COLUMN_POSITION_EDEFAULT;
case FSDModelPackage.WIDGET_PART_LAYOUT__ROW_POSITION:
return rowPosition != ROW_POSITION_EDEFAULT;
case FSDModelPackage.WIDGET_PART_LAYOUT__WIDTH_UI:
return false; // CMT54208:25713 Derived value, do not check
case FSDModelPackage.WIDGET_PART_LAYOUT__HEIGHT_UI:
return false; // CMT54208:25713 Derived value, do not check
}
return super.eIsSet(featureID);
}
Thanks
Yigal