aboutsummaryrefslogtreecommitdiffstats
path: root/jdisc_core/src/main/java/com
diff options
context:
space:
mode:
authorArne Juul <arnej@yahoo-inc.com>2017-11-09 21:16:51 +0000
committerArne Juul <arnej@yahoo-inc.com>2017-11-09 21:16:51 +0000
commit5bc7413e1af6272b172d1ccd293235a2202f368a (patch)
tree6c34a440e614c5548173b3b5c40b0ae6477bdb5c /jdisc_core/src/main/java/com
parent310675a44a01e9f671b06d63a2043cdad2cfc58a (diff)
add the pattern to BindingMatch
Diffstat (limited to 'jdisc_core/src/main/java/com')
-rw-r--r--jdisc_core/src/main/java/com/yahoo/jdisc/application/BindingMatch.java24
-rw-r--r--jdisc_core/src/main/java/com/yahoo/jdisc/application/BindingSet.java5
2 files changed, 27 insertions, 2 deletions
diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/application/BindingMatch.java b/jdisc_core/src/main/java/com/yahoo/jdisc/application/BindingMatch.java
index 5d4974f2dc4..5d5f40a825a 100644
--- a/jdisc_core/src/main/java/com/yahoo/jdisc/application/BindingMatch.java
+++ b/jdisc_core/src/main/java/com/yahoo/jdisc/application/BindingMatch.java
@@ -15,6 +15,7 @@ public class BindingMatch<T> {
private final UriPattern.Match match;
private final T target;
+ private final UriPattern matched;
/**
* <p>Constructs a new instance of this class.</p>
@@ -24,10 +25,23 @@ public class BindingMatch<T> {
* @throws NullPointerException If any argument is null.
*/
public BindingMatch(UriPattern.Match match, T target) {
+ this(match, target, null);
+ }
+
+ /**
+ * <p>Constructs a new instance of this class.</p>
+ *
+ * @param match The match information for this instance.
+ * @param target The target of this match.
+ * @param matched The matched URI pattern
+ * @throws NullPointerException If any argument is null.
+ */
+ public BindingMatch(UriPattern.Match match, T target, UriPattern matched) {
Objects.requireNonNull(match, "match");
Objects.requireNonNull(target, "target");
this.match = match;
this.target = target;
+ this.matched = matched;
}
/**
@@ -61,4 +75,14 @@ public class BindingMatch<T> {
public T target() {
return target;
}
+
+ /**
+ * <p>Returns the URI pattern that was matched.</p>
+ *
+ * @return The matched pattern.
+ */
+ public UriPattern matched() {
+ return matched;
+ }
+
}
diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/application/BindingSet.java b/jdisc_core/src/main/java/com/yahoo/jdisc/application/BindingSet.java
index 7a21e204dd3..1e25846f63c 100644
--- a/jdisc_core/src/main/java/com/yahoo/jdisc/application/BindingSet.java
+++ b/jdisc_core/src/main/java/com/yahoo/jdisc/application/BindingSet.java
@@ -38,9 +38,10 @@ public class BindingSet<T> implements Iterable<Map.Entry<UriPattern, T>> {
*/
public BindingMatch<T> match(URI uri) {
for (Map.Entry<UriPattern, T> entry : bindings) {
- UriPattern.Match match = entry.getKey().match(uri);
+ UriPattern pattern = entry.getKey();
+ UriPattern.Match match = pattern.match(uri);
if (match != null) {
- return new BindingMatch<>(match, entry.getValue());
+ return new BindingMatch<>(match, entry.getValue(), pattern);
}
}
return null;