/*
(non-Javadoc)
@see org.springframework.hateoas.LinkDiscoverer#findLinksWithRel(org.springframework.hateoas.LinkRelation, java.lang.String)
174201
@Override
	public Links findLinksWithRel(LinkRelation rel, String representation) {

		return getLinks(representation).stream() //
				.filter(it -> it.hasRel(rel)) //
				.collect(Links.collector());
	}
746721
@VisibleForTesting
  static void getLocationsFromLink(List<String> possiblePaths, Path link) {
    try {
      Path resolvedLink = link.toRealPath();
      Path possibleBinDir = resolvedLink.getParent();
      // check if the parent is "bin", we actually depend on that for other resolution
      if (possibleBinDir != null && possibleBinDir.getFileName().toString().equals("bin")) {
        Path possibleCloudSdkHome = possibleBinDir.getParent();
        if (possibleCloudSdkHome != null && Files.exists(possibleCloudSdkHome)) {
          possiblePaths.add(possibleCloudSdkHome.toString());
        }
      }
    } catch (IOException ioe) {
      // intentionally ignore exception
      logger.log(Level.FINE, "Non-critical exception when searching for cloud-sdk", ioe);
    }
  }
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;
    }
825289
@Override
	public LinkRelation getCollectionResourceRelFor(Class<?> type) {
		return LinkRelation.of(StringUtils.uncapitalize(type.getSimpleName()) + "List");
	}
853502
protected Link extractLink(Object element, LinkRelation rel) {
		return new Link(element.toString(), rel);
	}
835206
@Override
	public LinkBuilder linkFor(Class<?> entity, Object... parameters) {

		Assert.notNull(entity, "Entity must not be null!");

		Class<?> controllerType = entityToController.get(entity);

		if (controllerType == null) {
			throw new IllegalArgumentException(String.format(
					"Type %s is not managed by a Spring MVC controller. Make sure you have annotated your controller with %s!",
					entity.getName(), ExposesResourceFor.class.getName()));
		}

		return linkBuilderFactory.linkTo(controllerType, parameters);
	}
460967
public void removeLinks(ServiceReference<D> declarationSRef) {
        D declaration = getDeclaration(declarationSRef);
        for (ServiceReference serviceReference : declaration.getStatus().getServiceReferencesBounded()) {
            // FIXME : In case of multiples Linker, we will remove the link of all the ServiceReference
            // FIXME : event the ones which dun know nothing about
            linkerManagement.unlink(declaration, serviceReference);
        }
    }
727187
public Link getLink() {
        final String link = headers.getFirst(LINK);
        if (link != null) {
            return Link.valueOf(link);
        }
        return null;
    }
1124213
public static LinkRelation parse(String relation) {

		return LINK_RELATIONS.stream() //
				.filter(it -> it.value().equalsIgnoreCase(relation)) //
				.findFirst() //
				.orElseThrow(() -> new IllegalArgumentException(relation + " is not a valid IANA link relation!"));
	}
525929
public <U extends ODataEntity<?>> LinkInfo<U> getLink(String rel) {
        for (Object child : entry.getEntryChildren()) {

            LinkType link = linkFromChild(child);
            if (link != null && link.getRel().equals(rel)) {
                return new LinkInfo<U>(link);
            }
        }
        return null;
    }
1290849
private void readRelationship(Link link)
   {
      Task sourceTask = m_taskIdMap.get(link.getSourceTaskID());
      Task destinationTask = m_taskIdMap.get(link.getDestinationTaskID());
      if (sourceTask != null && destinationTask != null)
      {
         Duration lag = getDuration(link.getLagUnit(), link.getLag());
         RelationType type = link.getType();
         Relation relation = destinationTask.addPredecessor(sourceTask, type, lag);
         relation.setUniqueID(link.getID());
      }
   }
857332
private LinkRelation toLinkRelation(JavaClass javaClazz, JavaField javaField, ClassLoader compileClassLoader) {
    LinkRelation rel = new LinkRelation();

    rel.setShortDescription(buildShortDescription(javaField.getComment()));
    rel.setDescriptionMarkup(javaField.getComment());

    rel.setRel(getStaticFieldValue(javaClazz, javaField, compileClassLoader, String.class));

    LinkRelationDoc relDoc = getAnnotation(javaClazz, javaField, compileClassLoader, LinkRelationDoc.class);
    rel.setJsonSchemaRef(buildJsonSchemaRefModel(relDoc.jsonSchema(), relDoc.model()));

    Arrays.stream(relDoc.embedded()).forEach(embedded -> rel.addResourceRef(embedded.value(), embedded.description(),
        buildJsonSchemaRefModel(embedded.jsonSchema(), embedded.model())));

    Arrays.stream(relDoc.links()).forEach(link -> rel.addLinkRelationRef(link.value(), link.description()));

    return rel;
  }
527164
public List<Link> getLinks(String relation) {

		Assert.hasText(relation, "Link relation must not be null or empty!");

		return links.stream() //
				.filter(link -> link.hasRel(relation)) //
				.collect(Collectors.toList());
	}
1230974
public Optional<Link> getLinkByRel(final String rel)
    {
        return Optional.ofNullable(representation.getLinkByRel(rel));
    }
90198
def findFirstHref(link_attrs_list, target_rel):
    """"""
    # XXX: TESTME
    matches = findLinksRel(link_attrs_list, target_rel)
    if not matches:
        return None
    first = matches[0]
    return first.get('href')
508536
@Override
	public LinkRelation getItemResourceRelFor(Class<?> type) {

		Assert.notNull(type, "Type must not be null!");

		Relation annotation = lookupAnnotation(type);

		if (annotation == null || Relation.NO_RELATION.equals(annotation.value())) {
			throw new IllegalStateException(String.format("Type %s is not supported!", type.getName()));
		}

		return LinkRelation.of(annotation.value());
	}
63368
private Links createLinksFrom(Object parseResult, LinkRelation rel) {

		if (JSONArray.class.isInstance(parseResult)) {

			JSONArray jsonArray = (JSONArray) parseResult;

			return jsonArray.stream() //
					.flatMap(it -> JSONArray.class.isInstance(it) ? ((JSONArray) it).stream() : Stream.of(it)) //
					.map(it -> extractLink(it, rel)) //
					.collect(Collectors.collectingAndThen(Collectors.toList(), Links::of));
		}

		return Links.of(Map.class.isInstance(parseResult) //
				? extractLink(parseResult, rel) //
				: new Link(parseResult.toString(), rel));
	}