Examples of PropertyMappings


Examples of org.springframework.data.rest.webmvc.mapping.PropertyMappings

  private List<Descriptor> buildPropertyDescriptors(Class<?> type, final String baseRel) {

    PersistentEntity<?, ?> entity = persistentEntities.getPersistentEntity(type);
    final List<Descriptor> propertyDescriptors = new ArrayList<Descriptor>();
    final JacksonMetadata jackson = new JacksonMetadata(mapper, type);
    final PropertyMappings propertyMappings = new PropertyMappings(mappings);
    final AssociationLinks associationLinks = new AssociationLinks(mappings);

    entity.doWithProperties(new SimplePropertyHandler() {

      @Override
      public void doWithPersistentProperty(PersistentProperty<?> property) {

        BeanPropertyDefinition propertyDefinition = jackson.getDefinitionFor(property);
        ResourceMapping propertyMapping = propertyMappings.getMappingFor(property);

        if (propertyDefinition != null) {
          propertyDescriptors.add(//
              descriptor(). //
                  type(Type.SEMANTIC).//
                  name(propertyDefinition.getName()).//
                  doc(getDocFor(propertyMapping.getDescription())).//
                  build());
        }
      }
    });

    entity.doWithAssociations(new SimpleAssociationHandler() {

      @Override
      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)) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.