diff --git a/src/main/java/org/springframework/hateoas/CollectionModel.java b/src/main/java/org/springframework/hateoas/CollectionModel.java index 00047887..d2144586 100644 --- a/src/main/java/org/springframework/hateoas/CollectionModel.java +++ b/src/main/java/org/springframework/hateoas/CollectionModel.java @@ -50,31 +50,11 @@ public class CollectionModel extends RepresentationModel> * Creates an empty {@link CollectionModel} instance. */ protected CollectionModel() { - this(new ArrayList<>()); + this(Collections.emptyList()); } - /** - * Creates a {@link CollectionModel} instance with the given content and {@link Link}s (optional). - * - * @param content must not be {@literal null}. - * @param links the links to be added to the {@link CollectionModel}. - * @deprecated since 1.1, use {@link #of(Iterable, Link...)} instead. - */ - @Deprecated - public CollectionModel(Iterable content, Link... links) { - this(content, Arrays.asList(links)); - } - - /** - * Creates a {@link CollectionModel} instance with the given content and {@link Link}s. - * - * @param content must not be {@literal null}. - * @param links the links to be added to the {@link CollectionModel}. - * @deprecated since 1.1, use {@link #of(Iterable, Iterable)} instead. - */ - @Deprecated - public CollectionModel(Iterable content, Iterable links) { - this(content, links, null); + protected CollectionModel(Iterable content) { + this(content, Links.NONE, null); } protected CollectionModel(Iterable content, Iterable links, @Nullable ResolvableType fallbackType) { @@ -200,7 +180,7 @@ public class CollectionModel extends RepresentationModel> * @see #withFallbackType(ResolvableType) */ public static CollectionModel of(Iterable content, Iterable links) { - return new CollectionModel<>(content, links); + return new CollectionModel<>(content, links, null); } /** diff --git a/src/main/java/org/springframework/hateoas/EntityModel.java b/src/main/java/org/springframework/hateoas/EntityModel.java index 4527a29c..e1567bb8 100644 --- a/src/main/java/org/springframework/hateoas/EntityModel.java +++ b/src/main/java/org/springframework/hateoas/EntityModel.java @@ -57,16 +57,8 @@ public class EntityModel extends RepresentationModel> { this.content = null; } - /** - * Creates a new {@link EntityModel} with the given content and {@link Link}s (optional). - * - * @param content must not be {@literal null}. - * @param links the links to add to the {@link EntityModel}. - * @deprecated since 1.1, use {@link #of(Object, Link...)} instead. - */ - @Deprecated - public EntityModel(T content, Link... links) { - this(content, Arrays.asList(links)); + protected EntityModel(T content) { + this(content, Links.NONE); } /** @@ -74,10 +66,8 @@ public class EntityModel extends RepresentationModel> { * * @param content must not be {@literal null}. * @param links the links to add to the {@link EntityModel}. - * @deprecated since 1.1, use {@link #of(Object, Iterable)} instead. */ - @Deprecated - public EntityModel(T content, Iterable links) { + protected EntityModel(T content, Iterable links) { Assert.notNull(content, "Content must not be null!"); Assert.isTrue(!(content instanceof Collection), "Content must not be a collection! Use CollectionModel instead!"); diff --git a/src/main/java/org/springframework/hateoas/Link.java b/src/main/java/org/springframework/hateoas/Link.java index 57500340..1831633f 100755 --- a/src/main/java/org/springframework/hateoas/Link.java +++ b/src/main/java/org/springframework/hateoas/Link.java @@ -51,70 +51,19 @@ public class Link implements Serializable { public static final String ATOM_NAMESPACE = "http://www.w3.org/2005/Atom"; - /** - * @deprecated Use {@link IanaLinkRelations#SELF} instead. - */ - public static final @Deprecated LinkRelation REL_SELF = IanaLinkRelations.SELF; - - /** - * @deprecated Use {@link IanaLinkRelations#FIRST} instead. - */ - public static final @Deprecated LinkRelation REL_FIRST = IanaLinkRelations.FIRST; - - /** - * @deprecated Use {@link IanaLinkRelations#PREV} instead. - */ - public static final @Deprecated LinkRelation REL_PREVIOUS = IanaLinkRelations.PREV; - - /** - * @deprecated Use {@link IanaLinkRelations#NEXT} instead. - */ - public static final @Deprecated LinkRelation REL_NEXT = IanaLinkRelations.NEXT; - - /** - * @deprecated Use {@link IanaLinkRelations#LAST} instead. - */ - public static final @Deprecated LinkRelation REL_LAST = IanaLinkRelations.LAST; - private LinkRelation rel; private String href; private @Nullable String hreflang, media, title, type, deprecation, profile, name; private @JsonIgnore @Nullable UriTemplate template; private @JsonIgnore List affordances; - /** - * Creates a new link to the given URI with the self rel. - * - * @see IanaLinkRelations#SELF - * @param href must not be {@literal null} or empty. - * @deprecated since 1.1, use {@link #of(String)} - */ - @Deprecated - public Link(String href) { - this(href, IanaLinkRelations.SELF); - } - /** * Creates a new {@link Link} to the given URI with the given rel. * * @param href must not be {@literal null} or empty. * @param rel must not be {@literal null} or empty. - * @deprecated since 1.1, use {@link #of(String, String)}. */ - @Deprecated - public Link(String href, String rel) { - this(href, LinkRelation.of(rel)); - } - - /** - * Creates a new {@link Link} to the given URI with the given rel. - * - * @param href must not be {@literal null} or empty. - * @param rel must not be {@literal null} or empty. - * @deprecated since 1.1, use {@link #of(String, LinkRelation)}. - */ - @Deprecated - public Link(String href, LinkRelation rel) { + protected Link(String href, LinkRelation rel) { this(href, templateOrNull(href), rel, Collections.emptyList()); } @@ -123,22 +72,8 @@ public class Link implements Serializable { * * @param template must not be {@literal null}. * @param rel must not be {@literal null} or empty. - * @deprecated since 1.1, use {@link #of(UriTemplate, String)}. */ - @Deprecated - public Link(UriTemplate template, String rel) { - this(template, LinkRelation.of(rel)); - } - - /** - * Creates a new Link from the given {@link UriTemplate} and rel. - * - * @param template must not be {@literal null}. - * @param rel must not be {@literal null} or empty. - * @deprecated since 1.1, use {@link #of(UriTemplate, LinkRelation)}. - */ - @Deprecated - public Link(UriTemplate template, LinkRelation rel) { + protected Link(UriTemplate template, LinkRelation rel) { this(template, rel, Collections.emptyList()); } @@ -198,7 +133,7 @@ public class Link implements Serializable { * @since 1.1 */ public static Link of(String href) { - return new Link(href); + return new Link(href, IanaLinkRelations.SELF); } /** @@ -210,7 +145,7 @@ public class Link implements Serializable { * @since 1.1 */ public static Link of(String href, String relation) { - return new Link(href, relation); + return new Link(href, LinkRelation.of(relation)); } /** @@ -234,7 +169,7 @@ public class Link implements Serializable { * @since 1.1 */ public static Link of(UriTemplate template, String relation) { - return new Link(template, relation); + return new Link(template, LinkRelation.of(relation)); } /** diff --git a/src/main/java/org/springframework/hateoas/Links.java b/src/main/java/org/springframework/hateoas/Links.java index 85be8890..e3486bee 100644 --- a/src/main/java/org/springframework/hateoas/Links.java +++ b/src/main/java/org/springframework/hateoas/Links.java @@ -79,18 +79,6 @@ public class Links implements Iterable { return Links.class.isInstance(links) ? Links.class.cast(links) : new Links(links); } - /** - * Creates a {@link Links} instance from the given RFC-8288-compatible link format. - * - * @param source a comma separated list of {@link Link} representations. - * @return the {@link Links} represented by the given {@link String}. - * @deprecated use {@link #parse(String)} instead - */ - @Deprecated - public static Links valueOf(String source) { - return parse(source); - } - /** * Creates a {@link Links} instance from the given RFC-8288-compatible link format. * diff --git a/src/main/java/org/springframework/hateoas/PagedModel.java b/src/main/java/org/springframework/hateoas/PagedModel.java index 00cd520d..354139a0 100644 --- a/src/main/java/org/springframework/hateoas/PagedModel.java +++ b/src/main/java/org/springframework/hateoas/PagedModel.java @@ -50,29 +50,11 @@ public class PagedModel extends CollectionModel { this(new ArrayList<>(), null); } - /** - * Creates a new {@link PagedModel} from the given content, {@link PageMetadata} and {@link Link}s (optional). - * - * @param content must not be {@literal null}. - * @param metadata - * @param links - * @deprectated since 1.1, use {@link #of(Collection, PageMetadata, Link...)} instead. - */ - @Deprecated - public PagedModel(Collection content, @Nullable PageMetadata metadata, Link... links) { - this(content, metadata, Arrays.asList(links)); + protected PagedModel(Collection content, @Nullable PageMetadata metadata) { + this(content, metadata, Links.NONE); } - /** - * Creates a new {@link PagedModel} from the given content {@link PageMetadata} and {@link Link}s. - * - * @param content must not be {@literal null}. - * @param metadata - * @param links - * @deprectated since 1.1, use {@link #of(Collection, PageMetadata, Iterable)} instead. - */ - @Deprecated - public PagedModel(Collection content, @Nullable PageMetadata metadata, Iterable links) { + protected PagedModel(Collection content, @Nullable PageMetadata metadata, Iterable links) { this(content, metadata, links, null); } diff --git a/src/main/java/org/springframework/hateoas/config/WebClientConfigurer.java b/src/main/java/org/springframework/hateoas/config/WebClientConfigurer.java deleted file mode 100644 index 4e594fdc..00000000 --- a/src/main/java/org/springframework/hateoas/config/WebClientConfigurer.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright 2019-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.hateoas.config; - -import java.util.List; - -import org.springframework.hateoas.config.EnableHypermediaSupport.HypermediaType; -import org.springframework.web.reactive.function.client.ExchangeStrategies; -import org.springframework.web.reactive.function.client.WebClient; - -import com.fasterxml.jackson.databind.ObjectMapper; - -/** - * Assembles {@link ExchangeStrategies} needed to wire a {@link WebClient} with hypermedia support. - * - * @author Greg Turnquist - * @author Oliver Drotbohm - * @since 1.0 - * @deprecated Migrate to {@link HypermediaWebClientConfigurer} and it's {@link WebClient.Builder}-oriented approach. - */ -@Deprecated -public class WebClientConfigurer { - - private final WebfluxCodecCustomizer customizer; - - /** - * Creates a new {@link WebClientConfigurer} for the given {@link ObjectMapper} and - * {@link HypermediaMappingInformation}s. - * - * @param mapper must not be {@literal null}. - * @param hypermediaTypes must not be {@literal null}. - */ - public WebClientConfigurer(ObjectMapper mapper, List hypermediaTypes) { - this.customizer = new WebfluxCodecCustomizer(hypermediaTypes, mapper); - } - - /** - * Return a set of {@link ExchangeStrategies} driven by registered {@link HypermediaType}s. - * - * @return a collection of {@link Encoder}s and {@link Decoder} assembled into a {@link ExchangeStrategies}. - */ - public ExchangeStrategies hypermediaExchangeStrategies() { - - return ExchangeStrategies.builder() // - .codecs(it -> it.defaultCodecs().configureDefaultCodec(customizer)) // - .build(); - } - - /** - * Register the proper {@link ExchangeStrategies} for a given {@link WebClient}. - * - * @param webClient - * @return mutated webClient with hypermedia support. - */ - public WebClient registerHypermediaTypes(WebClient webClient) { - - return webClient.mutate() - .codecs(it -> it.defaultCodecs().configureDefaultCodec(customizer)) - .build(); - } -} diff --git a/src/main/java/org/springframework/hateoas/mediatype/AffordanceModelFactory.java b/src/main/java/org/springframework/hateoas/mediatype/AffordanceModelFactory.java index 2cee389b..5b973598 100644 --- a/src/main/java/org/springframework/hateoas/mediatype/AffordanceModelFactory.java +++ b/src/main/java/org/springframework/hateoas/mediatype/AffordanceModelFactory.java @@ -15,16 +15,8 @@ */ package org.springframework.hateoas.mediatype; -import java.util.List; - import org.springframework.hateoas.AffordanceModel; -import org.springframework.hateoas.AffordanceModel.InputPayloadMetadata; -import org.springframework.hateoas.AffordanceModel.PayloadMetadata; -import org.springframework.hateoas.Link; -import org.springframework.hateoas.QueryParameter; -import org.springframework.http.HttpMethod; import org.springframework.http.MediaType; -import org.springframework.util.Assert; /** * SPI for media type implementations to create a specific {@link AffordanceModel} for a {@link ConfiguredAffordance}. @@ -41,26 +33,6 @@ public interface AffordanceModelFactory { */ MediaType getMediaType(); - /** - * Look up the {@link AffordanceModel} for this factory. - * - * @param name - * @param link - * @param httpMethod - * @param inputType - * @param queryMethodParameters - * @param outputType - * @return - * @deprecated since 1.3 in favor of {@link #getAffordanceModel(ConfiguredAffordance)}. Will be removed in 1.4. - */ - @Deprecated - default AffordanceModel getAffordanceModel(String name, Link link, HttpMethod httpMethod, - InputPayloadMetadata inputType, - List queryMethodParameters, PayloadMetadata outputType) { - throw new IllegalStateException( - "This method needs to be implemented unless you implement getAffordanceModel(ConfiguredAffordance)!"); - } - /** * Return the {@link AffordanceModel} for the given {@link ConfiguredAffordance}. * @@ -68,11 +40,5 @@ public interface AffordanceModelFactory { * @return must not be {@literal null}. * @since 1.3 */ - default AffordanceModel getAffordanceModel(ConfiguredAffordance configured) { - - Assert.notNull(configured, "Configured affordance must not be null!"); - - return getAffordanceModel(configured.getNameOrDefault(), configured.getTarget(), configured.getMethod(), - configured.getInputMetadata(), configured.getQueryParameters(), configured.getOutputMetadata()); - } + AffordanceModel getAffordanceModel(ConfiguredAffordance configured); } diff --git a/src/main/java/org/springframework/hateoas/mediatype/hal/DefaultCurieProvider.java b/src/main/java/org/springframework/hateoas/mediatype/hal/DefaultCurieProvider.java index e2b92063..c71dd63c 100644 --- a/src/main/java/org/springframework/hateoas/mediatype/hal/DefaultCurieProvider.java +++ b/src/main/java/org/springframework/hateoas/mediatype/hal/DefaultCurieProvider.java @@ -154,10 +154,9 @@ public class DefaultCurieProvider implements CurieProvider { private final String name; - @SuppressWarnings("deprecation") public Curie(String name, String href) { - super(href, "curies"); + super(href, LinkRelation.of("curies")); this.name = name; } diff --git a/src/main/java/org/springframework/hateoas/mediatype/hal/HalModelBuilder.java b/src/main/java/org/springframework/hateoas/mediatype/hal/HalModelBuilder.java index 888e9140..4b94dda7 100644 --- a/src/main/java/org/springframework/hateoas/mediatype/hal/HalModelBuilder.java +++ b/src/main/java/org/springframework/hateoas/mediatype/hal/HalModelBuilder.java @@ -408,7 +408,6 @@ public class HalModelBuilder { } @JsonUnwrapped - @SuppressWarnings("deprecation") public CollectionModel getEmbeddeds() { return new CollectionModel(embeddeds) { diff --git a/src/main/java/org/springframework/hateoas/mediatype/hal/forms/HalFormsConfiguration.java b/src/main/java/org/springframework/hateoas/mediatype/hal/forms/HalFormsConfiguration.java index 786fb307..f468793e 100644 --- a/src/main/java/org/springframework/hateoas/mediatype/hal/forms/HalFormsConfiguration.java +++ b/src/main/java/org/springframework/hateoas/mediatype/hal/forms/HalFormsConfiguration.java @@ -82,25 +82,6 @@ public class HalFormsConfiguration { this.mediaTypes = new ArrayList<>(mediaTypes); } - /** - * Registers a regular expression pattern to be used for form descriptions of the given type. - * - * @param type must not be {@literal null}. - * @param pattern must not be {@literal null} or empty. - * @return will never be {@literal null}. - * @deprecated prefer {@link #withPattern(Class, String)} that returns a fresh instance, to be removed with 1.3. - */ - @Deprecated - public HalFormsConfiguration registerPattern(Class type, String pattern) { - - Assert.notNull(type, "Type must not be null!"); - Assert.hasText(pattern, "Pattern must not be null or empty!"); - - patterns.put(type, pattern); - - return this; - } - /** * Registers a regular expression pattern to be used for form descriptions of the given type. * diff --git a/src/main/java/org/springframework/hateoas/server/core/AnnotationMappingDiscoverer.java b/src/main/java/org/springframework/hateoas/server/core/AnnotationMappingDiscoverer.java index 402ec4f0..31918045 100644 --- a/src/main/java/org/springframework/hateoas/server/core/AnnotationMappingDiscoverer.java +++ b/src/main/java/org/springframework/hateoas/server/core/AnnotationMappingDiscoverer.java @@ -42,10 +42,8 @@ import org.springframework.web.bind.annotation.RequestMethod; * @author Mark Paluch * @author Greg Turnquist * @author Réda Housni Alaoui - * @deprecated since 1.2, not for removal but for hiding within the package in 1.3 */ -@Deprecated -public class AnnotationMappingDiscoverer implements MappingDiscoverer { +class AnnotationMappingDiscoverer implements MappingDiscoverer { private final Class annotationType; private final String mappingAttributeName; diff --git a/src/main/java/org/springframework/hateoas/support/WebStack.java b/src/main/java/org/springframework/hateoas/support/WebStack.java index f9463434..04d4d3f7 100644 --- a/src/main/java/org/springframework/hateoas/support/WebStack.java +++ b/src/main/java/org/springframework/hateoas/support/WebStack.java @@ -22,7 +22,7 @@ import org.springframework.util.ClassUtils; /** * Utility to glean what web stack is currently available. - * + * * @author Greg Turnquist */ public enum WebStack { @@ -74,14 +74,4 @@ public enum WebStack { return configurations; } - - /** - * Is this web stack on the classpath? - * - * @deprecated Will be removed in 1.2 in light of {@link #getAvailableConfigurations()}. - */ - @Deprecated - public boolean isAvailable() { - return this.isServerAvailable; - } } diff --git a/src/test/kotlin/org/springframework/hateoas/server/mvc/WebMvcLinkBuilderDslUnitTest.kt b/src/test/kotlin/org/springframework/hateoas/server/mvc/WebMvcLinkBuilderDslUnitTest.kt index a2f633ee..9d51b860 100644 --- a/src/test/kotlin/org/springframework/hateoas/server/mvc/WebMvcLinkBuilderDslUnitTest.kt +++ b/src/test/kotlin/org/springframework/hateoas/server/mvc/WebMvcLinkBuilderDslUnitTest.kt @@ -52,7 +52,7 @@ class WebMvcLinkBuilderDslUnitTest : TestUtils() { @Test fun `adds links to wrapped domain object`() { - val customer = EntityModel(Customer("15", "John Doe")) + val customer = EntityModel.of(Customer("15", "John Doe")) customer.add(CustomerController::class) { linkTo { findById(it.content.id) } withRel IanaLinkRelations.SELF