diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 823b4fc..ff169db 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -7,11 +7,9 @@
-
-
-
-
-
+
+
+
@@ -239,7 +237,8 @@
-
+
+
diff --git a/build.gradle.kts b/build.gradle.kts
index 219893a..68eb50d 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -5,7 +5,7 @@ plugins {
}
group = "com.duncpro"
-version = "1.0-SNAPSHOT-10"
+version = "1.0-SNAPSHOT-11"
repositories {
mavenCentral()
diff --git a/src/main/java/com/duncpro/jroute/router/Router.java b/src/main/java/com/duncpro/jroute/router/Router.java
index 0228e80..0a1cda3 100644
--- a/src/main/java/com/duncpro/jroute/router/Router.java
+++ b/src/main/java/com/duncpro/jroute/router/Router.java
@@ -31,6 +31,11 @@ default void add(String routeString, E endpoint) throws RouteConflictException {
*/
Set> getAllEndpoints(Route prefix);
+ /**
+ * Returns the endpoint which exists at the given {@link Route} (if any).
+ */
+ Optional getEndpoint(Route at);
+
/**
* @throws RouteConflictException if the given endpoint conflicts with a pre-existing endpoint within the router.
*/
diff --git a/src/main/java/com/duncpro/jroute/router/TreeRouter.java b/src/main/java/com/duncpro/jroute/router/TreeRouter.java
index 214c291..ba77f16 100644
--- a/src/main/java/com/duncpro/jroute/router/TreeRouter.java
+++ b/src/main/java/com/duncpro/jroute/router/TreeRouter.java
@@ -41,6 +41,11 @@ public Set> getAllEndpoints(Route prefix) {
.orElse(Collections.emptySet());
}
+ @Override
+ public Optional getEndpoint(Route at) {
+ return findNode(at).flatMap(RouteTreeNode::getEndpoint);
+ }
+
private Optional> findNode(Route route) {
RouteTreeNode prefixNode = rootRoute;
diff --git a/src/main/java/com/duncpro/jroute/util/DelegatingRouter.java b/src/main/java/com/duncpro/jroute/util/DelegatingRouter.java
index a3b94bc..402521e 100644
--- a/src/main/java/com/duncpro/jroute/util/DelegatingRouter.java
+++ b/src/main/java/com/duncpro/jroute/util/DelegatingRouter.java
@@ -40,4 +40,9 @@ public E getOrAdd(Route route, Supplier endpointFactory) {
public Set> getAllEndpoints(Route prefix) {
return underlyingRouter.getAllEndpoints(prefix);
}
+
+ @Override
+ public Optional getEndpoint(Route at) {
+ return underlyingRouter.getEndpoint(at);
+ }
}