From 7d7342272a4eb891d6e8a9801a6c76e2cfef74dc Mon Sep 17 00:00:00 2001
From: Jonas Blatt <jonasblatt@uni-koblenz.de>
Date: Wed, 16 Oct 2019 11:47:59 +0200
Subject: [PATCH] Add column name printing method

---
 .../dmn/domain/vdmn/utils/VDmnFunctions.java  | 29 +++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/dmnverifierapi/src/main/java/de/unikoblenz/fgbks/core/dmn/domain/vdmn/utils/VDmnFunctions.java b/dmnverifierapi/src/main/java/de/unikoblenz/fgbks/core/dmn/domain/vdmn/utils/VDmnFunctions.java
index 4c504b21..4319f908 100644
--- a/dmnverifierapi/src/main/java/de/unikoblenz/fgbks/core/dmn/domain/vdmn/utils/VDmnFunctions.java
+++ b/dmnverifierapi/src/main/java/de/unikoblenz/fgbks/core/dmn/domain/vdmn/utils/VDmnFunctions.java
@@ -1,5 +1,6 @@
 package de.unikoblenz.fgbks.core.dmn.domain.vdmn.utils;
 
+import de.unikoblenz.fgbks.base.domain.Name;
 import de.unikoblenz.fgbks.core.dmn.domain.ids.RuleId;
 import de.unikoblenz.fgbks.core.dmn.domain.vdmn.VDmnColumn;
 import de.unikoblenz.fgbks.core.dmn.domain.vdmn.VDmnDecisionTable;
@@ -213,4 +214,32 @@ public class VDmnFunctions {
     }
     return clusters;
   }
+
+  /**
+   * Get the name of a column as string. If a label is present, the string of the label is returned.
+   * If the label is not present, the name is returned. If the name is not present, "[no name]" is
+   * returned.
+   *
+   * @param column the {@link VDmnColumn}
+   * @return a string, representing the "name" of the column
+   */
+  public String getColumnStringName(VDmnColumn column) {
+    Validate.notNull(column);
+    return column.getLabel().isPresent()
+        ? column.getLabel().get().toString()
+        : column.getName().orElse(new Name("[no name]")).toString();
+  }
+
+  /**
+   * Get the name of a column as string. If a label is present, the string of the label is returned.
+   * If the label is not present, the name is returned. If the name is not present, "[no name]" is
+   * returned.
+   *
+   * @param column the {@link VDmnColumn}
+   * @return a string, representing the "name" of the column + "name"
+   */
+  public String getColumnStringNameWithDoubleQuotes(VDmnColumn column) {
+    Validate.notNull(column);
+    return "\"" + getColumnStringName(column) + "\"";
+  }
 }
-- 
GitLab