diff --git a/pom.xml b/pom.xml
index 6b64864..63ac1d9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -78,7 +78,7 @@
net.yetamine
net.yetamine.sova
-
+
1.0.0-SNAPSHOT
diff --git a/src/main/java/net/yetamine/sova/servlet/ServletAttributeSymbol.java b/src/main/java/net/yetamine/sova/servlet/ServletAttributeSymbol.java
index c3e39f8..bd3529f 100644
--- a/src/main/java/net/yetamine/sova/servlet/ServletAttributeSymbol.java
+++ b/src/main/java/net/yetamine/sova/servlet/ServletAttributeSymbol.java
@@ -19,6 +19,8 @@
import java.util.Objects;
import net.yetamine.sova.AdaptationProvider;
+import net.yetamine.sova.Mappable;
+import net.yetamine.sova.Substitutable;
import net.yetamine.sova.symbols.DelegatingSymbol;
/**
@@ -28,10 +30,12 @@
* @param
* the type of resulting values
*/
-public abstract class ServletAttributeSymbol extends DelegatingSymbol {
+public abstract class ServletAttributeSymbol extends DelegatingSymbol implements Substitutable> {
/** Name of the attribute. */
private final String attribute;
+ /** Cached {@link #substitute()}. */
+ private Mappable substitute;
/**
* Prepares a new instance.
@@ -86,4 +90,21 @@ public static String name(Class> qualifier, String identifier) {
public final String attribute() {
return attribute;
}
+
+ /**
+ * @see net.yetamine.sova.symbols.PublicSymbol#substitute()
+ */
+ public final Mappable substitute() {
+ // Using caching technique that uses out-of-thin air thread safety;
+ // this technique is alright here, because the instances are always
+ // behaving in the same way, therefore they are interchangeable
+ Mappable result = substitute;
+ if (result != null) {
+ return result;
+ }
+
+ result = Mappable.of(attribute, this);
+ substitute = result;
+ return result;
+ }
}
diff --git a/src/main/java/net/yetamine/sova/servlet/ServletSymbol.java b/src/main/java/net/yetamine/sova/servlet/ServletSymbol.java
index 394c5c5..c0fd801 100644
--- a/src/main/java/net/yetamine/sova/servlet/ServletSymbol.java
+++ b/src/main/java/net/yetamine/sova/servlet/ServletSymbol.java
@@ -166,11 +166,7 @@ public T use(ServletRequest source) {
*/
public Optional find(ServletRequest source) {
final T result = requestSymbol.get(source);
- if (result != null) {
- return Optional.of(result);
- }
-
- return contextSymbol.find(source.getServletContext());
+ return (result != null) ? Optional.of(result) : contextSymbol.find(source.getServletContext());
}
/**