/** * Expands template variables as far as possible, unsatisfied variables will remain variables. This is primarily for * manually created affordances. If the Affordance has been created with linkTo-methodOn, it should not be necessary * to expand the affordance again. * * @param arguments for expansion, in the order they appear in the template * @return partially expanded affordance */ public Affordance expandPartially(Object... arguments) { return new Affordance(partialUriTemplate.expand(arguments) .toString(), linkParams, actionDescriptors); }
private Affordance(String uriTemplate, MultiValueMap<String, String> linkParams, List<ActionDescriptor> actionDescriptors) { this(new PartialUriTemplate(uriTemplate), actionDescriptors); // no rels to pass this.linkParams = linkParams; // takes care of rels }
private static List<String> addClassPropertyPaths(List<String> ret, String currentPath, Class<?> clazz) { PropertyDescriptor[] propertyDescriptors = getPropertyDescriptors(clazz); for (PropertyDescriptor propertyDescriptor : propertyDescriptors) { addPropertyPaths(ret, currentPath, propertyDescriptor); } return ret; }
@Test public void testLinkExtensionParams() { final Affordance affordance = new Affordance("http://example.com"); affordance.addLinkParam("name", "name-to-distinguish-links-with-same-rel"); affordance.addLinkParam("deprecation", "http://example.com/why/this/is/deprecated"); affordance.addLinkParam("type", "application/json"); Affordance.DynaBean linkExtensions = affordance.getLinkExtensions(); assertEquals("application/json", affordance.getType()); assertEquals("must only contain link extension params", "{name=name-to-distinguish-links-with-same-rel, " + "deprecation=http://example.com/why/this/is/deprecated}", linkExtensions.toString()); }
@Test public void testPreservesUnexpandedSimpleStringVariables() { final PartialUriTemplate template = new PartialUriTemplate (LAWNMOWER_TEMPLATE_STRING); assertEquals("http://localhost/things/22/widgets?type={widgetType}&redirect=http://example" + ".com/{widgetName}?preorder=true#/order/{widgetId}", template.expand("22") .toString()); }
@Override public String toString() { return partialUriTemplateComponents.toString(); }
@Override public String toString() { return getHeaderName() + ": " + asHeader(); }
@JsonIgnore public boolean isBaseUriTemplated() { return partialUriTemplate.asComponents() .isBaseUriTemplated(); }
@Override public String getDocumentationUrl(ActionInputParameter annotatedParameter, Object content) { return defaultUrlPrefix + annotatedParameter.getParameterName(); }
/** * Concatenates all components to uri String. * * @return uri String */ public String toString() { return baseUri + getQuery() + fragmentIdentifier; }
/** * Expands template variables as far as possible, unsatisfied variables will remain variables. This is primarily for * manually created affordances. If the Affordance has been created with linkTo-methodOn, it should not be necessary * to expand the affordance again. * * @param arguments for expansion, in the order they appear in the template * @return partially expanded affordance */ public Affordance expandPartially(Object... arguments) { return new Affordance(partialUriTemplate.expand(arguments) .toString(), linkParams, actionDescriptors); }
@Override public String toString() { return partialUriTemplateComponents.toString(); }
@Override public String toString() { return getHeaderName() + ": " + asHeader(); }
private Affordance(String uriTemplate, MultiValueMap<String, String> linkParams, List<ActionDescriptor> actionDescriptors) { this(new PartialUriTemplate(uriTemplate), actionDescriptors); // no rels to pass this.linkParams = linkParams; // takes care of rels }
private static List<String> addClassPropertyPaths(List<String> ret, String currentPath, Class<?> clazz) { PropertyDescriptor[] propertyDescriptors = getPropertyDescriptors(clazz); for (PropertyDescriptor propertyDescriptor : propertyDescriptors) { addPropertyPaths(ret, currentPath, propertyDescriptor); } return ret; }
@JsonIgnore public boolean isBaseUriTemplated() { return partialUriTemplate.asComponents() .isBaseUriTemplated(); }
@Override public String getDocumentationUrl(ActionInputParameter annotatedParameter, Object content) { return defaultUrlPrefix + annotatedParameter.getParameterName(); }
/** * Concatenates all components to uri String. * * @return uri String */ public String toString() { return baseUri + getQuery() + fragmentIdentifier; }
/** * Expands template variables as far as possible, unsatisfied variables will remain variables. This is primarily for * manually created affordances. If the Affordance has been created with linkTo-methodOn, it should not be necessary * to expand the affordance again. * * @param arguments for expansion * @return partially expanded affordance */ public Affordance expandPartially(Map<String, ? extends Object> arguments) { return new Affordance(partialUriTemplate.expand((Map<String, Object>) arguments) .toString(), linkParams, actionDescriptors); }
/** * Expands template variables as far as possible, unsatisfied variables will remain variables. This is primarily for * manually created affordances. If the Affordance has been created with linkTo-methodOn, it should not be necessary * to expand the affordance again. * * @param arguments for expansion * @return partially expanded affordance */ public Affordance expandPartially(Map<String, ? extends Object> arguments) { return new Affordance(partialUriTemplate.expand((Map<String, Object>) arguments) .toString(), linkParams, actionDescriptors); }