From c3dcdf1b9ec2f71bb375001d2a9d05c579d7de18 Mon Sep 17 00:00:00 2001 From: Oliver Gierke Date: Mon, 2 Mar 2015 12:48:21 +0100 Subject: [PATCH] #306 - Renamed type references types to allow more concise usage. Renamed the Resource, Resources and PagedResources types in TypeReferences to *Type so that new TypeReferences.Resources() {} now becomes new ResourcesType() {}. Prior to this change a static import of TypeReferences would've cause the actual Resource types to be fully qualified. --- .../org/springframework/hateoas/mvc/TypeReferences.java | 9 +++++---- .../hateoas/mvc/TypeReferencesIntegrationTests.java | 8 +++++--- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/springframework/hateoas/mvc/TypeReferences.java b/src/main/java/org/springframework/hateoas/mvc/TypeReferences.java index 2ea7afa0..b352b10d 100644 --- a/src/main/java/org/springframework/hateoas/mvc/TypeReferences.java +++ b/src/main/java/org/springframework/hateoas/mvc/TypeReferences.java @@ -40,7 +40,8 @@ public class TypeReferences { * @author Oliver Gierke * @since 0.17 */ - public static class Resource extends SyntheticParameterizedTypeReference> {} + public static class ResourceType extends + SyntheticParameterizedTypeReference> {} /** * A {@link ParameterizedTypeReference} to return a {@link org.springframework.hateoas.Resources} of some type. @@ -48,7 +49,7 @@ public class TypeReferences { * @author Oliver Gierke * @since 0.17 */ - public static class Resources extends + public static class ResourcesType extends SyntheticParameterizedTypeReference> {} /** @@ -57,7 +58,7 @@ public class TypeReferences { * @author Oliver Gierke * @since 0.17 */ - public static class PagedResources extends + public static class PagedResourcesType extends SyntheticParameterizedTypeReference> {} /** @@ -71,7 +72,7 @@ public class TypeReferences { private final Type type; - @SuppressWarnings("rawtypes") + @SuppressWarnings({ "rawtypes", "deprecation" }) protected SyntheticParameterizedTypeReference() { Class foo = getClass(); diff --git a/src/test/java/org/springframework/hateoas/mvc/TypeReferencesIntegrationTests.java b/src/test/java/org/springframework/hateoas/mvc/TypeReferencesIntegrationTests.java index 19c8ebf6..4cd59890 100644 --- a/src/test/java/org/springframework/hateoas/mvc/TypeReferencesIntegrationTests.java +++ b/src/test/java/org/springframework/hateoas/mvc/TypeReferencesIntegrationTests.java @@ -34,6 +34,8 @@ import org.springframework.hateoas.Resource; import org.springframework.hateoas.Resources; import org.springframework.hateoas.config.EnableHypermediaSupport; import org.springframework.hateoas.config.EnableHypermediaSupport.HypermediaType; +import org.springframework.hateoas.mvc.TypeReferences.ResourceType; +import org.springframework.hateoas.mvc.TypeReferences.ResourcesType; import org.springframework.http.HttpMethod; import org.springframework.http.ResponseEntity; import org.springframework.test.context.ContextConfiguration; @@ -83,7 +85,7 @@ public class TypeReferencesIntegrationTests { server.expect(requestTo("/resource")).andRespond(withSuccess(RESOURCE, MediaTypes.HAL_JSON)); ResponseEntity> response = template.exchange("/resource", HttpMethod.GET, null, - new TypeReferences.Resource() {}); + new ResourceType() {}); assertExpectedUserResource(response.getBody()); } @@ -97,7 +99,7 @@ public class TypeReferencesIntegrationTests { server.expect(requestTo("/resources")).andRespond(withSuccess(RESOURCES_OF_USER, MediaTypes.HAL_JSON)); ResponseEntity> response = template.exchange("/resources", HttpMethod.GET, null, - new TypeReferences.Resources() {}); + new ResourcesType() {}); Resources body = response.getBody(); assertThat(body.hasLink("self"), is(true)); @@ -117,7 +119,7 @@ public class TypeReferencesIntegrationTests { server.expect(requestTo("/resources")).andRespond(withSuccess(RESOURCES_OF_RESOURCE, MediaTypes.HAL_JSON)); ResponseEntity>> response = template.exchange("/resources", HttpMethod.GET, null, - new TypeReferences.Resources>() {}); + new ResourcesType>() {}); Resources> body = response.getBody(); assertThat(body.hasLink("self"), is(true));