Package org.springframework.hateoas.alps.Descriptor

Examples of org.springframework.hateoas.alps.Descriptor.DescriptorBuilder


      public void doWithAssociation(Association<? extends PersistentProperty<?>> association) {

        PersistentProperty<?> property = association.getInverse();
        ResourceMapping mapping = propertyMappings.getMappingFor(property);

        DescriptorBuilder builder = descriptor().//
            name(mapping.getRel()).doc(getDocFor(mapping.getDescription()));

        if (associationLinks.isLinkableAssociation(property)) {

          ResourceMetadata targetTypeMapping = mappings.getMappingFor(property.getActualType());
          String localPath = targetTypeMapping.getRel().concat("#").concat(targetTypeMapping.getItemResourceRel());
          Link link = ControllerLinkBuilder.linkTo(AlpsController.class).slash(localPath).withSelfRel();

          builder.//
              type(Type.SAFE).//
              rt(link.getHref());

        } else {

          List<Descriptor> nestedDescriptors = buildPropertyDescriptors(property.getActualType(), baseRel.concat(".")
              .concat(mapping.getRel()));

          builder = builder.//
              type(Type.SEMANTIC).//
              descriptors(nestedDescriptors);
        }

        propertyDescriptors.add(builder.build());
      }
    });

    return propertyDescriptors;
  }
View Full Code Here

TOP

Related Classes of org.springframework.hateoas.alps.Descriptor.DescriptorBuilder

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.