Class TLcdValidationResult

java.lang.Object
com.luciad.util.TLcdValidationResult

public final class TLcdValidationResult extends Object

A TLcdValidationResult is used to contain the result of a validation operation. It contain the severity of the validation result (see TLcdValidationResult.Severity) and the corresponding warning and error messages. The benefit of using this class is that is collects all warnings and errors, instead of relying on a single message as a result.

Usage:

  public TLcdValidationResult validateModelMetaDataForWcsService(TLcdModelMetadata aModelMetadata) {
    TLcdValidationResult validationResult = TLcdValidationResult.ok();

    if (!aModelMetadata.getDataSource().isPresent()) {
      validationResult.addError("The model metadata is empty");
    }

    if (!aModelMetadata.getDataCategories().contains(TLcdModelMetadata.DataCategory.RASTER)) {
      validationResult.addError("The model metadata does not contain raster data.");
    }
    if (aModelMetadata.getDataCategories().size() > 1) {
      validationResult.addError("The model metadata contains mixed data. Only metadata containing nothing but raster data is supported.");
    }

    List<? extends ILcdDimension<?>> dimensions = aModelMetadata.getDimensions();
    if (dimensions.size() > 1
        || (dimensions.size() == 1 && dimensions.get(0).getValues().size() > 1)) {
      validationResult.addWarning("The model metadata contains data with multiple dimensions and values. "
                                  + "This is not supported and only the first dimension value will be used.");
    }

    return validationResult;
  }
Since:
2021.0