class DatabaseCriteriaResolver {

    @NotNull
    AttemptResult<Object> resolveResultByCriteria(DatabaseOperation databaseOperation, DatabaseServerV4Response rdsStatus, Cluster cluster) {
        checkArgument(databaseOperation != null, "DatabaseOperation should not be null");
        checkArgument(rdsStatus != null, "DatabaseServerV4Response should not be null");
        AttemptResult<Object> result;
        if (databaseOperation.getExitCriteria().apply(rdsStatus.getStatus())) {
            result = AttemptResults.finishWith(rdsStatus);
        } else {
            if (databaseOperation.getFailureCriteria().apply(rdsStatus.getStatus())) {
                result = rdsStatus.getStatusReason() != null && rdsStatus.getStatusReason().contains("does not exist")
                        ? AttemptResults.finishWith(null)
                        : AttemptResults.breakFor(getDatabaseOperationFailedResultMessage(cluster, rdsStatus));
            } else {
                result = AttemptResults.justContinue();
            }
        }
        return result;
    }

}