// In a page constructor add(new Link("link") { public void onClick() { setVisible(false); } });
public void insert(int d1, double d2) { Link link = new Link(d1, d2); if(first==null){ link.nextLink = null; first = link; last=link; } else{ last.nextLink=link; link.nextLink=null; last=link; } }
/** * Creats a new {@link Link} with the given {@link Affordance}s. * * @param affordances must not be {@literal null}. * @return */ public Link withAffordances(List<Affordance> affordances) { return new Link(this.rel, this.href, this.hreflang, this.media, this.title, this.type, this.deprecation, this.profile, this.template, affordances); }
/** * Fetch all the links found in this {@link UberData}. */ @JsonIgnore public List<Link> getLinks() { return Optional.ofNullable(this.rel) .map(rels -> rels.stream() .map(rel -> new Link(this.url, rel)) .collect(Collectors.toList())) .orElse(Collections.emptyList()); }
@Override public Link findInResponse(String representation, MediaType mediaType) { return new Link(JsonPath.read(representation, jsonPath).toString(), rel); } }
/** * Creates {@link Link} instances from the given parse result. * * @param parseResult the result originating from parsing the source content using the JSON path expression. * @param rel the relation type that was parsed for. * @return */ private List<Link> createLinksFrom(Object parseResult, String rel) { if (parseResult instanceof JSONArray) { JSONArray array = (JSONArray) parseResult; return array.stream() // .map(element -> new Link(element.toString(), rel)) // .collect(Collectors.collectingAndThen(Collectors.toList(), Collections::unmodifiableList)); } return Collections.unmodifiableList(Collections.singletonList(new Link(parseResult.toString(), rel))); }
@Override public ResourceSupport read(Class<? extends ResourceSupport> clazz, HttpInputMessage inputMessage) throws IOException, HttpMessageNotReadableException { List<Link> links = new ArrayList<Link>(); Scanner scanner = new Scanner(inputMessage.getBody()); try { while (scanner.hasNextLine()) { String line = scanner.nextLine(); if (StringUtils.hasText(line)) { links.add(new Link(line)); } } } finally { scanner.close(); } return new Resources<Object>(Collections.emptyList(), links); }
/** * Add a link to the {@link ProfileController}'s base URI to the app's root URI. * * @param resource * @return */ @Override public RepositoryLinksResource process(RepositoryLinksResource resource) { resource.add(new Link(ProfileController.getRootPath(this.configuration), PROFILE_REL)); return resource; } }
private Link traverseToLink(boolean expandFinalUrl) { Assert.isTrue(this.rels.size() > 0, "At least one rel needs to be provided!"); URIAndHeaders expandedFinalUriAndHeaders = traverseToExpandedFinalUrl(); UriStringAndHeaders finalUriAndHeaders = traverseToFinalUrl(); return new Link(expandFinalUrl ? expandedFinalUriAndHeaders.getUri().toString() : finalUriAndHeaders.getUri(), this.rels.get(this.rels.size() - 1).getRel()); }
public Link withRel(String rel) { return new Link(toString(), rel).withAffordances(affordances); }
/** * Turns the current template into a {@link Link} by expanding it using the given parameters. * * @param arguments * @return */ public Link expand(Object... arguments) { return new Link(getUriTemplate().expand(arguments).toString(), getRel()); }
/** * Turns the current template into a {@link Link} by expanding it using the given parameters. * * @param arguments must not be {@literal null}. * @return */ public Link expand(Map<String, ? extends Object> arguments) { return new Link(getUriTemplate().expand(arguments).toString(), getRel()); }
/** * Creates the self link for the given domain instance. * * @param instance must be a managed entity, not {@literal null}. * @return */ public Link getSelfLinkFor(Object instance) { Link link = linkProvider.createSelfLinkFor(instance); return new Link(link.expand().getHref(), Link.REL_SELF); } }
protected Link getDefaultSelfLink() { return new Link(ServletUriComponentsBuilder.fromCurrentRequest().build().toUriString()); } }
protected Link resourceLink(RootResourceInformation resourceLink, Resource resource) { ResourceMetadata repoMapping = resourceLink.getResourceMetadata(); Link selfLink = resource.getLink("self"); String rel = repoMapping.getItemResourceRel(); return new Link(selfLink.getHref(), rel); }
/** * List a profile link for each exported repository. * * @return */ @RequestMapping(value = PROFILE_ROOT_MAPPING, method = GET) HttpEntity<ResourceSupport> listAllFormsOfMetadata() { ResourceSupport profile = new ResourceSupport(); profile.add(new Link(getRootPath(this.configuration)).withSelfRel()); for (Class<?> domainType : this.repositories) { ResourceMetadata mapping = this.mappings.getMetadataFor(domainType); if (mapping.isExported()) { profile.add(new Link(getPath(this.configuration, mapping), mapping.getRel())); } } return new ResponseEntity<ResourceSupport>(profile, HttpStatus.OK); }
private List<Link> getCollectionResourceLinks(RootResourceInformation resourceInformation, DefaultedPageable pageable) { ResourceMetadata metadata = resourceInformation.getResourceMetadata(); SearchResourceMappings searchMappings = metadata.getSearchResourceMappings(); List<Link> links = new ArrayList<Link>(); links.add(new Link(ProfileController.getPath(this.config, metadata), ProfileResourceProcessor.PROFILE_REL)); if (searchMappings.isExported()) { links.add(entityLinks.linkFor(metadata.getDomainType()).slash(searchMappings.getPath()) .withRel(searchMappings.getRel())); } return links; }
/** * Returns the link to to the paged colelction resource for the given type, pre-expanding the * * @param type must not be {@literal null}. * @param pageable the pageable to can be {@literal null}. * @return */ public Link linkToPagedResource(Class<?> type, Pageable pageable) { ResourceMetadata metadata = mappings.getMetadataFor(type); String href = linkFor(type).toString(); UriComponents components = prepareUri(href, metadata, pageable); TemplateVariables variables = getTemplateVariables(components, metadata, pageable).// concat(getProjectionVariable(type)); return new Link(new UriTemplate(href, variables), metadata.getRel()); }
@Override public Link linkToSingleResource(Class<?> type, Object id) { Assert.isInstanceOf(Serializable.class, id, "Id must be assignable to Serializable!"); ResourceMetadata metadata = mappings.getMetadataFor(type); String mappedId = idConverters.getPluginFor(type)// .orElse(DefaultIdConverter.INSTANCE)// .toRequestId((Serializable) id, type); Link link = linkFor(type).slash(mappedId).withRel(metadata.getItemResourceRel()); return new Link(new UriTemplate(link.getHref(), getProjectionVariable(type)).toString(), metadata.getItemResourceRel()); }
@Override public void doWithAssociation(Association<? extends PersistentProperty<?>> association) { PersistentProperty<?> property = association.getInverse(); if (!jackson.isExported(property) || !associations.isLinkableAssociation(property)) { return; } ResourceMapping mapping = metadata.getMappingFor(property); DescriptorBuilder builder = descriptor().// name(mapping.getRel()).doc(getDocFor(mapping.getDescription())); ResourceMetadata targetTypeMetadata = associations.getMetadataFor(property.getActualType()); String href = ProfileController.getPath(configuration, targetTypeMetadata) + "#" + getRepresentationDescriptorId(targetTypeMetadata); Link link = new Link(href).withSelfRel(); builder.// type(Type.SAFE).// rt(link.getHref()); propertyDescriptors.add(builder.build()); } });