diff --git a/pom.xml b/pom.xml
index df0a3d7a..52600dae 100644
--- a/pom.xml
+++ b/pom.xml
@@ -459,7 +459,7 @@
org.springframework.plugin
spring-plugin-core
- 1.2.0.RELEASE
+ 2.0.0.BUILD-SNAPSHOT
true
diff --git a/src/main/java/org/springframework/hateoas/LinkDiscoverers.java b/src/main/java/org/springframework/hateoas/LinkDiscoverers.java
index ea5e6fe5..810e1de9 100644
--- a/src/main/java/org/springframework/hateoas/LinkDiscoverers.java
+++ b/src/main/java/org/springframework/hateoas/LinkDiscoverers.java
@@ -47,7 +47,7 @@ public class LinkDiscoverers {
* @return
*/
public LinkDiscoverer getLinkDiscovererFor(MediaType mediaType) {
- return discoverers.getPluginFor(mediaType);
+ return discoverers.getRequiredPluginFor(mediaType);
}
/**
diff --git a/src/main/java/org/springframework/hateoas/core/DelegatingEntityLinks.java b/src/main/java/org/springframework/hateoas/core/DelegatingEntityLinks.java
index 7422ee87..a73d011f 100644
--- a/src/main/java/org/springframework/hateoas/core/DelegatingEntityLinks.java
+++ b/src/main/java/org/springframework/hateoas/core/DelegatingEntityLinks.java
@@ -96,13 +96,9 @@ public class DelegatingEntityLinks extends AbstractEntityLinks {
*/
private EntityLinks getPluginFor(Class> type) {
- EntityLinks plugin = delegates.getPluginFor(type);
-
- if (plugin == null) {
- throw new IllegalArgumentException(String.format(
- "Cannot determine link for %s! No EntityLinks instance found supporting the domain type!", type.getName()));
- }
-
- return plugin;
+ return delegates.getPluginFor(type) //
+ .orElseThrow(() -> new IllegalArgumentException(
+ String.format("Cannot determine link for %s! No EntityLinks instance found supporting the domain type!",
+ type.getName())));
}
}
diff --git a/src/main/java/org/springframework/hateoas/core/DelegatingRelProvider.java b/src/main/java/org/springframework/hateoas/core/DelegatingRelProvider.java
index 93ff1e72..a8351a32 100644
--- a/src/main/java/org/springframework/hateoas/core/DelegatingRelProvider.java
+++ b/src/main/java/org/springframework/hateoas/core/DelegatingRelProvider.java
@@ -38,7 +38,7 @@ public class DelegatingRelProvider implements RelProvider {
*/
@Override
public String getItemResourceRelFor(Class> type) {
- return providers.getPluginFor(type).getItemResourceRelFor(type);
+ return providers.getRequiredPluginFor(type).getItemResourceRelFor(type);
}
/*
@@ -47,7 +47,7 @@ public class DelegatingRelProvider implements RelProvider {
*/
@Override
public String getCollectionResourceRelFor(java.lang.Class> type) {
- return providers.getPluginFor(type).getCollectionResourceRelFor(type);
+ return providers.getRequiredPluginFor(type).getCollectionResourceRelFor(type);
}
/*
diff --git a/src/main/java/org/springframework/hateoas/mvc/ControllerRelProvider.java b/src/main/java/org/springframework/hateoas/mvc/ControllerRelProvider.java
index 1cdd9fc9..9142bc17 100644
--- a/src/main/java/org/springframework/hateoas/mvc/ControllerRelProvider.java
+++ b/src/main/java/org/springframework/hateoas/mvc/ControllerRelProvider.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013-2014 the original author or authors.
+ * Copyright 2013-2017 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.
@@ -48,7 +48,7 @@ public class ControllerRelProvider implements RelProvider {
*/
@Override
public String getCollectionResourceRelFor(Class> resource) {
- return providers.getPluginFor(entityType).getCollectionResourceRelFor(resource);
+ return providers.getRequiredPluginFor(entityType).getCollectionResourceRelFor(resource);
}
/*
@@ -57,7 +57,7 @@ public class ControllerRelProvider implements RelProvider {
*/
@Override
public String getItemResourceRelFor(Class> resource) {
- return providers.getPluginFor(entityType).getItemResourceRelFor(resource);
+ return providers.getRequiredPluginFor(entityType).getItemResourceRelFor(resource);
}
/*
diff --git a/src/test/java/org/springframework/hateoas/LinkDiscoverersUnitTest.java b/src/test/java/org/springframework/hateoas/LinkDiscoverersUnitTest.java
index f53b0b30..53ccf8cd 100644
--- a/src/test/java/org/springframework/hateoas/LinkDiscoverersUnitTest.java
+++ b/src/test/java/org/springframework/hateoas/LinkDiscoverersUnitTest.java
@@ -46,7 +46,7 @@ public class LinkDiscoverersUnitTest {
LinkDiscoverer high = new HighPriorityLinkDiscoverer();
PluginRegistry registry = OrderAwarePluginRegistry.create(Arrays.asList(low, high));
- assertThat(registry.getPluginFor(MediaType.APPLICATION_JSON), is(high));
+ assertThat(registry.getRequiredPluginFor(MediaType.APPLICATION_JSON), is(high));
}
@Order(20)