Skip to content

Commit

Permalink
Remove switch(hardcoded enum.name)
Browse files Browse the repository at this point in the history
There is no need for a switch here, the doc exists or it does not.
  • Loading branch information
ghubstan committed Jan 15, 2021
1 parent f2a8999 commit ec9f783
Showing 1 changed file with 6 additions and 18 deletions.
24 changes: 6 additions & 18 deletions core/src/main/java/bisq/core/api/CoreHelpService.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,7 @@ public CoreHelpService() {
}

public String getMethodHelp(String methodName) {
switch (methodName) {
case "createoffer":
case "getfundingaddresses":
case "getpaymentaccts":
case "getpaymentmethods":
case "gettxfeerate":
case "getunusedbsqaddress":
case "getversion":
case "lockwallet":
case "takeoffer":
case "unsettxfeerate":
return getHelpText(methodName);
default:
throw new IllegalStateException("no help found for " + methodName);
}
return getHelpText(methodName);
}

private String getHelpText(String methodName) {
Expand All @@ -63,7 +49,7 @@ private String getHelpText(String methodName) {
return readHelpFile(resourceFile);
} catch (NullPointerException ex) {
log.error("", ex);
throw new IllegalStateException(format("could not find %s help doc", methodName));
throw new IllegalStateException(format("no help found for api method %s", methodName));
} catch (IOException ex) {
log.error("", ex);
throw new IllegalStateException(format("could not read %s help doc", methodName));
Expand All @@ -87,7 +73,7 @@ private String readHelpFile(String resourceFile) throws NullPointerException, IO
@SuppressWarnings("CommentedOutCode")
public static void main(String[] args) {
CoreHelpService coreHelpService = new CoreHelpService();
// out.println(coreHelpService.getMethodHelp("getversion"));
out.println(coreHelpService.getMethodHelp("getversion"));
// out.println(coreHelpService.getMethodHelp("getfundingaddresses"));
// out.println(coreHelpService.getMethodHelp("getfundingaddresses"));
// out.println(coreHelpService.getMethodHelp("getunusedbsqaddress"));
Expand All @@ -96,8 +82,10 @@ public static void main(String[] args) {
// out.println(coreHelpService.getMethodHelp("getpaymentaccts"));
// out.println(coreHelpService.getMethodHelp("lockwallet"));
// out.println(coreHelpService.getMethodHelp("gettxfeerate"));
out.println(coreHelpService.getMethodHelp("createoffer"));
// out.println(coreHelpService.getMethodHelp("createoffer"));
// out.println(coreHelpService.getMethodHelp("takeoffer"));
// out.println(coreHelpService.getMethodHelp("garbage"));
// out.println(coreHelpService.getMethodHelp(""));
// out.println(coreHelpService.getMethodHelp(null));
}
}

0 comments on commit ec9f783

Please sign in to comment.