2727import org .springframework .data .rest .core .mapping .RepositoryDetectionStrategy ;
2828import org .springframework .data .rest .core .mapping .RepositoryDetectionStrategy .RepositoryDetectionStrategies ;
2929import org .springframework .data .rest .core .support .EntityLookup ;
30+ import org .springframework .hateoas .LinkRelation ;
3031import org .springframework .hateoas .MediaTypes ;
3132import org .springframework .hateoas .server .LinkRelationProvider ;
3233import org .springframework .hateoas .server .core .AnnotationLinkRelationProvider ;
@@ -67,16 +68,14 @@ public class RepositoryRestConfiguration {
6768 private RepositoryDetectionStrategy repositoryDetectionStrategy = RepositoryDetectionStrategies .DEFAULT ;
6869 private boolean exposeRepositoryMethodsByDefault = true ;
6970
70- /**
71- * The {@link RelProvider} to be used to calculate the link relation defaults for repositories.
72- */
73- private LinkRelationProvider relProvider = new EvoInflectorLinkRelationProvider ();
7471 private final ProjectionDefinitionConfiguration projectionConfiguration ;
7572 private final MetadataConfiguration metadataConfiguration ;
7673 private final EntityLookupConfiguration entityLookupConfiguration ;
7774
7875 private final ExposureConfiguration exposureConfiguration ;
7976 private final EnumTranslationConfiguration enumTranslationConfiguration ;
77+
78+ private LinkRelationProvider linkRelationProvider ;
8079 private boolean enableEnumTranslation = false ;
8180
8281 /**
@@ -99,7 +98,7 @@ public RepositoryRestConfiguration(ProjectionDefinitionConfiguration projectionC
9998 this .entityLookupConfiguration = new EntityLookupConfiguration ();
10099 this .exposureConfiguration = new ExposureConfiguration ();
101100
102- this .relProvider = new DelegatingLinkRelationProvider ( //
101+ this .linkRelationProvider = new DelegatingLinkRelationProvider ( //
103102 new AnnotationLinkRelationProvider (), //
104103 new EvoInflectorLinkRelationProvider ());
105104 }
@@ -666,20 +665,56 @@ public boolean isLookupType(Class<?> type) {
666665 }
667666
668667 /**
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.
670671 */
672+ @ Deprecated
671673 public LinkRelationProvider getRelProvider () {
672- return this .relProvider ;
674+ return this .linkRelationProvider ;
673675 }
674676
675677 /**
676678 * 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.
677681 */
682+ @ Deprecated
678683 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+ }
679701
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!" );
681714
682- this .relProvider = relProvider ;
715+ this .linkRelationProvider = provider ;
716+
717+ return this ;
683718 }
684719
685720 public ExposureConfiguration getExposureConfiguration () {
0 commit comments