diff options
author | Adrien Hopkins <ahopk127@my.yorku.ca> | 2022-02-26 11:15:04 -0500 |
---|---|---|
committer | Adrien Hopkins <ahopk127@my.yorku.ca> | 2022-02-26 11:15:49 -0500 |
commit | 934213e08e85cc20bd994d0f39567426c21b89eb (patch) | |
tree | b6a6ec78124e854246478f001fd0d816703e39ce /src/main/java/sevenUnits/utils/Nameable.java | |
parent | 07c86e02be29aa3d3d878adce62c5c0a9a458e47 (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.java | 20 |
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 */ |