Return a HAL entity with just a self link
976542
public function extract($value)
    {
        if (is_null($value)) {
            return $value;
        }

        $entityValues = $this->getHydratorForEntity($value)->extract($value);
        $entityMetadata = $this->getMetadataMap()[ClassUtils::getRealClass(get_class($value))];

        $link = new Link('self');
        $link->setRoute($entityMetadata['route_name']);
        $link->setRouteParams([
            $entityMetadata['route_identifier_name'] => $entityValues[$entityMetadata['entity_identifier_name']]
        ]);

        $linkCollection = new LinkCollection();
        $linkCollection->add($link);

        $halEntity = new HalEntity(new stdClass());
        $halEntity->setLinks($linkCollection);

        return $halEntity;
    }
759999
def makeMNBaseURL(url):
    """"""
    o = urllib.parse.urlparse(url, scheme=d1_common.const.DEFAULT_MN_PROTOCOL)
    if o.netloc and o.path:
        netloc = o.netloc
        path = o.path
    elif o.netloc:
        netloc = o.netloc
        path = d1_common.const.DEFAULT_MN_PATH
    elif o.path:
        s = o.path.split('/', 1)
        netloc = s[0]
        if len(s) == 1:
            path = d1_common.const.DEFAULT_MN_PATH
        else:
            path = s[1]
    else:
        netloc = d1_common.const.DEFAULT_MN_HOST
        path = d1_common.const.DEFAULT_MN_PATH
    return urllib.parse.urlunparse(
        (o.scheme, netloc, path, o.params, o.query, o.fragment)
    )
1223214
public HalRepresentation link(String rel, String href) {
        addLink(rel, new Link(href));
        return this;
    }
790057
def _handle_entity(self, token):
        """"""
        token = self._tokens.pop()
        if isinstance(token, tokens.HTMLEntityNumeric):
            token = self._tokens.pop()
            if isinstance(token, tokens.HTMLEntityHex):
                text = self._tokens.pop()
                self._tokens.pop()  # Remove HTMLEntityEnd
                return HTMLEntity(text.text, named=False, hexadecimal=True,
                                  hex_char=token.char)
            self._tokens.pop()  # Remove HTMLEntityEnd
            return HTMLEntity(token.text, named=False, hexadecimal=False)
        self._tokens.pop()  # Remove HTMLEntityEnd
        return HTMLEntity(token.text, named=True, hexadecimal=False)
1179457
def _recursively_embed(self, doc, update_state=True):
        ''''''
        self_link = None
        self_uri = utils.getpath(doc, '_links.self.href')
        if self_uri is not None:
            uri = urlparse.urljoin(self.uri, self_uri)
            self_link = Link(
                uri=uri,
                properties=utils.getpath(doc, '_links.self')
            )
        curies = utils.getpath(doc, '_links.curies')
        state = utils.getstate(doc)
        if self_link is None:
            nav = OrphanHALNavigator(
                link=None,
                response=None,
                parent=self,
                core=self._core,
                curies=curies,
                state=state,
            )
        else:
            nav = HALNavigator(
                link=self_link,
                response=None,
                core=self._core,
                curies=curies,
                state=state,
            )
        if update_state:
            nav.state = state

        links = self._make_links_from(doc)
        if links is not None:
            nav._links = links
        embedded = self._make_embedded_from(doc)
        if embedded is not None:
            nav._embedded = embedded
        return nav
150085
def merge_link_object(serializer, data, instance):
    

    link_object = {}

    if not getattr(instance, 'pk', None):
        # If instance doesn't have a `pk` field, we'll assume it doesn't
        # have a canonical resource URL to hang a link off of.
        # This generally only affectes Ephemeral Objects.
        return data

    link_fields = serializer.get_link_fields()
    for name, field in six.iteritems(link_fields):
        # For included fields, omit link if there's no data.
        if name in data and not data[name]:
            continue

        link = getattr(field, 'link', None)
        if link is None:
            base_url = ''
            if settings.ENABLE_HOST_RELATIVE_LINKS:
                # if the resource isn't registered, this will default back to
                # using resource-relative urls for links.
                base_url = DynamicRouter.get_canonical_path(
                    serializer.get_resource_key(),
                    instance.pk
                ) or ''
            link = '%s%s/' % (base_url, name)
        # Default to DREST-generated relation endpoints.
        elif callable(link):
            link = link(name, field, data, instance)

        link_object[name] = link

    if link_object:
        data['links'] = link_object
    return data
207903
def get_entity(self, uri: str) -> OntologyClass:
        
        return self.entities.get(str(uri), None)
1062023
function Entity(route, opts) {
  if (!(this instanceof Entity)) return new Entity(route, opts);
  this._route = route;
  this._options = opts || {};
  this._methods = {};
  this.on('error', function() { /* stifle auto exit on error */ });
}
1211098
function pathObjectUrl($entity, $type = LinkGeneratorService::TYPE_LINK_DEFAULT, array $parameters = array()) {
        if($entity === null){
            return "";
        }
        return $this->linkGeneratorService->generateOnlyUrl($entity, $type, $parameters);
    }
644756
def url(self, node):
        
        a_node = node.findParent('a')
        if not a_node:
            return None

        if self.link_callback is None:
            return a_node.get('href')
        else:
            return self.link_callback(a_node.get('href'))
664124
def from_url(cls, url, **kwargs):
        
        doc = {
            "clusters": [
                {
                    "name": "self",
                    "cluster": {
                        "server": url,
                    },
                },
            ],
            "contexts": [
                {
                    "name": "self",
                    "context": {
                        "cluster": "self",
                    },
                }
            ],
            "current-context": "self",
        }
        self = cls(doc, **kwargs)
        return self
1028433
def href(self):
        
        url = self.session.base_url + str(self.path)
        if self.path.is_collection and not self.path.is_root:
            return url + 's'
        return url
539745
public static Link getLinkByRel(Entity entity, String... rel) {
        if(entity == null) {
            throw new IllegalArgumentException("entity cannot be null.");
        }
        if(ArrayUtils.isEmpty(rel)) {
            throw new IllegalArgumentException("rel cannot be null or empty");
        }
        List<Link> links = entity.getLinks();
        if (links == null)
            return null;
        Link link = null;
        for (Link l : links) {
            if (ArrayUtils.isNotEmpty(l.getRel()) && ArrayUtils.toString(rel).equals(ArrayUtils.toString(l.getRel()))) {
                link = l;
                break;
            }
        }
        return link;
    }
352917
def single(C, namespace=None):
        """"""
        if namespace is None:
            B = C()._
        else:
            B = C(default=namespace, _=namespace)._
        return B
953751
def _handle_external_link(self, token):
        """"""
        brackets, url = token.brackets, None
        self._push()
        while self._tokens:
            token = self._tokens.pop()
            if isinstance(token, tokens.ExternalLinkSeparator):
                url = self._pop()
                self._push()
            elif isinstance(token, tokens.ExternalLinkClose):
                if url is not None:
                    return ExternalLink(url, self._pop(), brackets)
                return ExternalLink(self._pop(), brackets=brackets)
            else:
                self._write(self._handle_token(token))
        raise ParserError("_handle_external_link() missed a close token")
655545
def urlAt(self, index):
        
        if 0 <= index and index < len(self._stack):
            return self._stack[index][0]
        return ''
737336
def _get_entity(partition_key, row_key, select, accept):
    '''
    
    '''
    _validate_not_none('partition_key', partition_key)
    _validate_not_none('row_key', row_key)
    _validate_not_none('accept', accept)
    request = HTTPRequest()
    request.method = 'GET'
    request.headers = [('Accept', _to_str(accept))]
    request.query = [('$select', _to_str(select))]

    return request