#793 - Switch from @Order to Ordered.
This commit is contained in:
@@ -18,19 +18,24 @@ package org.springframework.hateoas.core;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.annotation.AnnotationUtils;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.hateoas.RelProvider;
|
||||
|
||||
/**
|
||||
* @author Oliver Gierke
|
||||
* @author Alexander Baetz
|
||||
* @author Greg Turnquist
|
||||
*/
|
||||
@Order(100)
|
||||
public class AnnotationRelProvider implements RelProvider {
|
||||
public class AnnotationRelProvider implements RelProvider, Ordered {
|
||||
|
||||
private final Map<Class<?>, Relation> annotationCache = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return 100;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.hateoas.RelProvider#getRelForCollectionResource(java.lang.Class)
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
package org.springframework.hateoas.core;
|
||||
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.hateoas.RelProvider;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -25,11 +24,16 @@ import org.springframework.util.StringUtils;
|
||||
* single resource rel as well as an appended {@code List} for the collection resource rel.
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
* @author Greg Turnquist
|
||||
*/
|
||||
@Order(Ordered.LOWEST_PRECEDENCE)
|
||||
public class DefaultRelProvider implements RelProvider {
|
||||
public class DefaultRelProvider implements RelProvider, Ordered {
|
||||
|
||||
/*
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return Ordered.LOWEST_PRECEDENCE;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.plugin.core.Plugin#supports(java.lang.Object)
|
||||
*/
|
||||
|
||||
@@ -20,7 +20,7 @@ import static org.assertj.core.api.Assertions.*;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.hateoas.core.JsonPathLinkDiscoverer;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.plugin.core.OrderAwarePluginRegistry;
|
||||
@@ -30,6 +30,7 @@ import org.springframework.plugin.core.PluginRegistry;
|
||||
* Unit tests for {@link LinkDiscoverers}.
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
* @author Greg Turnquist
|
||||
*/
|
||||
public class LinkDiscoverersUnitTest {
|
||||
|
||||
@@ -48,16 +49,24 @@ public class LinkDiscoverersUnitTest {
|
||||
assertThat(registry.getRequiredPluginFor(MediaType.APPLICATION_JSON)).isEqualTo(high);
|
||||
}
|
||||
|
||||
@Order(20)
|
||||
static class LowPriorityLinkDiscoverer extends JsonPathLinkDiscoverer {
|
||||
static class LowPriorityLinkDiscoverer extends JsonPathLinkDiscoverer implements Ordered {
|
||||
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return 20;
|
||||
}
|
||||
|
||||
public LowPriorityLinkDiscoverer() {
|
||||
super("$.links.%s", MediaType.APPLICATION_JSON);
|
||||
}
|
||||
}
|
||||
|
||||
@Order(10)
|
||||
static class HighPriorityLinkDiscoverer extends JsonPathLinkDiscoverer {
|
||||
static class HighPriorityLinkDiscoverer extends JsonPathLinkDiscoverer implements Ordered {
|
||||
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return 10;
|
||||
}
|
||||
|
||||
public HighPriorityLinkDiscoverer() {
|
||||
super("$.links.%s", MediaType.APPLICATION_JSON);
|
||||
|
||||
@@ -21,8 +21,8 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.ResolvableType;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.hateoas.AffordanceModel;
|
||||
import org.springframework.hateoas.Link;
|
||||
import org.springframework.hateoas.QueryParameter;
|
||||
@@ -50,8 +50,12 @@ public class SpringMvcAffordanceBuilderUnitTest {
|
||||
assertThat(registry.getPluginFor(MediaType.APPLICATION_JSON).get()).isEqualTo(high);
|
||||
}
|
||||
|
||||
@Order(20)
|
||||
static class LowPriorityModelFactory implements AffordanceModelFactory {
|
||||
static class LowPriorityModelFactory implements AffordanceModelFactory, Ordered {
|
||||
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return 20;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AffordanceModel getAffordanceModel(String name, Link link, HttpMethod httpMethod, ResolvableType inputType, List<QueryParameter> queryMethodParameters, ResolvableType outputType) {
|
||||
@@ -64,8 +68,12 @@ public class SpringMvcAffordanceBuilderUnitTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Order(10)
|
||||
static class HighPriorityModelFactory implements AffordanceModelFactory {
|
||||
static class HighPriorityModelFactory implements AffordanceModelFactory, Ordered {
|
||||
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return 10;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AffordanceModel getAffordanceModel(String name, Link link, HttpMethod httpMethod, ResolvableType inputType, List<QueryParameter> queryMethodParameters, ResolvableType outputType) {
|
||||
|
||||
Reference in New Issue
Block a user