Skip to content

Commit fd132c9

Browse files
committed
[spring-projects#1300] Fix several test switching generics order
1 parent cb39ff5 commit fd132c9

File tree

8 files changed

+13
-20
lines changed

8 files changed

+13
-20
lines changed

src/main/java/org/springframework/hateoas/AbstractCollectionModel.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,18 @@
2020
import org.springframework.util.Assert;
2121

2222
import java.util.ArrayList;
23-
import java.util.Arrays;
2423
import java.util.Collection;
2524
import java.util.Collections;
2625
import java.util.Iterator;
2726
import java.util.Objects;
28-
import java.util.function.Supplier;
2927

3028
/**
3129
* General helper to easily create a wrapper for a collection of entities.
3230
*
3331
* @author Oliver Gierke
3432
* @author Greg Turnquist
3533
*/
36-
public class AbstractCollectionModel<S extends AbstractCollectionModel<S,T>, T> extends RepresentationModel<S> implements Iterable<T> {
34+
public class AbstractCollectionModel<T, S extends AbstractCollectionModel<T, S>> extends RepresentationModel<S> implements Iterable<T> {
3735

3836
private final Collection<T> content;
3937

@@ -98,7 +96,7 @@ public boolean equals(@Nullable Object obj) {
9896
return false;
9997
}
10098

101-
AbstractCollectionModel<?, ?> that = (AbstractCollectionModel<?,?>) obj;
99+
AbstractCollectionModel<?, ?> that = (AbstractCollectionModel<?, ?>) obj;
102100
return Objects.equals(this.content, that.content);
103101
}
104102

src/main/java/org/springframework/hateoas/CollectionModel.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,17 @@
1717

1818
import java.util.ArrayList;
1919
import java.util.Arrays;
20-
import java.util.Collection;
2120
import java.util.Collections;
22-
import java.util.Iterator;
2321

24-
import org.springframework.lang.Nullable;
2522
import org.springframework.util.Assert;
2623

27-
import com.fasterxml.jackson.annotation.JsonProperty;
28-
2924
/**
3025
* General helper to easily create a wrapper for a collection of entities.
3126
*
3227
* @author Oliver Gierke
3328
* @author Greg Turnquist
3429
*/
35-
public class CollectionModel<T> extends AbstractCollectionModel<CollectionModel<T>, T> implements Iterable<T> {
30+
public class CollectionModel<T> extends AbstractCollectionModel<T, CollectionModel<T>> implements Iterable<T> {
3631

3732
/**
3833
* Creates an empty {@link CollectionModel} instance.

src/main/java/org/springframework/hateoas/PagedModel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
* @author Oliver Gierke
3535
* @author Greg Turnquist
3636
*/
37-
public class PagedModel<T> extends AbstractCollectionModel<PagedModel<T>, T> {
37+
public class PagedModel<T> extends AbstractCollectionModel<T, PagedModel<T>> {
3838

3939
public static PagedModel<?> NO_PAGE = new PagedModel<>();
4040

src/main/java/org/springframework/hateoas/mediatype/collectionjson/Jackson2CollectionJsonModule.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -915,7 +915,7 @@ private CollectionJsonPagedResourcesDeserializer(JavaType contentType) {
915915
}
916916
}
917917

918-
private static List<CollectionJsonItem<Object>> resourcesToCollectionJsonItems(AbstractCollectionModel<?,?> resources) {
918+
private static List<CollectionJsonItem<Object>> resourcesToCollectionJsonItems(AbstractCollectionModel<?, ?> resources) {
919919

920920
return resources.getContent().stream().map(content -> {
921921

src/main/java/org/springframework/hateoas/mediatype/hal/forms/HalFormsSerializers.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ public JsonSerializer<?> createContextual(SerializerProvider prov, BeanProperty
210210
/**
211211
* Serializer for {@link CollectionModel}
212212
*/
213-
static class HalFormsCollectionModelSerializer extends ContainerSerializer<AbstractCollectionModel<?,?>>
213+
static class HalFormsCollectionModelSerializer extends ContainerSerializer<AbstractCollectionModel<?, ?>>
214214
implements ContextualSerializer {
215215

216216
private static final long serialVersionUID = -3601146866067500734L;
@@ -243,7 +243,7 @@ static class HalFormsCollectionModelSerializer extends ContainerSerializer<Abstr
243243
*/
244244
@Override
245245
@SuppressWarnings("null")
246-
public void serialize(AbstractCollectionModel<?,?> value, JsonGenerator gen, SerializerProvider provider) throws IOException {
246+
public void serialize(AbstractCollectionModel<?, ?> value, JsonGenerator gen, SerializerProvider provider) throws IOException {
247247

248248
EmbeddedMapper mapper = configuration.isApplyPropertyNamingStrategy() //
249249
? embeddedMapper.with(provider.getConfig().getPropertyNamingStrategy()) //
@@ -298,7 +298,7 @@ public JsonSerializer<?> getContentSerializer() {
298298
*/
299299
@Override
300300
@SuppressWarnings("null")
301-
public boolean hasSingleElement(AbstractCollectionModel<?,?> resources) {
301+
public boolean hasSingleElement(AbstractCollectionModel<?, ?> resources) {
302302
return resources.getContent().size() == 1;
303303
}
304304

src/main/java/org/springframework/hateoas/mediatype/uber/UberData.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ static List<UberData> extractLinksAndContent(EntityModel<?> resource) {
204204
* @param resources
205205
* @return
206206
*/
207-
private static List<UberData> extractLinksAndCollectionContent(AbstractCollectionModel<?,?> resources) {
207+
private static List<UberData> extractLinksAndCollectionContent(AbstractCollectionModel<?, ?> resources) {
208208

209209
List<UberData> data = extractLinks(resources);
210210

src/main/java/org/springframework/hateoas/server/mvc/RepresentationModelProcessorInvoker.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ public boolean supports(ResolvableType type, Object value) {
385385
* @return
386386
*/
387387

388-
static boolean isValueTypeMatch(@Nullable AbstractCollectionModel<?,?> collectionModel, ResolvableType target) {
388+
static boolean isValueTypeMatch(@Nullable AbstractCollectionModel<?, ?> collectionModel, ResolvableType target) {
389389

390390
if (collectionModel == null) {
391391
return false;
@@ -413,7 +413,7 @@ static boolean isValueTypeMatch(@Nullable AbstractCollectionModel<?,?> collectio
413413
}
414414

415415
Object element = content.iterator().next();
416-
ResolvableType resourceType = superType.getGeneric(1);
416+
ResolvableType resourceType = superType.getGeneric(0);
417417

418418
if (element instanceof EntityModel) {
419419
return EntityModelProcessorWrapper.isValueTypeMatch((EntityModel<?>) element, resourceType);

src/test/java/org/springframework/hateoas/mediatype/uber/Jackson2UberIntegrationTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -538,13 +538,13 @@ void handleTemplatedLinksOnDeserialization() throws IOException {
538538
assertThat(deserialized).isEqualTo(original);
539539
}
540540

541-
private static AbstractCollectionModel<?, EntityModel<Employee>> setupAnnotatedPagedResources() {
541+
private static AbstractCollectionModel<EntityModel<Employee>, ?> setupAnnotatedPagedResources() {
542542

543543
return setupAnnotatedPagedResources(2, 4);
544544
}
545545

546546
@NotNull
547-
private static AbstractCollectionModel<?, EntityModel<Employee>> setupAnnotatedPagedResources(int size, int totalElements) {
547+
private static AbstractCollectionModel<EntityModel<Employee>, ?> setupAnnotatedPagedResources(int size, int totalElements) {
548548

549549
List<EntityModel<Employee>> content = new ArrayList<>();
550550
Employee employee = new Employee("Frodo", "ring bearer");

0 commit comments

Comments
 (0)