Example usage for org.springframework.hateoas UriTemplate UriTemplate

List of usage examples for org.springframework.hateoas UriTemplate UriTemplate

Introduction

In this page you can find the example usage for org.springframework.hateoas UriTemplate UriTemplate.

Prototype

@Deprecated
public UriTemplate(String template) 

Source Link

Document

Creates a new UriTemplate using the given template string.

Usage

From source file:com.github.hateoas.forms.affordance.Affordance.java

/**
 * Expands template variables, arguments must satisfy all required template variables, optional variables will be removed.
 *
 * @param arguments to expansion in the order they appear in the template
 * @return expanded affordance//from  w ww  . jav  a  2 s.  c o  m
 */
@Override
public Affordance expand(final Object... arguments) {
    UriTemplate template = new UriTemplate(partialUriTemplate.asComponents().toString());
    String expanded = template.expand(arguments).toASCIIString();
    return new Affordance(expanded, linkParams, actionDescriptors);
}

From source file:de.escalon.hypermedia.affordance.Affordance.java

/**
 * Expands template variables, arguments must satisfy all required template variables, unsatisfied optional
 * arguments will be removed./*  www . j a  va  2  s.co m*/
 *
 * @param arguments
 *         to expansion
 * @return expanded affordance
 */
@Override
public Affordance expand(Map<String, ? extends Object> arguments) {
    UriTemplate template = new UriTemplate(partialUriTemplate.asComponents().toString());
    String expanded = template.expand(arguments).toASCIIString();
    return new Affordance(expanded, linkParams, actionDescriptors);
}

From source file:com.github.hateoas.forms.affordance.Affordance.java

/**
 * Expands template variables, arguments must satisfy all required template variables, unsatisfied optional arguments will be removed.
 *
 * @param arguments to expansion//from   w w  w.j a v  a  2s .  c o m
 * @return expanded affordance
 */
@Override
public Affordance expand(final Map<String, ? extends Object> arguments) {
    UriTemplate template = new UriTemplate(partialUriTemplate.asComponents().toString());
    String expanded = template.expand(arguments).toASCIIString();
    return new Affordance(expanded, linkParams, actionDescriptors);
}

From source file:org.springframework.boot.actuate.hypermedia.autoconfigure.EndpointHypermediaAutoConfiguration.java

@Bean
@ConditionalOnBean(ActuatorDocsEndpoint.class)
@ConditionalOnMissingBean(CurieProvider.class)
@ConditionalOnProperty(value = "endpoints.docs.curies.enabled", matchIfMissing = false)
public DefaultCurieProvider curieProvider(ServerProperties server, ManagementServerProperties management,
        ActuatorDocsEndpoint endpoint) {
    String path = management.getContextPath() + endpoint.getPath() + "/#spring_boot_actuator__{rel}";
    if (server.getPort() == management.getPort() && management.getPort() != null && management.getPort() != 0) {
        path = server.getPath(path);// w w  w  .ja v a  2  s . c  o m
    }
    return new DefaultCurieProvider("boot", new UriTemplate(path));
}

From source file:org.springframework.data.rest.webmvc.json.PersistentEntityJackson2ModuleUnitTests.java

/**
 * @see DATAREST-662/* w  ww .j  av  a  2s  .  co m*/
 */
@Test
public void resolvesReferenceToSubtypeCorrectly() throws IOException {

    PersistentProperty<?> property = persistentEntities.getPersistentEntity(PetOwner.class)
            .getPersistentProperty("pet");

    when(associations.isLinkableAssociation(property)).thenReturn(true);
    when(converter.convert(new UriTemplate("/pets/1").expand(), TypeDescriptor.valueOf(URI.class),
            TypeDescriptor.valueOf(Pet.class))).thenReturn(new Cat());

    PetOwner petOwner = mapper.readValue("{\"pet\":\"/pets/1\"}", PetOwner.class);

    assertThat(petOwner, is(notNullValue()));
    assertThat(petOwner.getPet(), is(notNullValue()));
}

From source file:org.springframework.hateoas.hal.Jackson2HalIntegrationTest.java

/**
 * @see #142//from  w  w  w  .  jav a2 s. co m
 */
@Test
public void rendersMultipleCuries() throws Exception {

    Resources<Object> resources = new Resources<Object>(Collections.emptySet());
    resources.add(new Link("foo", "myrel"));

    CurieProvider provider = new DefaultCurieProvider("default", new UriTemplate("/doc{?rel}")) {
        @Override
        public Collection<? extends Object> getCurieInformation(Links links) {
            return Arrays.asList(new Curie("foo", "bar"), new Curie("bar", "foo"));
        }
    };

    assertThat(getCuriedObjectMapper(provider).writeValueAsString(resources), is(MULTIPLE_CURIES_DOCUMENT));
}

From source file:org.springframework.hateoas.hal.Jackson2HalIntegrationTest.java

private static ObjectMapper getCuriedObjectMapper() {

    return getCuriedObjectMapper(
            new DefaultCurieProvider("foo", new UriTemplate("http://localhost:8080/rels/{rel}")));
}

From source file:org.springframework.hateoas.Link.java

/**
 * Creates a new {@link Link} to the given URI with the given rel.
 *
 * @param href must not be {@literal null} or empty.
 * @param rel must not be {@literal null} or empty.
 *//*  ww  w  . j  a  v a 2 s.  co m*/
public Link(String href, String rel) {
    this(new UriTemplate(href), rel);
}

From source file:org.springframework.hateoas.Link.java

/**
 * Creates a new {@link Link} to the given URI with the given rel and the given profile.
 *
 * @param href must not be {@literal null} or empty.
 * @param rel must not be {@literal null} or empty.
 * @param profile must not be {@literal null} or empty.
 *///from   w w w  .j  av  a2  s.  c  o m
public Link(String href, String rel, String profile) {
    this(new UriTemplate(href), rel, profile);
}

From source file:org.springframework.hateoas.Link.java

/**
 * Creates a new {@link Link} to the given URI with the given rel and the given profile and name.
 *
 * @param href must not be {@literal null} or empty.
 * @param rel must not be {@literal null} or empty.
 * @param profile must not be {@literal null} or empty.
 * @param name//  ww w  .  j a  va 2 s .c o m
 */
public Link(String href, String rel, String profile, String name) {
    this(new UriTemplate(href), rel, profile, name);
}