private List<Condition> getRuleAgeConditions(final List<DataRetentionRule> activeRules,
                                                 final Field<Integer> ruleNoField,
                                                 final Field<Long> metaCreateTimeField,
                                                 final Table<Record4<String, String, Integer, Long>> detailTable) {

        final Instant now = Instant.now();
        LOGGER.debug("now: {}", now);

        return activeRules.stream()
                // We already exclude meta rows where the effective rule is a forever one
                // so no need to add an age condition for forever rules
                .filter(rule -> !rule.isForever())
                .map(rule -> {
                    // Any meta record with a creation time older than this is a candidate for deletion
                    final Instant oldestRetainedCreateTime = DataRetentionCreationTimeUtil.minus(
                            now, rule);
                    LOGGER.debug(() -> LogUtil.message("RuleNo: {}, ageStr: {}, latestCreateTime: {}",
                            rule.getRuleNumber(),
                            rule.getAgeString(),
                            oldestRetainedCreateTime));

                    // Each meta row in the detailTable will have an effective rule and the meta creation time
                    // so include the ones where the meta is older than the delete cut off for the rule.
                    return DSL.and(
                            detailTable.field(ruleNoField)
                                    .eq(rule.getRuleNumber()),
                            detailTable.field(metaCreateTimeField)
                                    .lessThan(oldestRetainedCreateTime.toEpochMilli()));
                })
                .collect(Collectors.toList());
    }
@return True if any term in any rule expression uses at least one of {@code fields}.
stroom-meta/stroom-meta-impl-db/src/main/java/stroom/meta/impl/db/MetaDaoImpl.java