@Override protected void validateThis(final ValidationContext context) { super.validateThis(context); final FloatOrVariableRef maxComputer = getMax(); final FloatOrVariableRef minComputer = getMin(); if (maxComputer.isConstantFloat() && minComputer.isConstantFloat()) { final double max = maxComputer.getConstantFloatValue().doubleValue(); final double min = minComputer.getConstantFloatValue().doubleValue(); if (max < min) { context.fireAttributeValidationError(getAttributes().get(ATTR_MAX_NAME), "Attribute " + ATTR_MAX_NAME + " (" + max + ") cannot be lower than " + ATTR_MIN_NAME + " (" + min + ")"); } } }
@Override protected void validateThis(final ValidationContext context) { super.validateThis(context); final Attribute<?> tolerancesAttr = getAttributes().get(ATTR_TOLERANCES_NAME); final List<FloatOrVariableRef> tolerances = getTolerances(); if (tolerances!=null && (tolerances.size()==0 || tolerances.size()>2)) { context.fireAttributeValidationError(tolerancesAttr, "Attribute " + ATTR_TOLERANCES_NAME + " must contain 1 or 2 floatOrVariableRefs when specified"); } final FloatOrVariableRef firstToleranceComputer = getFirstTolerance(); if (firstToleranceComputer!=null && firstToleranceComputer.isConstantFloat()) { final double firstToleranceValue = firstToleranceComputer.getConstantFloatValue().doubleValue(); if (firstToleranceValue <= 0) { context.fireAttributeValidationError(tolerancesAttr, "Attribute " + ATTR_TOLERANCES_NAME + " (" + firstToleranceValue + ") must be positive"); } } final FloatOrVariableRef secondToleranceComputer = getSecondTolerance(); if (secondToleranceComputer!=null && secondToleranceComputer.isConstantFloat()) { final double secondToleranceValue = secondToleranceComputer.getConstantFloatValue().doubleValue(); if (secondToleranceValue < 0) { context.fireAttributeValidationError(tolerancesAttr, "Attribute " + ATTR_TOLERANCES_NAME + " (" + getSecondTolerance() + ") must be positive if specified"); } } if (getToleranceMode() != null && getToleranceMode() != ToleranceMode.EXACT && tolerances==null) { context.fireAttributeValidationError(tolerancesAttr, "Attribute " + ATTR_TOLERANCES_NAME + " must be specified when toleranceMode is absolute or relative"); } }