public function setEntityState($entity, $new)
    {
        $current = $this->getEntityState($entity);

        if ($this->_state_machine->stateChanged($entity, $current, $new) === true) {
            if ($new & AnDomain::STATE_CLEAN) {
                unset($this->_states[$entity]);
            } else {
                $this->_states[$entity] = $new;
                $this->insertEntity($entity);
            }

            return true;
        }

        return false;
    }