#1648 - Removed further deprecations.
This commit is contained in:
@@ -50,31 +50,11 @@ public class CollectionModel<T> extends RepresentationModel<CollectionModel<T>>
|
||||
* 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<T> 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<T> content, Iterable<Link> links) {
|
||||
this(content, links, null);
|
||||
protected CollectionModel(Iterable<T> content) {
|
||||
this(content, Links.NONE, null);
|
||||
}
|
||||
|
||||
protected CollectionModel(Iterable<T> content, Iterable<Link> links, @Nullable ResolvableType fallbackType) {
|
||||
@@ -200,7 +180,7 @@ public class CollectionModel<T> extends RepresentationModel<CollectionModel<T>>
|
||||
* @see #withFallbackType(ResolvableType)
|
||||
*/
|
||||
public static <T> CollectionModel<T> of(Iterable<T> content, Iterable<Link> links) {
|
||||
return new CollectionModel<>(content, links);
|
||||
return new CollectionModel<>(content, links, null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -57,16 +57,8 @@ public class EntityModel<T> extends RepresentationModel<EntityModel<T>> {
|
||||
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<T> extends RepresentationModel<EntityModel<T>> {
|
||||
*
|
||||
* @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<Link> links) {
|
||||
protected EntityModel(T content, Iterable<Link> links) {
|
||||
|
||||
Assert.notNull(content, "Content must not be null!");
|
||||
Assert.isTrue(!(content instanceof Collection), "Content must not be a collection! Use CollectionModel instead!");
|
||||
|
||||
@@ -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<Affordance> 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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -79,18 +79,6 @@ public class Links implements Iterable<Link> {
|
||||
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.
|
||||
*
|
||||
|
||||
@@ -50,29 +50,11 @@ public class PagedModel<T> extends CollectionModel<T> {
|
||||
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<T> content, @Nullable PageMetadata metadata, Link... links) {
|
||||
this(content, metadata, Arrays.asList(links));
|
||||
protected PagedModel(Collection<T> 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<T> content, @Nullable PageMetadata metadata, Iterable<Link> links) {
|
||||
protected PagedModel(Collection<T> content, @Nullable PageMetadata metadata, Iterable<Link> links) {
|
||||
this(content, metadata, links, 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<HypermediaMappingInformation> 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();
|
||||
}
|
||||
}
|
||||
@@ -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<QueryParameter> 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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -408,7 +408,6 @@ public class HalModelBuilder {
|
||||
}
|
||||
|
||||
@JsonUnwrapped
|
||||
@SuppressWarnings("deprecation")
|
||||
public CollectionModel<?> getEmbeddeds() {
|
||||
|
||||
return new CollectionModel<Object>(embeddeds) {
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
@@ -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<? extends Annotation> annotationType;
|
||||
private final String mappingAttributeName;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user