Example usage for org.springframework.hateoas Link getVariables

List of usage examples for org.springframework.hateoas Link getVariables

Introduction

In this page you can find the example usage for org.springframework.hateoas Link getVariables.

Prototype

@JsonIgnore
public List<TemplateVariable> getVariables() 

Source Link

Document

Returns all TemplateVariables contained in the Link .

Usage

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

/**
 * Creates the {@link Descriptor}s for pagination parameters.
 * /*from  w  w  w  .  j a  va 2  s.c  o m*/
 * @param type
 * @return
 */
private List<Descriptor> getPaginationDescriptors(Class<?> type, HttpMethod method) {

    RepositoryInformation information = repositories.getRepositoryInformationFor(type);

    if (!information.isPagingRepository() || !getType(method).equals(Type.SAFE)) {
        return Collections.emptyList();
    }

    Link linkToCollectionResource = entityLinks.linkToCollectionResource(type);
    List<TemplateVariable> variables = linkToCollectionResource.getVariables();
    List<Descriptor> descriptors = new ArrayList<Descriptor>(variables.size());

    ProjectionDefinitionConfiguration projectionConfiguration = configuration.getProjectionConfiguration();

    for (TemplateVariable variable : variables) {

        // Skip projection parameter
        if (projectionConfiguration.getParameterName().equals(variable.getName())) {
            continue;
        }

        ResourceDescription description = SimpleResourceDescription.defaultFor(variable.getDescription());

        descriptors.add(//
                descriptor().//
                        name(variable.getName()).//
                        type(Type.SEMANTIC).//
                        doc(getDocFor(description)).//
                        build());
    }

    return descriptors;
}