Example usage for org.springframework.data.rest.core.mapping TypedResourceDescription defaultFor

List of usage examples for org.springframework.data.rest.core.mapping TypedResourceDescription defaultFor

Introduction

In this page you can find the example usage for org.springframework.data.rest.core.mapping TypedResourceDescription defaultFor.

Prototype

public static ResourceDescription defaultFor(LinkRelation rel, String name, Class<?> type) 

Source Link

Usage

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

/**
 * Returns the fallback {@link ResourceDescription} to be used for the given {@link BeanPropertyDefinition}.
 * /* w ww  .  ja  v  a 2s . c  o  m*/
 * @param ownerMetadata must not be {@literal null}.
 * @param definition must not be {@literal null}.
 * @return
 */
public ResourceDescription getFallbackDescription(ResourceMetadata ownerMetadata,
        BeanPropertyDefinition definition) {

    Assert.notNull(ownerMetadata, "Owner's resource metadata must not be null!");
    Assert.notNull(definition, "BeanPropertyDefinition must not be null!");

    AnnotatedMember member = definition.getPrimaryMember();
    Description description = member.getAnnotation(Description.class);
    ResourceDescription fallback = TypedResourceDescription.defaultFor(ownerMetadata.getItemResourceRel(),
            definition.getInternalName(), definition.getPrimaryMember().getRawType());

    return description == null ? fallback : new AnnotationBasedResourceDescription(description, fallback);
}