27
27
import org .springframework .data .rest .core .mapping .RepositoryDetectionStrategy ;
28
28
import org .springframework .data .rest .core .mapping .RepositoryDetectionStrategy .RepositoryDetectionStrategies ;
29
29
import org .springframework .data .rest .core .support .EntityLookup ;
30
+ import org .springframework .hateoas .LinkRelation ;
30
31
import org .springframework .hateoas .MediaTypes ;
31
32
import org .springframework .hateoas .server .LinkRelationProvider ;
32
33
import org .springframework .hateoas .server .core .AnnotationLinkRelationProvider ;
@@ -67,16 +68,14 @@ public class RepositoryRestConfiguration {
67
68
private RepositoryDetectionStrategy repositoryDetectionStrategy = RepositoryDetectionStrategies .DEFAULT ;
68
69
private boolean exposeRepositoryMethodsByDefault = true ;
69
70
70
- /**
71
- * The {@link RelProvider} to be used to calculate the link relation defaults for repositories.
72
- */
73
- private LinkRelationProvider relProvider = new EvoInflectorLinkRelationProvider ();
74
71
private final ProjectionDefinitionConfiguration projectionConfiguration ;
75
72
private final MetadataConfiguration metadataConfiguration ;
76
73
private final EntityLookupConfiguration entityLookupConfiguration ;
77
74
78
75
private final ExposureConfiguration exposureConfiguration ;
79
76
private final EnumTranslationConfiguration enumTranslationConfiguration ;
77
+
78
+ private LinkRelationProvider linkRelationProvider ;
80
79
private boolean enableEnumTranslation = false ;
81
80
82
81
/**
@@ -99,7 +98,7 @@ public RepositoryRestConfiguration(ProjectionDefinitionConfiguration projectionC
99
98
this .entityLookupConfiguration = new EntityLookupConfiguration ();
100
99
this .exposureConfiguration = new ExposureConfiguration ();
101
100
102
- this .relProvider = new DelegatingLinkRelationProvider ( //
101
+ this .linkRelationProvider = new DelegatingLinkRelationProvider ( //
103
102
new AnnotationLinkRelationProvider (), //
104
103
new EvoInflectorLinkRelationProvider ());
105
104
}
@@ -666,20 +665,56 @@ public boolean isLookupType(Class<?> type) {
666
665
}
667
666
668
667
/**
669
- * The {@link RelProvider} to be used to calculate the link relation defaults for repositories.
668
+ * The {@link LinkRelationProvider} to be used to calculate the link relation defaults for repositories.
669
+ *
670
+ * @deprecated since 3.5, use {@link #getLinkRelationProvider()} instead.
670
671
*/
672
+ @ Deprecated
671
673
public LinkRelationProvider getRelProvider () {
672
- return this .relProvider ;
674
+ return this .linkRelationProvider ;
673
675
}
674
676
675
677
/**
676
678
* The {@link RelProvider} to be used to calculate the link relation defaults for repositories.
679
+ *
680
+ * @deprecated since 3.5, use {@link #setLinkRelationProvider(LinkRelationProvider)} instead.
677
681
*/
682
+ @ Deprecated
678
683
public void setRelProvider (LinkRelationProvider relProvider ) {
684
+ setLinkRelationProvider (relProvider );
685
+ }
686
+
687
+ /**
688
+ * Returns the {@link LinkRelationProvider} configured to calculate the link relation defaults for repositories.
689
+ * Defaults to a delegating wrapper around an {@link AnnotationLinkRelationProvider} and
690
+ * {@link EvoInflectorLinkRelationProvider}.
691
+ *
692
+ * @return
693
+ * @see #setLinkRelationProvider(LinkRelationProvider)
694
+ * @see AnnotationLinkRelationProvider
695
+ * @see EvoInflectorLinkRelationProvider
696
+ * @since 3.5
697
+ */
698
+ public LinkRelationProvider getLinkRelationProvider () {
699
+ return this .linkRelationProvider ;
700
+ }
679
701
680
- Assert .notNull (relProvider , "LinkRelationProvider must not be null!" );
702
+ /**
703
+ * Configures the {@link LinkRelationProvider} to be used to calculate the {@link LinkRelation} defaults for
704
+ * repositories. The provided instance will replace the default setup completely. For details on the defaults and
705
+ * setting up a similar, delegating arrangement, see {@link #getLinkRelationProvider()}.
706
+ *
707
+ * @param provider must not be {@literal null}.
708
+ * @return the current instance
709
+ * @since 3.5
710
+ */
711
+ public RepositoryRestConfiguration setLinkRelationProvider (LinkRelationProvider provider ) {
712
+
713
+ Assert .notNull (provider , "LinkRelationProvider must not be null!" );
681
714
682
- this .relProvider = relProvider ;
715
+ this .linkRelationProvider = provider ;
716
+
717
+ return this ;
683
718
}
684
719
685
720
public ExposureConfiguration getExposureConfiguration () {
0 commit comments