optaplanner-core/src/main/java/org/optaplanner/core/impl/domain/solution/AbstractSolution.java
private void addProblemFactsFromClass(List<Object> factList, Class<?> instanceClass) {
        if (instanceClass.equals(AbstractSolution.class)) {
            // The field score should not be included
            return;
        }
        for (Field field : instanceClass.getDeclaredFields()) {
            field.setAccessible(true);
            if (isFieldAPlanningEntityPropertyOrPlanningEntityCollectionProperty(field, instanceClass)) {
                continue;
            }
            Object value;
            try {
                value = field.get(this);
            } catch (IllegalAccessException e) {
                throw new IllegalStateException("The class (" + instanceClass + ") has a field (" + field
                        + ") which can not be read to create the problem facts.", e);
            }
            if (value != null) {
                if (value instanceof Collection) {
                    factList.addAll((Collection) value);
                } else if (value instanceof Map) {
                    throw new IllegalStateException("The class (" + instanceClass + ") has a field (" + field
                            + ") which is a " + Map.class.getSimpleName() + " and that's not yet supported.");
                } else {
                    factList.add(value);
                }
            }
        }
        Class<?> superclass = instanceClass.getSuperclass();
        if (superclass != null) {
            addProblemFactsFromClass(factList, superclass);
        }
    }
private void addProblemFactsFromClass(List<Object> factList, Class<?> instanceClass) {
        if (instanceClass.equals(AbstractSolution.class)) {
            // The field score should not be included
            return;
        }
        for (Field field : instanceClass.getDeclaredFields()) {
            field.setAccessible(true);
            if (isFieldAPlanningEntityPropertyOrPlanningEntityCollectionProperty(field, instanceClass)) {
                continue;
            }
            Object value;
            try {
                value = field.get(this);
            } catch (IllegalAccessException e) {
                throw new IllegalStateException("The class (" + instanceClass + ") has a field (" + field
                        + ") which can not be read to create the problem facts.", e);
            }
            if (value != null) {
                if (value instanceof Collection) {
                    factList.addAll((Collection) value);
                } else if (value instanceof Map) {
                    throw new IllegalStateException("The class (" + instanceClass + ") has a field (" + field
                            + ") which is a " + Map.class.getSimpleName() + " and that's not yet supported.");
                } else {
                    factList.add(value);
                }
            }
        }
        Class<?> superclass = instanceClass.getSuperclass();
        if (superclass != null) {
            addProblemFactsFromClass(factList, superclass);
        }
    }
Adds to an existing to {@link List} to avoid copying the entire list with {@link List#addAll(Collection)}.
@param factList never null
@param instanceClass never null