public function compareData(
        $entities,
        array $requestEntities,
        callable $compare = null,
        callable $add = null,
        callable $update = null,
        callable $delete = null
    ) {
        $success = true;

        if (!empty($entities)) {
            foreach ($entities as $entity) {
                $matchedEntry = null;
                $matchedKey = null;

                // find match callback
                $compare($entity, $requestEntities, $matchedEntry, $matchedKey);

                if (null == $matchedEntry && null != $delete) {
                    // delete entity if it is not listed anymore
                    $delete($entity);
                } elseif (null != $update) {
                    // update entity if it is matched
                    $success = $update($entity, $matchedEntry);
                    if (!$success) {
                        break;
                    }
                }

                // Remove done element from array
                if (null !== $matchedKey) {
                    unset($requestEntities[$matchedKey]);
                }
            }
        }

        // The entity which have not been delete or updated have to be added
        if (!empty($requestEntities) && null != $add) {
            foreach ($requestEntities as $entity) {
                if (!$success) {
                    break;
                }
                $success = $add($entity);
            }
        }

        return $success;
    }