summaryrefslogtreecommitdiff
path: root/src/main/java/sevenUnits/utils/Nameable.java
diff options
context:
space:
mode:
authorAdrien Hopkins <ahopk127@my.yorku.ca>2022-02-26 11:15:04 -0500
committerAdrien Hopkins <ahopk127@my.yorku.ca>2022-02-26 11:15:49 -0500
commit934213e08e85cc20bd994d0f39567426c21b89eb (patch)
treeb6a6ec78124e854246478f001fd0d816703e39ce /src/main/java/sevenUnits/utils/Nameable.java
parent07c86e02be29aa3d3d878adce62c5c0a9a458e47 (diff)
Implemented expression conversion, tests now pass
Diffstat (limited to 'src/main/java/sevenUnits/utils/Nameable.java')
-rw-r--r--src/main/java/sevenUnits/utils/Nameable.java20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/main/java/sevenUnits/utils/Nameable.java b/src/main/java/sevenUnits/utils/Nameable.java
index 3cfc05a..e469d04 100644
--- a/src/main/java/sevenUnits/utils/Nameable.java
+++ b/src/main/java/sevenUnits/utils/Nameable.java
@@ -27,6 +27,16 @@ import java.util.Set;
*/
public interface Nameable {
/**
+ * @return a name for the object - if there's a primary name, it's that,
+ * otherwise the symbol, otherwise "Unnamed"
+ * @since 2022-02-26
+ */
+ default String getName() {
+ final NameSymbol ns = this.getNameSymbol();
+ return ns.getPrimaryName().or(ns::getSymbol).orElse("Unnamed");
+ }
+
+ /**
* @return a {@code NameSymbol} that contains this object's primary name,
* symbol and other names
* @since 2020-09-07
@@ -50,6 +60,16 @@ public interface Nameable {
}
/**
+ * @return a short name for the object - if there's a symbol, it's that,
+ * otherwise the symbol, otherwise "Unnamed"
+ * @since 2022-02-26
+ */
+ default String getShortName() {
+ final NameSymbol ns = this.getNameSymbol();
+ return ns.getSymbol().or(ns::getPrimaryName).orElse("Unnamed");
+ }
+
+ /**
* @return short symbol representing object
* @since 2020-09-07
*/