Package org.springframework.data.rest.core

Examples of org.springframework.data.rest.core.Path


  @Override
  public Path getPath() {

    String path = annotation == null ? null : annotation.path().trim();
    path = StringUtils.hasText(path) ? path : getDefaultPathFor(type);
    return new Path(path);
  }
View Full Code Here


     * (non-Javadoc)
     * @see org.springframework.data.rest.core.mapping.ResourceMapping#getPath()
     */
    @Override
    public Path getPath() {
      return annotation != null && StringUtils.hasText(annotation.path()) ? new Path(annotation.path()) : new Path(
          property.getName());
    }
View Full Code Here

   */
  public Method getMappedMethod(String path) {

    Assert.hasText(path, "Path must not be null or empty!");

    MethodResourceMapping mapping = mappings.get(new Path(path));
    return mapping == null ? null : mapping.getMethod();
  }
View Full Code Here

   * @see org.springframework.data.rest.core.mapping.ResourceMapping#getPath()
   */
  @Override
  public Path getPath() {

    Path fallback = domainTypeMapping.getPath();

    if (repositoryAnnotation != null) {
      String path = repositoryAnnotation.path();
      return StringUtils.hasText(path) ? new Path(path) : fallback;
    }

    if (annotation != null) {
      String path = annotation.path();
      return StringUtils.hasText(path) ? new Path(path) : fallback;
    }

    return fallback;
  }
View Full Code Here

    RestResource annotation = AnnotationUtils.findAnnotation(method, RestResource.class);
    String resourceRel = resourceMapping.getRel();

    this.isExported = annotation != null ? annotation.exported() : true;
    this.rel = annotation == null || !StringUtils.hasText(annotation.rel()) ? method.getName() : annotation.rel();
    this.path = annotation == null || !StringUtils.hasText(annotation.path()) ? new Path(method.getName()) : new Path(
        annotation.path());
    this.method = method;
    this.parameterMetadata = discoverParameterMetadata(method, resourceRel.concat(".").concat(rel));

    List<Class<?>> parameterTypes = Arrays.asList(method.getParameterTypes());
View Full Code Here

    ResourceMetadata metadata = mappings.getMappingFor(Person.class);
    ResourceMapping mapping = metadata.getMappingFor(property);

    assertThat(mapping.getRel(), is("siblings"));
    assertThat(mapping.getPath(), is(new Path("siblings")));
    assertThat(mapping.isExported(), is(true));
  }
View Full Code Here

    assertThat(mappings.exportsTopLevelResourceFor("people"), is(true));
    assertThat(mappings.exportsTopLevelResourceFor("orders"), is(true));

    ResourceMetadata creditCardMapping = mappings.getMappingFor(CreditCard.class);
    assertThat(creditCardMapping, is(notNullValue()));
    assertThat(creditCardMapping.getPath(), is(new Path("creditCards")));
    assertThat(creditCardMapping.isExported(), is(false));
    assertThat(mappings.exportsTopLevelResourceFor("creditCards"), is(false));
  }
View Full Code Here

  @Test
  public void defaultsMappingsByType() {

    CollectionResourceMapping mapping = new TypeBasedCollectionResourceMapping(Sample.class);

    assertThat(mapping.getPath(), is(new Path("sample")));
    assertThat(mapping.getRel(), is("samples"));
    assertThat(mapping.getItemResourceRel(), is("sample"));
    assertThat(mapping.isExported(), is(true));
  }
View Full Code Here

  @Test
  public void usesCustomizedRel() {

    CollectionResourceMapping mapping = new TypeBasedCollectionResourceMapping(CustomizedSample.class);

    assertThat(mapping.getPath(), is(new Path("customizedSample")));
    assertThat(mapping.getRel(), is("myRel"));
    assertThat(mapping.getItemResourceRel(), is("customizedSample"));
    assertThat(mapping.isExported(), is(true));
  }
View Full Code Here

  @Test
  public void buildsDefaultMappingForRepository() {

    CollectionResourceMapping mapping = getResourceMappingFor(PersonRepository.class);

    assertThat(mapping.getPath(), is(new Path("persons")));
    assertThat(mapping.getRel(), is("persons"));
    assertThat(mapping.getItemResourceRel(), is("person"));
    assertThat(mapping.isExported(), is(true));
  }
View Full Code Here

TOP

Related Classes of org.springframework.data.rest.core.Path

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.