Skip to main content

REST Expanders 3.18.0

· One min read
Frédéric Hannes
Frédéric Hannes
R&D Engineer

Changes and improvements

Refactoring Options.Option

As net.democritus.sys.Options.Option is being phased out, this version of rest-expanders replaced the vast majority of its uses with java.util.Optional. All of these changes are located in the validation system and may affect custom code.

Migration guide

Updating to Optional<T>

  • ValidationResult.getFirstError() now returns Optional<T>. This method is used in most generated endpoints. If the implementation was copied to custom code, this should be adapted as well.

    if (validateUrlResult.isValidationFailed()) throw new ResourceNotFoundException(validateUrlResult.getFirstError().getValue());
    if (validateUrlResult.isValidationFailed()) throw new ResourceNotFoundException(validateUrlResult.getFirstError().get());
  • Any implementation of database validators that call generated methods in DatabaseValidator class should be adapted if they use the return value of those methods. They have been changed to return Optional<T>. This applies to:

    • DatabaseValidator.existsProjection()
    • DatabaseValidator.existsDataRef()
    • DatabaseValidator.isUniqueProjection()
    • DatabaseValidator.isUniqueDataRef()
    • DatabaseValidator.connectedProjection()
    • DatabaseValidator.connectedDataRef()
  • Any calls to a CommonDataValidator's exists methods or the exists/unique methods in the other DataValidators should be refactored to also handle the new Optional<T> return value. This applies to:

    • <dataElement>CommonDataValidator.validate<dataElement>Exists()
    • <dataElement><operation>DataValidator.validate<dataElement>Exists()
    • <dataElement><operation>DataValidator.validate<dataElement>Unique()