private void insertInTrailingEntityMap(Object entity) {
if (hasChainedVariables) {
for (Map.Entry<PlanningVariableDescriptor, Map<Object, List<Object>>> entry
: chainedVariableToTrailingEntitiesMap.entrySet()) {
PlanningVariableDescriptor variableDescriptor = entry.getKey();
if (variableDescriptor.getPlanningEntityDescriptor().appliesToPlanningEntity(entity)) {
Object value = variableDescriptor.getValue(entity);
Map<Object, List<Object>> valueToTrailingEntityMap = entry.getValue();
List<Object> trailingEntities = valueToTrailingEntityMap.get(value);
if (trailingEntities == null) {
trailingEntities = new ArrayList<Object>();
valueToTrailingEntityMap.put(value, trailingEntities);