summaryrefslogtreecommitdiffstats
path: root/v3po/vpp-translate-utils/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'v3po/vpp-translate-utils/src/main/java')
-rw-r--r--v3po/vpp-translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/v3po/util/NamingContext.java24
1 files changed, 24 insertions, 0 deletions
diff --git a/v3po/vpp-translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/v3po/util/NamingContext.java b/v3po/vpp-translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/v3po/util/NamingContext.java
index bcc980dd4..dc77106fb 100644
--- a/v3po/vpp-translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/v3po/util/NamingContext.java
+++ b/v3po/vpp-translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/v3po/util/NamingContext.java
@@ -76,6 +76,9 @@ public final class NamingContext implements AutoCloseable {
if (!containsName(index, mappingContext)) {
final String artificialName = getArtificialName(index);
LOG.info("Assigning artificial name: {} for index: {}", artificialName, index);
+ for (StackTraceElement stackTraceElement : Thread.currentThread().getStackTrace()) {
+ LOG.error("{}", stackTraceElement.toString());
+ }
addName(index, artificialName, mappingContext);
}
@@ -88,6 +91,27 @@ public final class NamingContext implements AutoCloseable {
}
/**
+ * Retrieve name for mapping stored provided mappingContext instance. if present
+ *
+ * @param index index of a mapped item
+ * @param mappingContext mapping context providing context data for current transaction
+ *
+ * @return name mapped to provided index
+ */
+ @Nonnull
+ public synchronized Optional<String> getNameIfPresent(final int index,
+ @Nonnull final MappingContext mappingContext) {
+ final Optional<Mappings> read = mappingContext.read(namingContextIid.child(Mappings.class));
+
+ return read.isPresent()
+ ? Optional.of(read.get().getMapping().stream()
+ .filter(mapping -> mapping.getIndex().equals(index))
+ .collect(SINGLE_ITEM_COLLECTOR)
+ .getName())
+ : Optional.absent();
+ }
+
+ /**
* Check whether mapping is present for index.
*
* @param index index of a mapped item