blob: 868884c6d10c9448d00162391d7ee81bee981171 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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;
}
}
|