// In a page constructor add(new Link("link") { public void onClick() { setVisible(false); } });
public InitializrMetadataV21JsonMapper() { this.dependenciesVariables = new TemplateVariables(new TemplateVariable( "bootVersion", TemplateVariable.VariableType.REQUEST_PARAM)); }
private ObjectNode dependenciesLink(String appUrl) { String uri = (appUrl != null) ? appUrl + "/dependencies" : "/dependencies"; UriTemplate uriTemplate = new UriTemplate(uri, this.dependenciesVariables); ObjectNode result = nodeFactory().objectNode(); result.put("href", uriTemplate.toString()); result.put("templated", true); return result; }
@Override public Resource<Order> process(Resource<Order> resource) { Order order = resource.getContent(); if (!order.isPaid()) { resource.add(entityLinks.linkForSingleResource(order).withRel(CANCEL_REL)); resource.add(entityLinks.linkForSingleResource(order).withRel(UPDATE_REL)); } return resource; } }
/** * Looks up the stores in the given distance around the given location. * * @param model the {@link Model} to populate. * @param location the optional location, if none is given, no search results will be returned. * @param distance the distance to use, if none is given the {@link #DEFAULT_DISTANCE} is used. * @param pageable the pagination information * @return */ @RequestMapping(value = "/", method = RequestMethod.GET) String index(Model model, @RequestParam Optional<Point> location, @RequestParam Optional<Distance> distance, Pageable pageable) { Point point = location.orElse(KNOWN_LOCATIONS.get("Timesquare NY")); Page<Store> stores = repository.findByAddressLocationNear(point, distance.orElse(DEFAULT_DISTANCE), pageable); model.addAttribute("stores", stores); model.addAttribute("distances", DISTANCES); model.addAttribute("selectedDistance", distance.orElse(DEFAULT_DISTANCE)); model.addAttribute("location", point); model.addAttribute("locations", KNOWN_LOCATIONS); model.addAttribute("api", entityLinks.linkToSearchResource(Store.class, "by-location", pageable).getHref()); return "index"; } }
/** * Returns the {@link Link} to point to the {@link Payment} for the given {@link Order}. * * @param order must not be {@literal null}. * @return */ Link getPaymentLink(Order order) { return entityLinks.linkForSingleResource(order).slash(PAYMENT).withRel(PAYMENT_REL); }
private UriTemplate getUriTemplate() { if (template == null) { this.template = new UriTemplate(href); } return template; }
/** * Creates a new {@link UriTemplate} with a {@link TemplateVariable} with the given name and type added. * * @param variableName must not be {@literal null} or empty. * @param type must not be {@literal null}. * @return will never be {@literal null}. */ public UriTemplate with(String variableName, TemplateVariable.VariableType type) { return with(new TemplateVariables(new TemplateVariable(variableName, type))); }
/** * Convenience method when chaining an existing {@link Link}. * * @param name * @param httpMethod * @param inputType * @param queryMethodParameters * @param outputType * @return */ public Link andAffordance(String name, HttpMethod httpMethod, ResolvableType inputType, List<QueryParameter> queryMethodParameters, ResolvableType outputType) { return andAffordance(new Affordance(name, this, httpMethod, inputType, queryMethodParameters, outputType)); }
/** * Creates a new {@link VndErrors} instance containing a single {@link VndError} with the given logref, message and * optional {@link Link}s. * * @param logref must not be {@literal null} or empty. * @param message must not be {@literal null} or empty. * @param links */ public VndErrors(String logref, String message, Link... links) { this(new VndError(logref, message, links)); }
/** * Returns whether the given {@link TemplateVariable} is of the same type as the current one. * * @param variable must not be {@literal null}. * @return */ boolean isCombinable(TemplateVariable variable) { return this.type.canBeCombinedWith(variable.type); }
/** * Returns whether the template variable is optional, which means the template can be expanded to a URI without a * value given for that variable. * * @return */ boolean isRequired() { return !type.isOptional(); }
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; } }
/** * Returns the {@link Link} to the {@link Receipt} of the given {@link Order}. * * @param order * @return */ Link getReceiptLink(Order order) { return entityLinks.linkForSingleResource(order).slash(RECEIPT).withRel(RECEIPT_REL); } }
private String generateTemplatedUri(String appUrl, Type type) { String uri = (appUrl != null) ? appUrl + type.getAction() : type.getAction(); uri = uri + "?type=" + type.getId(); UriTemplate uriTemplate = new UriTemplate(uri, this.templateVariables); return uriTemplate.toString(); }
public InitializrMetadataV2JsonMapper() { this.templateVariables = new TemplateVariables( new TemplateVariable("dependencies", TemplateVariable.VariableType.REQUEST_PARAM), new TemplateVariable("packaging", TemplateVariable.VariableType.REQUEST_PARAM), new TemplateVariable("javaVersion", TemplateVariable.VariableType.REQUEST_PARAM), new TemplateVariable("language", TemplateVariable.VariableType.REQUEST_PARAM), new TemplateVariable("bootVersion", TemplateVariable.VariableType.REQUEST_PARAM), new TemplateVariable("groupId", TemplateVariable.VariableType.REQUEST_PARAM), new TemplateVariable("artifactId", TemplateVariable.VariableType.REQUEST_PARAM), new TemplateVariable("version", TemplateVariable.VariableType.REQUEST_PARAM), new TemplateVariable("name", TemplateVariable.VariableType.REQUEST_PARAM), new TemplateVariable("description", TemplateVariable.VariableType.REQUEST_PARAM), new TemplateVariable("packageName", TemplateVariable.VariableType.REQUEST_PARAM)); }