diff options
author | Dico200 <dico.karssiens@gmail.com> | 2018-07-25 01:53:23 +0100 |
---|---|---|
committer | Dico200 <dico.karssiens@gmail.com> | 2018-07-25 01:53:23 +0100 |
commit | 44587e49ff1840219d9bc44844d4a3a6cd8ac5de (patch) | |
tree | 276ae9625795e9d79fc7db8592dbcb3a1af60928 /dicore3/command/src/main/java/io/dico/dicore/command/annotation/CommandAnnotationUtils.java | |
parent | 5e168847c2624b767deb9da310ecfdf169e0f43c (diff) |
Add dicore3-command
Diffstat (limited to 'dicore3/command/src/main/java/io/dico/dicore/command/annotation/CommandAnnotationUtils.java')
-rw-r--r-- | dicore3/command/src/main/java/io/dico/dicore/command/annotation/CommandAnnotationUtils.java | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/dicore3/command/src/main/java/io/dico/dicore/command/annotation/CommandAnnotationUtils.java b/dicore3/command/src/main/java/io/dico/dicore/command/annotation/CommandAnnotationUtils.java new file mode 100644 index 0000000..868884c --- /dev/null +++ b/dicore3/command/src/main/java/io/dico/dicore/command/annotation/CommandAnnotationUtils.java @@ -0,0 +1,35 @@ +package io.dico.dicore.command.annotation; + +public class CommandAnnotationUtils { + + /** + * Get the short description from a {@link Desc} annotation. + * If {@link Desc#shortVersion()} is given, returns that. + * Otherwise, returns the first element of {@link Desc#value()} + * If neither is available, returns null. + * + * @param desc the annotation + * @return the short description + */ + public static String getShortDescription(Desc desc) { + String descString; + if (desc == null) { + descString = null; + } else if (!desc.shortVersion().isEmpty()) { + descString = desc.shortVersion(); + } else if (desc.value().length > 0) { + descString = desc.value()[0]; + if (desc.value().length > 1) { + //System.out.println("[Command Warning] Multiline descriptions not supported here. Keep it short for: " + targetIdentifier); + } + if (descString != null && descString.isEmpty()) { + descString = null; + } + } else { + descString = null; + } + + return descString; + } + +} |