private function documentRouteAndOperations($metadata, Reflector $element)
    {
        if ((null !== ($annotation = $this->getAnnotation($element, 'ML\HydraBundle\Mapping\Id'))) ||
            (null !== ($annotation = $this->getAnnotation($element, 'ML\HydraBundle\Mapping\Route')))) {
            // TODO Check that the IRI template can be filled!?
            $metadata->setRoute($this->getRouteMetadata($annotation->route));
        }

        $annotation = $this->getAnnotation($element, 'ML\HydraBundle\Mapping\Operations');
        if (null !== $annotation) {
            $operations = array_unique($annotation->operations);

            $operationsMetadata = array_map(array($this, 'getRouteMetadata'), $operations);

            $metadata->setOperations($operationsMetadata);
        }

        if (null !== ($route = $metadata->getRoute())) {
            // Add the route to the supported operations
            $metadata->addOperation($this->getRouteMetadata($route->getName()));
        } elseif (null !== $annotation) {
            // ... or use an operation as route if none is set

            // FIXXME: Do this only for GET operations!
            $metadata->setRoute($this->getRouteMetadata(reset($annotation->operations)));
        }

        if (($metadata instanceof PropertyDefinition) && (count($operations = $metadata->getOperations()) > 0)) {
            foreach ($operations as $operation) {
                if (('GET' === $operation->getMethod()) && (null !== $operation->getReturns())) {
                    $metadata->setType($operation->getReturns());
                    return;
                }
            }

            $metadata->setType('ML\HydraBundle\Entity\Resource');
        }
    }