ezntt commented on code in PR #7022:
URL: https://github.com/apache/cloudstack/pull/7022#discussion_r1060190770
##########
api/src/main/java/org/apache/cloudstack/api/BaseCmd.java:
##########
@@ -247,30 +247,36 @@ public void setResponseType(final String responseType) {
this.responseType = responseType;
}
- /**
- * For some reason this method does not return the actual command name,
but more a name that
- * is used to create the response. So you can expect for a XCmd a value
like xcmdresponse. Anyways
- * this methods is used in too many places so for now instead of changing
it we just create another
- * method {@link BaseCmd#getActualCommandName()} that returns the value
from {@link APICommand#name()}
- *
- * @return
- */
- public abstract String getCommandName();
-
-
/**
* Gets the CommandName based on the class annotations: the value from
{@link APICommand#name()}
*
* @return the value from {@link APICommand#name()}
*/
- public String getActualCommandName() {
+ public static String getCommandNameByClass(Class<?> clazz) {
String cmdName = null;
- if (this.getClass().getAnnotation(APICommand.class) != null) {
- cmdName = this.getClass().getAnnotation(APICommand.class).name();
+ APICommand apiClassAnnotation = clazz.getAnnotation(APICommand.class);
+
+ if (apiClassAnnotation != null && apiClassAnnotation.name() != null) {
+ cmdName = apiClassAnnotation.name();
} else {
- cmdName = this.getClass().getName();
+ cmdName = clazz.getName();
Review Comment:
@weizhouapache
No. as far as I've seen, there are no null annotations or null names
throughout the APIs.
In my view, the main purpose of this PR is just to clean up the code and not
change its behaviors if needed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]