Example usage for org.springframework.data.rest.core.mapping SupportedHttpMethods getMethodsFor

List of usage examples for org.springframework.data.rest.core.mapping SupportedHttpMethods getMethodsFor

Introduction

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

Prototype

HttpMethods getMethodsFor(PersistentProperty<?> property);

Source Link

Document

Returns the supported HttpMethod s for the given PersistentProperty .

Usage

From source file:org.springframework.data.rest.webmvc.alps.RootResourceInformationToAlpsDescriptorConverter.java

public Alps convert(RootResourceInformation resourceInformation) {

    Class<?> type = resourceInformation.getDomainType();
    List<Descriptor> descriptors = new ArrayList<Descriptor>();

    Descriptor representationDescriptor = buildRepresentationDescriptor(type);

    descriptors.add(representationDescriptor);

    SupportedHttpMethods supportedHttpMethods = resourceInformation.getSupportedMethods();

    for (HttpMethod method : supportedHttpMethods.getMethodsFor(ResourceType.COLLECTION)) {

        if (!UNDOCUMENTED_METHODS.contains(method)) {
            descriptors.add(buildCollectionResourceDescriptor(type, resourceInformation,
                    representationDescriptor, method));
        }//  w ww  .ja  va2 s .  com
    }

    for (HttpMethod method : supportedHttpMethods.getMethodsFor(ResourceType.ITEM)) {

        if (!UNDOCUMENTED_METHODS.contains(method)) {
            descriptors.add(buildItemResourceDescriptor(resourceInformation, representationDescriptor, method));
        }
    }

    descriptors.addAll(buildSearchResourceDescriptors(resourceInformation.getPersistentEntity()));

    return Alps.alps().descriptors(descriptors).build();
}