public function countPermissions(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
    {
        $partial = $this->collPermissionsPartial && !$this->isNew();
        if (null === $this->collPermissions || null !== $criteria || $partial) {
            if ($this->isNew() && null === $this->collPermissions) {
                return 0;
            } else {

                if ($partial && !$criteria) {
                    return count($this->getPermissions());
                }

                $query = ChildPermissionQuery::create(null, $criteria);
                if ($distinct) {
                    $query->distinct();
                }

                return $query
                    ->filterByRole($this)
                    ->count($con);
            }
        } else {
            return count($this->collPermissions);
        }
    }