class AbstractSearchRequest extends DirectBean implements PagedRequest {

  public boolean matches(AbstractDocument document) {
    if (getVersionCorrection() == null) {
      return true;
    }
    Instant versionFrom = Objects.firstNonNull(document.getVersionFromInstant(), Instant.MIN);
    Instant versionTo = Objects.firstNonNull(document.getVersionToInstant(), Instant.MAX);
    Instant correctionFrom = Objects.firstNonNull(document.getCorrectionFromInstant(), Instant.MIN);
    Instant correctionTo = Objects.firstNonNull(document.getCorrectionToInstant(), Instant.MAX);
    VersionCorrection locked = getVersionCorrection().withLatestFixed(OpenGammaClock.getInstance().instant());
    Instant versionPoint = locked.getVersionAsOf();
    Instant corrrectionPoint = locked.getCorrectedTo();
    return versionPoint.isBefore(versionTo) &&
        !versionFrom.isAfter(versionPoint) &&
        corrrectionPoint.isBefore(correctionTo) &&
        !correctionFrom.isAfter(corrrectionPoint);
  }

  public  AbstractSearchRequest();

}