#848 - Renamed RelProvider to LinkRelationProvider.
This commit is contained in:
@@ -23,11 +23,11 @@ import org.springframework.context.support.MessageSourceAccessor;
|
||||
import org.springframework.context.support.ReloadableResourceBundleMessageSource;
|
||||
import org.springframework.hateoas.client.LinkDiscoverer;
|
||||
import org.springframework.hateoas.client.LinkDiscoverers;
|
||||
import org.springframework.hateoas.server.RelProvider;
|
||||
import org.springframework.hateoas.server.core.AnnotationRelProvider;
|
||||
import org.springframework.hateoas.server.core.DefaultRelProvider;
|
||||
import org.springframework.hateoas.server.core.DelegatingRelProvider;
|
||||
import org.springframework.hateoas.server.core.EvoInflectorRelProvider;
|
||||
import org.springframework.hateoas.server.LinkRelationProvider;
|
||||
import org.springframework.hateoas.server.core.AnnotationLinkRelationProvider;
|
||||
import org.springframework.hateoas.server.core.DefaultLinkRelationProvider;
|
||||
import org.springframework.hateoas.server.core.DelegatingLinkRelationProvider;
|
||||
import org.springframework.hateoas.server.core.EvoInflectorLinkRelationProvider;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.plugin.core.PluginRegistry;
|
||||
import org.springframework.plugin.core.config.EnablePluginRegistries;
|
||||
@@ -69,31 +69,31 @@ class HateoasConfiguration {
|
||||
// RelProvider
|
||||
|
||||
@Bean
|
||||
RelProvider defaultRelProvider() {
|
||||
LinkRelationProvider defaultRelProvider() {
|
||||
|
||||
return ClassUtils.isPresent("org.atteo.evo.inflector.English", null) //
|
||||
? new EvoInflectorRelProvider()
|
||||
: new DefaultRelProvider();
|
||||
? new EvoInflectorLinkRelationProvider()
|
||||
: new DefaultLinkRelationProvider();
|
||||
}
|
||||
|
||||
@Bean
|
||||
AnnotationRelProvider annotationRelProvider() {
|
||||
return new AnnotationRelProvider();
|
||||
AnnotationLinkRelationProvider annotationRelProvider() {
|
||||
return new AnnotationLinkRelationProvider();
|
||||
}
|
||||
|
||||
@Primary
|
||||
@Bean
|
||||
DelegatingRelProvider _relProvider(PluginRegistry<RelProvider, Class<?>> relProviderPluginRegistry) {
|
||||
return new DelegatingRelProvider(relProviderPluginRegistry);
|
||||
DelegatingLinkRelationProvider _relProvider(PluginRegistry<LinkRelationProvider, Class<?>> relProviderPluginRegistry) {
|
||||
return new DelegatingLinkRelationProvider(relProviderPluginRegistry);
|
||||
}
|
||||
|
||||
@Bean
|
||||
PluginRegistryFactoryBean<RelProvider, Class<?>> relProviderPluginRegistry() {
|
||||
PluginRegistryFactoryBean<LinkRelationProvider, Class<?>> relProviderPluginRegistry() {
|
||||
|
||||
PluginRegistryFactoryBean<RelProvider, Class<?>> factory = new PluginRegistryFactoryBean<>();
|
||||
PluginRegistryFactoryBean<LinkRelationProvider, Class<?>> factory = new PluginRegistryFactoryBean<>();
|
||||
|
||||
factory.setType(RelProvider.class);
|
||||
factory.setExclusions(new Class[] { DelegatingRelProvider.class });
|
||||
factory.setType(LinkRelationProvider.class);
|
||||
factory.setExclusions(new Class[] { DelegatingLinkRelationProvider.class });
|
||||
|
||||
return factory;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ import java.util.Map;
|
||||
|
||||
import org.springframework.hateoas.LinkRelation;
|
||||
import org.springframework.hateoas.EntityModel;
|
||||
import org.springframework.hateoas.server.RelProvider;
|
||||
import org.springframework.hateoas.server.LinkRelationProvider;
|
||||
import org.springframework.hateoas.server.core.EmbeddedWrapper;
|
||||
import org.springframework.hateoas.server.core.EmbeddedWrappers;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -42,17 +42,17 @@ class HalEmbeddedBuilder {
|
||||
private static final String INVALID_EMBEDDED_WRAPPER = "Embedded wrapper %s returned null for both the static rel and the rel target type! Make sure one of the two returns a non-null value!";
|
||||
|
||||
private final Map<HalLinkRelation, Object> embeddeds = new HashMap<>();
|
||||
private final RelProvider provider;
|
||||
private final LinkRelationProvider provider;
|
||||
private final CurieProvider curieProvider;
|
||||
private final EmbeddedWrappers wrappers;
|
||||
|
||||
/**
|
||||
* Creates a new {@link HalEmbeddedBuilder} using the given {@link RelProvider} and prefer collection rels flag.
|
||||
* Creates a new {@link HalEmbeddedBuilder} using the given {@link LinkRelationProvider} and prefer collection rels flag.
|
||||
*
|
||||
* @param provider can be {@literal null}.
|
||||
* @param preferCollectionRels whether to prefer to ask the provider for collection rels.
|
||||
*/
|
||||
public HalEmbeddedBuilder(RelProvider provider, CurieProvider curieProvider, boolean preferCollectionRels) {
|
||||
public HalEmbeddedBuilder(LinkRelationProvider provider, CurieProvider curieProvider, boolean preferCollectionRels) {
|
||||
|
||||
Assert.notNull(provider, "Relprovider must not be null!");
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.springframework.context.support.MessageSourceAccessor;
|
||||
import org.springframework.hateoas.client.LinkDiscoverer;
|
||||
import org.springframework.hateoas.config.EnableHypermediaSupport.HypermediaType;
|
||||
import org.springframework.hateoas.config.HypermediaMappingInformation;
|
||||
import org.springframework.hateoas.server.RelProvider;
|
||||
import org.springframework.hateoas.server.LinkRelationProvider;
|
||||
import org.springframework.http.MediaType;
|
||||
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
@@ -40,7 +40,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
@Configuration
|
||||
public class HalMediaTypeConfiguration implements HypermediaMappingInformation {
|
||||
|
||||
private final RelProvider relProvider;
|
||||
private final LinkRelationProvider relProvider;
|
||||
private final ObjectProvider<CurieProvider> curieProvider;
|
||||
private final ObjectProvider<HalConfiguration> halConfiguration;
|
||||
private final MessageSourceAccessor messageSourceAccessor;
|
||||
@@ -51,7 +51,7 @@ public class HalMediaTypeConfiguration implements HypermediaMappingInformation {
|
||||
* @param halConfiguration
|
||||
* @param messageSourceAccessor
|
||||
*/
|
||||
public HalMediaTypeConfiguration(RelProvider relProvider, ObjectProvider<CurieProvider> curieProvider,
|
||||
public HalMediaTypeConfiguration(LinkRelationProvider relProvider, ObjectProvider<CurieProvider> curieProvider,
|
||||
ObjectProvider<HalConfiguration> halConfiguration,
|
||||
@Qualifier("linkRelationMessageSource") MessageSourceAccessor messageSourceAccessor) {
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ import org.springframework.hateoas.LinkRelation;
|
||||
import org.springframework.hateoas.Links;
|
||||
import org.springframework.hateoas.RepresentationModel;
|
||||
import org.springframework.hateoas.mediatype.hal.HalConfiguration.RenderSingleLinks;
|
||||
import org.springframework.hateoas.server.RelProvider;
|
||||
import org.springframework.hateoas.server.LinkRelationProvider;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
@@ -664,13 +664,13 @@ public class Jackson2HalModule extends SimpleModule {
|
||||
private final Map<Class<?>, Object> serializers = new HashMap<>();
|
||||
private final AutowireCapableBeanFactory delegate;
|
||||
|
||||
public HalHandlerInstantiator(RelProvider provider, CurieProvider curieProvider,
|
||||
public HalHandlerInstantiator(LinkRelationProvider provider, CurieProvider curieProvider,
|
||||
MessageSourceAccessor messageSourceAccessor) {
|
||||
this(provider, curieProvider, messageSourceAccessor, new HalConfiguration());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link HalHandlerInstantiator} using the given {@link RelProvider}, {@link CurieProvider} and
|
||||
* Creates a new {@link HalHandlerInstantiator} using the given {@link LinkRelationProvider}, {@link CurieProvider} and
|
||||
* {@link MessageSourceAccessor}. Registers a prepared {@link HalResourcesSerializer} and
|
||||
* {@link HalLinkListSerializer} falling back to instantiation expecting a default constructor.
|
||||
*
|
||||
@@ -678,13 +678,13 @@ public class Jackson2HalModule extends SimpleModule {
|
||||
* @param curieProvider can be {@literal null}.
|
||||
* @param messageSourceAccessor can be {@literal null}.
|
||||
*/
|
||||
public HalHandlerInstantiator(RelProvider provider, CurieProvider curieProvider,
|
||||
public HalHandlerInstantiator(LinkRelationProvider provider, CurieProvider curieProvider,
|
||||
MessageSourceAccessor messageSourceAccessor, HalConfiguration halConfiguration) {
|
||||
this(provider, curieProvider, messageSourceAccessor, true, halConfiguration);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link HalHandlerInstantiator} using the given {@link RelProvider}, {@link CurieProvider} and
|
||||
* Creates a new {@link HalHandlerInstantiator} using the given {@link LinkRelationProvider}, {@link CurieProvider} and
|
||||
* {@link MessageSourceAccessor} and whether to enforce embedded collections. Registers a prepared
|
||||
* {@link HalResourcesSerializer} and {@link HalLinkListSerializer} falling back to instantiation expecting a
|
||||
* default constructor.
|
||||
@@ -694,12 +694,12 @@ public class Jackson2HalModule extends SimpleModule {
|
||||
* @param accessor can be {@literal null}.
|
||||
* @param enforceEmbeddedCollections
|
||||
*/
|
||||
public HalHandlerInstantiator(RelProvider provider, CurieProvider curieProvider, MessageSourceAccessor accessor,
|
||||
public HalHandlerInstantiator(LinkRelationProvider provider, CurieProvider curieProvider, MessageSourceAccessor accessor,
|
||||
boolean enforceEmbeddedCollections, HalConfiguration halConfiguration) {
|
||||
this(provider, curieProvider, accessor, enforceEmbeddedCollections, null, halConfiguration);
|
||||
}
|
||||
|
||||
private HalHandlerInstantiator(RelProvider provider, CurieProvider curieProvider, MessageSourceAccessor accessor,
|
||||
private HalHandlerInstantiator(LinkRelationProvider provider, CurieProvider curieProvider, MessageSourceAccessor accessor,
|
||||
boolean enforceEmbeddedCollections, AutowireCapableBeanFactory delegate, HalConfiguration halConfiguration) {
|
||||
|
||||
Assert.notNull(provider, "RelProvider must not be null!");
|
||||
@@ -830,19 +830,19 @@ public class Jackson2HalModule extends SimpleModule {
|
||||
*/
|
||||
public static class EmbeddedMapper {
|
||||
|
||||
private RelProvider relProvider;
|
||||
private LinkRelationProvider relProvider;
|
||||
private CurieProvider curieProvider;
|
||||
private boolean preferCollectionRels;
|
||||
|
||||
/**
|
||||
* Creates a new {@link EmbeddedMapper} for the given {@link RelProvider}, {@link CurieProvider} and flag whether to
|
||||
* Creates a new {@link EmbeddedMapper} for the given {@link LinkRelationProvider}, {@link CurieProvider} and flag whether to
|
||||
* prefer collection relations.
|
||||
*
|
||||
* @param relProvider must not be {@literal null}.
|
||||
* @param curieProvider can be {@literal null}.
|
||||
* @param preferCollectionRels
|
||||
*/
|
||||
public EmbeddedMapper(RelProvider relProvider, CurieProvider curieProvider, boolean preferCollectionRels) {
|
||||
public EmbeddedMapper(LinkRelationProvider relProvider, CurieProvider curieProvider, boolean preferCollectionRels) {
|
||||
|
||||
Assert.notNull(relProvider, "RelProvider must not be null!");
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ import org.springframework.hateoas.config.EnableHypermediaSupport.HypermediaType
|
||||
import org.springframework.hateoas.mediatype.hal.CurieProvider;
|
||||
import org.springframework.hateoas.client.LinkDiscoverer;
|
||||
import org.springframework.hateoas.config.HypermediaMappingInformation;
|
||||
import org.springframework.hateoas.server.core.DelegatingRelProvider;
|
||||
import org.springframework.hateoas.server.core.DelegatingLinkRelationProvider;
|
||||
import org.springframework.http.MediaType;
|
||||
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
@@ -43,7 +43,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
@RequiredArgsConstructor
|
||||
class HalFormsMediaTypeConfiguration implements HypermediaMappingInformation {
|
||||
|
||||
private final DelegatingRelProvider relProvider;
|
||||
private final DelegatingLinkRelationProvider relProvider;
|
||||
private final ObjectProvider<CurieProvider> curieProvider;
|
||||
private final ObjectProvider<HalFormsConfiguration> halFormsConfiguration;
|
||||
private final MessageSourceAccessor messageSourceAccessor;
|
||||
|
||||
@@ -37,7 +37,7 @@ import org.springframework.hateoas.mediatype.hal.RepresentationModelMixin;
|
||||
import org.springframework.hateoas.mediatype.hal.forms.HalFormsDeserializers.HalFormsResourcesDeserializer;
|
||||
import org.springframework.hateoas.mediatype.hal.forms.HalFormsSerializers.HalFormsResourceSerializer;
|
||||
import org.springframework.hateoas.mediatype.hal.forms.HalFormsSerializers.HalFormsResourcesSerializer;
|
||||
import org.springframework.hateoas.server.RelProvider;
|
||||
import org.springframework.hateoas.server.LinkRelationProvider;
|
||||
import org.springframework.hateoas.server.mvc.JacksonSerializers.MediaTypeDeserializer;
|
||||
import org.springframework.http.MediaType;
|
||||
|
||||
@@ -148,21 +148,20 @@ class Jackson2HalFormsModule extends SimpleModule {
|
||||
|
||||
private final Map<Class<?>, Object> serializers = new HashMap<>();
|
||||
|
||||
public HalFormsHandlerInstantiator(RelProvider resolver, CurieProvider curieProvider,
|
||||
MessageSourceAccessor messageSource, boolean enforceEmbeddedCollections,
|
||||
public HalFormsHandlerInstantiator(LinkRelationProvider resolver, CurieProvider curieProvider,
|
||||
MessageSourceAccessor accessor, boolean enforceEmbeddedCollections,
|
||||
HalFormsConfiguration halFormsConfiguration) {
|
||||
|
||||
super(resolver, curieProvider, messageSource, enforceEmbeddedCollections,
|
||||
halFormsConfiguration.toHalConfiguration());
|
||||
super(resolver, curieProvider, accessor, enforceEmbeddedCollections, halFormsConfiguration.toHalConfiguration());
|
||||
|
||||
EmbeddedMapper mapper = new EmbeddedMapper(resolver, curieProvider, enforceEmbeddedCollections);
|
||||
|
||||
this.serializers.put(HalFormsResourcesSerializer.class, new HalFormsResourcesSerializer(mapper));
|
||||
this.serializers.put(HalLinkListSerializer.class,
|
||||
new HalLinkListSerializer(curieProvider, mapper, messageSource, halFormsConfiguration.toHalConfiguration()));
|
||||
new HalLinkListSerializer(curieProvider, mapper, accessor, halFormsConfiguration.toHalConfiguration()));
|
||||
}
|
||||
|
||||
public HalFormsHandlerInstantiator(RelProvider relProvider, CurieProvider curieProvider,
|
||||
public HalFormsHandlerInstantiator(LinkRelationProvider relProvider, CurieProvider curieProvider,
|
||||
MessageSourceAccessor messageSource, boolean enforceEmbeddedCollections,
|
||||
AutowireCapableBeanFactory beanFactory) {
|
||||
this(relProvider, curieProvider, messageSource, enforceEmbeddedCollections,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2014 the original author or authors.
|
||||
* Copyright 2013-2019 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.
|
||||
@@ -19,11 +19,11 @@ import org.springframework.hateoas.LinkRelation;
|
||||
import org.springframework.plugin.core.Plugin;
|
||||
|
||||
/**
|
||||
* API to provide relation types for collections and items of the given type.
|
||||
* API to provide {@link LinkRelation}s for collections and items of the given type.
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
public interface RelProvider extends Plugin<Class<?>> {
|
||||
public interface LinkRelationProvider extends Plugin<Class<?>> {
|
||||
|
||||
/**
|
||||
* Returns the relation type to be used to point to an item resource of the given type.
|
||||
@@ -21,20 +21,20 @@ import java.util.Map;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.annotation.AnnotationUtils;
|
||||
import org.springframework.hateoas.LinkRelation;
|
||||
import org.springframework.hateoas.server.RelProvider;
|
||||
import org.springframework.hateoas.server.LinkRelationProvider;
|
||||
|
||||
/**
|
||||
* @author Oliver Gierke
|
||||
* @author Alexander Baetz
|
||||
* @author Greg Turnquist
|
||||
*/
|
||||
public class AnnotationRelProvider implements RelProvider, Ordered {
|
||||
public class AnnotationLinkRelationProvider implements LinkRelationProvider, Ordered {
|
||||
|
||||
private final Map<Class<?>, Relation> annotationCache = new HashMap<>();
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.hateoas.RelProvider#getRelForCollectionResource(java.lang.Class)
|
||||
* @see org.springframework.hateoas.server.LinkRelationProvider#getCollectionResourceRelFor(java.lang.Class)
|
||||
*/
|
||||
@Override
|
||||
public LinkRelation getCollectionResourceRelFor(Class<?> type) {
|
||||
@@ -50,7 +50,7 @@ public class AnnotationRelProvider implements RelProvider, Ordered {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.hateoas.RelProvider#getRelForSingleResource(java.lang.Object)
|
||||
* @see org.springframework.hateoas.server.LinkRelationProvider#getItemResourceRelFor(java.lang.Class)
|
||||
*/
|
||||
@Override
|
||||
public LinkRelation getItemResourceRelFor(Class<?> type) {
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2014 the original author or authors.
|
||||
* Copyright 2013-2019 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.
|
||||
@@ -17,18 +17,41 @@ package org.springframework.hateoas.server.core;
|
||||
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.hateoas.LinkRelation;
|
||||
import org.springframework.hateoas.server.RelProvider;
|
||||
import org.springframework.hateoas.server.LinkRelationProvider;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Default implementation of {@link RelProvider} to simply use the uncapitalized version of the given type's name as
|
||||
* single resource rel as well as an appended {@code List} for the collection resource rel.
|
||||
* Default implementation of {@link LinkRelationProvider} to simply use the uncapitalized version of the given type's
|
||||
* name as item resource {@link LinkRelation} as well as an appended {@code List} for the collection resource
|
||||
* {@link LinkRelation}.
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
* @author Greg Turnquist
|
||||
*/
|
||||
public class DefaultRelProvider implements RelProvider, Ordered {
|
||||
public class DefaultLinkRelationProvider implements LinkRelationProvider, Ordered {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.hateoas.server.LinkRelationProvider#getCollectionResourceRelFor(java.lang.Class)
|
||||
*/
|
||||
@Override
|
||||
public LinkRelation getCollectionResourceRelFor(Class<?> type) {
|
||||
return LinkRelation.of(StringUtils.uncapitalize(type.getSimpleName()) + "List");
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.hateoas.server.LinkRelationProvider#getItemResourceRelFor(java.lang.Class)
|
||||
*/
|
||||
@Override
|
||||
public LinkRelation getItemResourceRelFor(Class<?> type) {
|
||||
return LinkRelation.of(StringUtils.uncapitalize(type.getSimpleName()));
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.core.Ordered#getOrder()
|
||||
*/
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return Ordered.LOWEST_PRECEDENCE;
|
||||
@@ -42,22 +65,4 @@ public class DefaultRelProvider implements RelProvider, Ordered {
|
||||
public boolean supports(Class<?> delimiter) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.hateoas.RelProvider#getRelForCollectionResource(java.lang.Class)
|
||||
*/
|
||||
@Override
|
||||
public LinkRelation getCollectionResourceRelFor(Class<?> type) {
|
||||
return LinkRelation.of(StringUtils.uncapitalize(type.getSimpleName()) + "List");
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.hateoas.RelProvider#getRelForSingleResource(java.lang.Class)
|
||||
*/
|
||||
@Override
|
||||
public LinkRelation getItemResourceRelFor(Class<?> type) {
|
||||
return LinkRelation.of(StringUtils.uncapitalize(type.getSimpleName()));
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2014 the original author or authors.
|
||||
* Copyright 2013-2019 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.
|
||||
@@ -15,27 +15,24 @@
|
||||
*/
|
||||
package org.springframework.hateoas.server.core;
|
||||
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import org.springframework.hateoas.LinkRelation;
|
||||
import org.springframework.hateoas.server.RelProvider;
|
||||
import org.springframework.hateoas.server.LinkRelationProvider;
|
||||
import org.springframework.plugin.core.PluginRegistry;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
public class DelegatingRelProvider implements RelProvider {
|
||||
@RequiredArgsConstructor
|
||||
public class DelegatingLinkRelationProvider implements LinkRelationProvider {
|
||||
|
||||
private final PluginRegistry<RelProvider, Class<?>> providers;
|
||||
|
||||
public DelegatingRelProvider(PluginRegistry<RelProvider, Class<?>> providers) {
|
||||
|
||||
Assert.notNull(providers, "RelProviders must not be null!");
|
||||
this.providers = providers;
|
||||
}
|
||||
private final @NonNull PluginRegistry<LinkRelationProvider, Class<?>> providers;
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.hateoas.RelProvider#getRelForSingleResource(java.lang.Class)
|
||||
* @see org.springframework.hateoas.server.LinkRelationProvider#getItemResourceRelFor(java.lang.Class)
|
||||
*/
|
||||
@Override
|
||||
public LinkRelation getItemResourceRelFor(Class<?> type) {
|
||||
@@ -44,7 +41,7 @@ public class DelegatingRelProvider implements RelProvider {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.hateoas.RelProvider#getRelForCollectionResource(java.lang.Class)
|
||||
* @see org.springframework.hateoas.server.LinkRelationProvider#getCollectionResourceRelFor(java.lang.Class)
|
||||
*/
|
||||
@Override
|
||||
public LinkRelation getCollectionResourceRelFor(java.lang.Class<?> type) {
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2014 the original author or authors.
|
||||
* Copyright 2013-2019 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.
|
||||
@@ -17,20 +17,20 @@ package org.springframework.hateoas.server.core;
|
||||
|
||||
import org.atteo.evo.inflector.English;
|
||||
import org.springframework.hateoas.LinkRelation;
|
||||
import org.springframework.hateoas.server.RelProvider;
|
||||
import org.springframework.hateoas.server.LinkRelationProvider;
|
||||
|
||||
/**
|
||||
* {@link RelProvider} implementation using the Evo Inflector implementation of an algorithmic approach to English
|
||||
* plurals.
|
||||
* {@link LinkRelationProvider} implementation using the Evo Inflector implementation of an algorithmic approach to
|
||||
* English plurals.
|
||||
*
|
||||
* @see http://www.csse.monash.edu.au/~damian/papers/HTML/Plurals.html
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
public class EvoInflectorRelProvider extends DefaultRelProvider {
|
||||
public class EvoInflectorLinkRelationProvider extends DefaultLinkRelationProvider {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.hateoas.core.DefaultRelProvider#getCollectionResourceRelFor(java.lang.Class)
|
||||
* @see org.springframework.hateoas.server.core.DefaultLinkRelationProvider#getCollectionResourceRelFor(java.lang.Class)
|
||||
*/
|
||||
@Override
|
||||
public LinkRelation getCollectionResourceRelFor(Class<?> type) {
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2017 the original author or authors.
|
||||
* Copyright 2013-2019 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.
|
||||
@@ -18,24 +18,25 @@ package org.springframework.hateoas.server.mvc;
|
||||
import org.springframework.core.annotation.AnnotationUtils;
|
||||
import org.springframework.hateoas.LinkRelation;
|
||||
import org.springframework.hateoas.server.ExposesResourceFor;
|
||||
import org.springframework.hateoas.server.RelProvider;
|
||||
import org.springframework.hateoas.server.LinkRelationProvider;
|
||||
import org.springframework.plugin.core.PluginRegistry;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
public class ControllerRelProvider implements RelProvider {
|
||||
public class ControllerLinkRelationProvider implements LinkRelationProvider {
|
||||
|
||||
private final Class<?> controllerType;
|
||||
private final Class<?> entityType;
|
||||
private final PluginRegistry<RelProvider, Class<?>> providers;
|
||||
private final PluginRegistry<LinkRelationProvider, Class<?>> providers;
|
||||
|
||||
public ControllerRelProvider(Class<?> controller, PluginRegistry<RelProvider, Class<?>> providers) {
|
||||
public ControllerLinkRelationProvider(Class<?> controller, PluginRegistry<LinkRelationProvider, Class<?>> providers) {
|
||||
|
||||
Assert.notNull(controller, "Controller must not be null!");
|
||||
|
||||
ExposesResourceFor annotation = AnnotationUtils.findAnnotation(controller, ExposesResourceFor.class);
|
||||
|
||||
Assert.notNull(annotation, "Controller must be annotated with ExposesResourceFor!");
|
||||
|
||||
this.controllerType = controller;
|
||||
@@ -45,22 +46,22 @@ public class ControllerRelProvider implements RelProvider {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.hateoas.RelProvider#getRelForCollectionResource(java.lang.Class)
|
||||
*/
|
||||
@Override
|
||||
public LinkRelation getCollectionResourceRelFor(Class<?> resource) {
|
||||
return providers.getRequiredPluginFor(entityType).getCollectionResourceRelFor(resource);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.hateoas.RelProvider#getRelForSingleResource(java.lang.Class)
|
||||
* @see org.springframework.hateoas.server.LinkRelationProvider#getItemResourceRelFor(java.lang.Class)
|
||||
*/
|
||||
@Override
|
||||
public LinkRelation getItemResourceRelFor(Class<?> resource) {
|
||||
return providers.getRequiredPluginFor(entityType).getItemResourceRelFor(resource);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.hateoas.server.LinkRelationProvider#getCollectionResourceRelFor(java.lang.Class)
|
||||
*/
|
||||
@Override
|
||||
public LinkRelation getCollectionResourceRelFor(Class<?> resource) {
|
||||
return providers.getRequiredPluginFor(entityType).getCollectionResourceRelFor(resource);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.plugin.core.Plugin#supports(java.lang.Object)
|
||||
Reference in New Issue
Block a user