class KiePMMLASTFactoryUtils {

    static void populateKiePMMLFieldOperatorValueListWithCompoundPredicates(final List<KiePMMLFieldOperatorValue> toPopulate,
                                                                            final List<CompoundPredicate> compoundPredicates,
                                                                            final Map<String, KiePMMLOriginalTypeGeneratedType> fieldTypeMap) {
        final List<KiePMMLFieldOperatorValue> nestedAndPredicates = new LinkedList<>();
        final List<KiePMMLFieldOperatorValue> nestedOrPredicates = new LinkedList<>();
        compoundPredicates.forEach(nestedCompoundPredicate -> {
            switch ((nestedCompoundPredicate).getBooleanOperator()) {
                case OR:
                    nestedOrPredicates.addAll(getConstraintEntriesFromAndOrCompoundPredicate(nestedCompoundPredicate, fieldTypeMap));
                    break;
                case AND:
                    nestedAndPredicates.addAll(getConstraintEntriesFromAndOrCompoundPredicate(nestedCompoundPredicate, fieldTypeMap));
                    break;
                default:
                    throw new IllegalStateException(String.format("Unmanaged CompoundPredicate.booleanOperator %s at populateKiePMMLFieldOperatorValueListWithCompoundPredicates", nestedCompoundPredicate.getBooleanOperator()));
            }
        });
        if (!nestedAndPredicates.isEmpty()) {
            toPopulate.add(new KiePMMLFieldOperatorValue(null, BOOLEAN_OPERATOR.AND, Collections.emptyList(), nestedAndPredicates));
        }
        if (!nestedOrPredicates.isEmpty()) {
            toPopulate.add(new KiePMMLFieldOperatorValue(null, BOOLEAN_OPERATOR.OR, Collections.emptyList(), nestedOrPredicates));
        }
    }

    private  KiePMMLASTFactoryUtils();

}