Fix build broken after cherry-pick
diff --git a/api/pom.xml b/api/pom.xml
index 74118a9..5741526 100644
--- a/api/pom.xml
+++ b/api/pom.xml
@@ -37,7 +37,10 @@
<version>2.2.11</version>
<scope>provided</scope>
</dependency>
-
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-lang3</artifactId>
+ </dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
diff --git a/api/src/main/java/org/apache/unomi/api/Profile.java b/api/src/main/java/org/apache/unomi/api/Profile.java
index ba75da9..7115bd5 100644
--- a/api/src/main/java/org/apache/unomi/api/Profile.java
+++ b/api/src/main/java/org/apache/unomi/api/Profile.java
@@ -17,6 +17,7 @@
package org.apache.unomi.api;
+import org.apache.commons.lang3.StringUtils;
import org.apache.unomi.api.segments.Scoring;
import org.apache.unomi.api.segments.Segment;
@@ -95,6 +96,30 @@
}
/**
+ * Retrieves the value of the nested property identified by the specified name.
+ *
+ * @param name the name of the property to be retrieved, splited in the nested properties with "."
+ * @return the value of the property identified by the specified name
+ */
+ public Object getNestedProperty(String name) {
+ if (!name.contains(".")) {
+ return getProperty(name);
+ }
+
+ Map properties = this.properties;
+ String[] propertyPath = StringUtils.substringBeforeLast(name, ".").split("\\.");
+ String propertyName = StringUtils.substringAfterLast(name, ".");
+
+ for (String property: propertyPath) {
+ properties = (Map) properties.get(property);
+ if (properties == null) {
+ return null;
+ }
+ }
+ return properties.get(propertyName);
+ }
+
+ /**
* Retrieves a Map of all property name - value pairs for this profile.
*
* @return a Map of all property name - value pairs for this profile