From ae08e9be88ca8cafe0f27ca2d9927db487e35db2 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Fri, 30 Mar 2018 15:47:00 +0100 Subject: [PATCH] JAL-2629 tidy code, factory methods for param sets --- src/jalview/hmmer/HMMERParamStore.java | 53 ++++++++++++++++++++++---------- src/jalview/hmmer/HMMERPreset.java | 10 ------ 2 files changed, 36 insertions(+), 27 deletions(-) diff --git a/src/jalview/hmmer/HMMERParamStore.java b/src/jalview/hmmer/HMMERParamStore.java index 17f582e..c668481 100644 --- a/src/jalview/hmmer/HMMERParamStore.java +++ b/src/jalview/hmmer/HMMERParamStore.java @@ -18,17 +18,38 @@ import java.util.Collection; import java.util.List; import java.util.Scanner; -public class HMMERParamStore implements ParamDatastoreI +public final class HMMERParamStore implements ParamDatastoreI { + private static final String HMMBUILD = "hmmbuild"; + + private static final String HMMALIGN = "hmmalign"; + + private static final String HMMSEARCH = "hmmsearch"; + String name; List presets = new ArrayList<>(); - public HMMERParamStore(String nam) + private HMMERParamStore(String nam) { this.name = nam; } + public static HMMERParamStore forBuild() + { + return new HMMERParamStore(HMMBUILD); + } + + public static HMMERParamStore forAlign() + { + return new HMMERParamStore(HMMALIGN); + } + + public static HMMERParamStore forSearch() + { + return new HMMERParamStore(HMMSEARCH); + } + @Override public List getPresets() { @@ -45,20 +66,20 @@ public class HMMERParamStore implements ParamDatastoreI public List getServiceParameters() { List args = new ArrayList<>(); - if ("hmmsearch".equals(name)) + switch (name) { + case HMMSEARCH: getHMMSearchParams(args); - } - if ("hmmalign".equals(name)) - { + break; + case HMMALIGN: getHMMAlignParams(args); - - } - if ("hmmbuild".equals(name)) - { + break; + case HMMBUILD: getHMMBuildParams(args); - + break; + default: } + return args; } @@ -80,7 +101,7 @@ public class HMMERParamStore implements ParamDatastoreI while (nameScanner.hasNext()) { String next = nameScanner.next(); - if (next == "null") + if ("null".equals(next)) { Cache.setProperty(Preferences.HMMSEARCH_DBS, ""); Cache.setProperty(Preferences.HMMSEARCH_DB_PATHS, ""); @@ -164,13 +185,13 @@ public class HMMERParamStore implements ParamDatastoreI } @Override - public boolean presetExists(String name) + public boolean presetExists(String forName) { return false; } @Override - public void deletePreset(String name) + public void deletePreset(String forName) { } @@ -178,8 +199,6 @@ public class HMMERParamStore implements ParamDatastoreI public void storePreset(String presetName, String text, List jobParams) { - // TODO Auto-generated method stub - } @Override @@ -189,7 +208,7 @@ public class HMMERParamStore implements ParamDatastoreI } @Override - public WsParamSetI parseServiceParameterFile(String name, + public WsParamSetI parseServiceParameterFile(String forName, String description, String[] serviceURL, String parameters) throws IOException { diff --git a/src/jalview/hmmer/HMMERPreset.java b/src/jalview/hmmer/HMMERPreset.java index b7cd29a..2712259 100644 --- a/src/jalview/hmmer/HMMERPreset.java +++ b/src/jalview/hmmer/HMMERPreset.java @@ -11,57 +11,47 @@ public class HMMERPreset implements WsParamSetI @Override public String getName() { - // TODO Auto-generated method stub return null; } @Override public String getDescription() { - // TODO Auto-generated method stub return null; } @Override public String[] getApplicableUrls() { - // TODO Auto-generated method stub return null; } @Override public String getSourceFile() { - // TODO Auto-generated method stub return null; } @Override public void setSourceFile(String newfile) { - // TODO Auto-generated method stub - } @Override public boolean isModifiable() { - // TODO Auto-generated method stub return false; } @Override public List getArguments() { - // TODO Auto-generated method stub return null; } @Override public void setArguments(List args) { - // TODO Auto-generated method stub - } } -- 1.7.10.2