From d7d522b7784d6ac65a008fe5f89ed7a4e7d8d2f7 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Mon, 14 May 2018 14:20:19 +0100 Subject: [PATCH] Update spike branch to latest --- src/jalview/gui/AlignFrame.java | 24 ++-- src/jalview/gui/OptsAndParamsPage.java | 147 ++++++++++++------- src/jalview/gui/Preferences.java | 5 +- src/jalview/hmmer/HMMERParamStore.java | 96 ++++++++----- src/jalview/util/StringUtils.java | 25 +--- src/jalview/workers/InformationThread.java | 11 +- src/jalview/ws/jws2/dm/JabaOption.java | 6 + src/jalview/ws/params/OptionI.java | 38 ++++- src/jalview/ws/params/simple/Option.java | 157 +++++++++++++-------- src/jalview/ws/params/simple/StringParameter.java | 12 +- src/jalview/ws/rest/InputType.java | 15 +- test/jalview/util/StringUtilsTest.java | 15 +- 12 files changed, 332 insertions(+), 219 deletions(-) diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index d52aa97..89066cb 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -94,7 +94,6 @@ import jalview.schemes.ColourSchemes; import jalview.schemes.ResidueColourScheme; import jalview.schemes.TCoffeeColourScheme; import jalview.util.MessageManager; -import jalview.util.StringUtils; import jalview.viewmodel.AlignmentViewport; import jalview.viewmodel.ViewportRanges; import jalview.ws.DBRefFetcher; @@ -143,7 +142,6 @@ import java.util.Deque; import java.util.Enumeration; import java.util.Hashtable; import java.util.List; -import java.util.Scanner; import java.util.Vector; import javax.swing.JCheckBoxMenuItem; @@ -1140,13 +1138,17 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, return true; } + /** + * Opens a file browser and adds the selected file, if in Fasta, Stockholm or + * Pfam format, to the list held under preference key "HMMSEARCH_DBS" (as a + * comma-separated list) + */ @Override public void addDatabase_actionPerformed() throws IOException { - if (Cache.getProperty(Preferences.HMMSEARCH_DB_PATHS) == null) + if (Cache.getProperty(Preferences.HMMSEARCH_DBS) == null) { Cache.setProperty(Preferences.HMMSEARCH_DBS, ""); - Cache.setProperty(Preferences.HMMSEARCH_DB_PATHS, ""); } String path = openFileChooser(false); @@ -1157,19 +1159,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, if (format == FileFormat.Fasta || format == FileFormat.Stockholm || format == FileFormat.Pfam) { - String currentDbs = Cache.getProperty(Preferences.HMMSEARCH_DBS); String currentDbPaths = Cache - .getProperty(Preferences.HMMSEARCH_DB_PATHS); - currentDbPaths += " " + path; - - String fileName = StringUtils.getLastToken(path, File.separator); - Scanner scanner = new Scanner(fileName).useDelimiter("."); - String name = scanner.next(); - scanner.close(); - currentDbs += " " + path; // TODO remove path from file name - scanner.close(); - - Cache.setProperty(Preferences.HMMSEARCH_DB_PATHS, currentDbPaths); + .getProperty(Preferences.HMMSEARCH_DBS); + currentDbPaths += Preferences.COMMA + path; Cache.setProperty(Preferences.HMMSEARCH_DBS, currentDbPaths); } else diff --git a/src/jalview/gui/OptsAndParamsPage.java b/src/jalview/gui/OptsAndParamsPage.java index 1843f49..298057f 100644 --- a/src/jalview/gui/OptsAndParamsPage.java +++ b/src/jalview/gui/OptsAndParamsPage.java @@ -144,12 +144,17 @@ public class OptsAndParamsPage add(enabled); } - val = new JComboBox<>(); - for (String str : opt.getPossibleValues()) - { - val.addItem(str); - } + /* + * construct the choice box with possible values, + * or their display names if provided + */ + val = buildComboBox(opt); val.setSelectedItem(opt.getValue()); + + /* + * only show the choicebox if there is more than one option, + * or the option is mandatory + */ if (opt.getPossibleValues().size() > 1 || opt.isRequired()) { val.addActionListener(this); @@ -228,31 +233,21 @@ public class OptsAndParamsPage poparent.argSetModified(this, !notmod); } - public OptionI getOptionIfEnabled() + /** + * Answers null if the option is not selected, else a new Option holding the + * selected value + * + * @return + */ + public ArgumentI getSelectedOption() { if (!enabled.isSelected()) { return null; } + String value = getSelectedValue(option, val.getSelectedIndex()); OptionI opt = option.copy(); - if (opt.getPossibleValues() != null - && opt.getPossibleValues().size() == 1) - { - // Hack to make sure the default value for an enabled option with only - // one value is actually returned - opt.setValue(opt.getPossibleValues().get(0)); - } - if (val.getSelectedItem() != null) - { - opt.setValue((String) val.getSelectedItem()); - } - else - { - if (option.getValue() != null) - { - opt.setValue(option.getValue()); - } - } + opt.setValue(value); return opt; } @@ -613,12 +608,18 @@ public class OptsAndParamsPage return Component.BaselineResizeBehavior.CONSTANT_ASCENT; } - public ParameterI getParameter() + /** + * Answers an argument holding the value entered or selected in the dialog + * + * @return + */ + public ArgumentI getParameter() { ParameterI prm = parameter.copy(); if (isChoiceParameter) { - prm.setValue((String) choicebox.getSelectedItem()); + String value = getSelectedValue(this.parameter, choicebox.getSelectedIndex()); + prm.setValue(value); } else { @@ -732,8 +733,7 @@ public class OptsAndParamsPage { if (isChoiceParameter) { - choicebox = new JComboBox<>(); - choicebox.addActionListener(this); + choicebox = buildComboBox(parm); controlsPanel.add(choicebox, BorderLayout.CENTER); } else @@ -765,26 +765,9 @@ public class OptsAndParamsPage } } - if (parm != null) + if (!isChoiceParameter && parm != null) { - if (isChoiceParameter) - { - if (init) - { - for (String val : parm.getPossibleValues()) - { - choicebox.addItem(val); - } - } - if (parm.getValue() != null) - { - choicebox.setSelectedItem(parm.getValue()); - } - } - else - { - valueField.setText(parm.getValue()); - } + valueField.setText(parm.getValue()); } lastVal = updateSliderFromValueField(); adjusting = false; @@ -810,7 +793,7 @@ public class OptsAndParamsPage { if (isChoiceParameter) { - return choicebox.getSelectedItem(); + return getSelectedValue(this.parameter, choicebox.getSelectedIndex()); } slider.setVisible(false); return valueField.getText().trim(); @@ -1048,7 +1031,9 @@ public class OptsAndParamsPage } /** - * recover options and parameters from GUI + * Answers a list of arguments representing all the options and arguments + * selected on the dialog, holding their chosen or input values. Optional + * parameters which were not selected are not included. * * @return */ @@ -1057,7 +1042,7 @@ public class OptsAndParamsPage List argSet = new ArrayList<>(); for (OptionBox opts : getOptSet().values()) { - OptionI opt = opts.getOptionIfEnabled(); + ArgumentI opt = opts.getSelectedOption(); if (opt != null) { argSet.add(opt); @@ -1065,7 +1050,7 @@ public class OptsAndParamsPage } for (ParamBox parambox : getParamSet().values()) { - ParameterI parm = parambox.getParameter(); + ArgumentI parm = parambox.getParameter(); if (parm != null) { argSet.add(parm); @@ -1074,4 +1059,64 @@ public class OptsAndParamsPage return argSet; } + + /** + * A helper method that constructs and returns a CombBox for choice of the + * possible option values. If display names are provided, then these are added + * as options, otherwise the actual values are added. + * + * @param opt + * @return + */ + protected JComboBox buildComboBox(OptionI opt) + { + JComboBox cb = null; + List displayNames = opt.getDisplayNames(); + if (displayNames != null) + { + cb = JvSwingUtils.buildComboWithTooltips(displayNames, + opt.getPossibleValues()); + } + else + { + cb = new JComboBox<>(); + for (String v : opt.getPossibleValues()) + { + cb.addItem(v); + } + } + return cb; + } + + /* + * Answers the value corresponding to the selected item in the choice combo + * box. If display names were not provided, this is simply the selected + * value. If display names were provided, it is the value corresponding to + * the selected item index. + * + * @return + */ + protected static String getSelectedValue(OptionI opt, int sel) + { + List possibleValues = opt.getPossibleValues(); + String value = null; + if (possibleValues != null && possibleValues.size() == 1) + { + // Hack to make sure the default value for an enabled option with only + // one value is actually returned even if this.val is not displayed + value = possibleValues.get(0); + } + else + { + if (sel >= 0 && sel < possibleValues.size()) + { + value = possibleValues.get(sel); + } + else + { + value = opt.getValue(); + } + } + return value; + } } diff --git a/src/jalview/gui/Preferences.java b/src/jalview/gui/Preferences.java index 5382f8d..3259909 100755 --- a/src/jalview/gui/Preferences.java +++ b/src/jalview/gui/Preferences.java @@ -86,6 +86,9 @@ import ext.edu.ucsf.rbvi.strucviz2.StructureManager; */ public class Preferences extends GPreferences { + // suggested list delimiter character + public static final String COMMA = ","; + public static final String HMMSEARCH_SEQCOUNT = "HMMSEARCH_SEQCOUNT"; public static final String HMMINFO_GLOBAL_BACKGROUND = "HMMINFO_GLOBAL_BACKGROUND"; @@ -118,8 +121,6 @@ public class Preferences extends GPreferences public static final String CYGWIN_PATH = "CYGWIN_PATH"; - public static final String HMMSEARCH_DB_PATHS = "HMMSEARCH_DB_PATHS"; - public static final String HMMSEARCH_DBS = "HMMSEARCH_DBS"; public static final String SORT_ANNOTATIONS = "SORT_ANNOTATIONS"; diff --git a/src/jalview/hmmer/HMMERParamStore.java b/src/jalview/hmmer/HMMERParamStore.java index fbab7a9..00cae85 100644 --- a/src/jalview/hmmer/HMMERParamStore.java +++ b/src/jalview/hmmer/HMMERParamStore.java @@ -15,10 +15,10 @@ import jalview.ws.params.simple.LogarithmicParameter; import jalview.ws.params.simple.Option; import jalview.ws.params.simple.StringParameter; +import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collection; import java.util.List; import java.util.Scanner; @@ -101,39 +101,6 @@ public final class HMMERParamStore implements ParamDatastoreI /* * 'Options' */ - addChoiceOfHmm(args); - - String names = Cache.getProperty(Preferences.HMMSEARCH_DBS); - if (names != null && !names.isEmpty()) - { - List databases = new ArrayList<>(); - databases.add(MessageManager.getString(HMMSearch.THIS_ALIGNMENT_KEY)); - Scanner nameScanner = new Scanner(names); - - if (nameScanner.hasNext()) - { - while (nameScanner.hasNext()) - { - String next = nameScanner.next(); - if ("null".equals(next)) - { - Cache.setProperty(Preferences.HMMSEARCH_DBS, ""); - Cache.setProperty(Preferences.HMMSEARCH_DB_PATHS, ""); - } - else - { - databases.add(next); - } - } - } - nameScanner.close(); - args.add(new StringParameter( - MessageManager.getString(HMMSearch.DATABASE_KEY), - MessageManager.getString("label.database_for_hmmsearch"), - true, MessageManager.getString(HMMSearch.THIS_ALIGNMENT_KEY), - MessageManager.getString(HMMSearch.THIS_ALIGNMENT_KEY), - databases)); - } args.add(new BooleanOption( MessageManager.getString(HMMSearch.AUTO_ALIGN_SEQS_KEY), MessageManager.getString("label.auto_align_seqs_desc"), false, @@ -150,6 +117,10 @@ public final class HMMERParamStore implements ParamDatastoreI /* * 'Parameters' */ + addChoiceOfHmm(args); + + addChoiceOfDatabase(args); + args.add(new IntegerParameter( MessageManager.getString(HMMSearch.NUMBER_OF_RESULTS_KEY), MessageManager.getString("label.number_of_results_desc"), true, @@ -158,7 +129,8 @@ public final class HMMERParamStore implements ParamDatastoreI MessageManager.getString(HMMSearch.REPORTING_CUTOFF_KEY), null, true, HMMSearch.CUTOFF_NONE, HMMSearch.CUTOFF_NONE, Arrays.asList(HMMSearch.CUTOFF_NONE, HMMSearch.CUTOFF_EVALUE, - HMMSearch.CUTOFF_SCORE))); + HMMSearch.CUTOFF_SCORE), + null)); args.add(new LogarithmicParameter( MessageManager.getString(HMMSearch.SEQ_EVALUE_KEY), MessageManager.getString("label.seq_e_value_desc"), false, 1D, @@ -180,6 +152,56 @@ public final class HMMERParamStore implements ParamDatastoreI } /** + * Constructs a choice parameter for database to search; always includes 'this + * alignment', and also includes any databases held under user preferences key + * "HMMSEARCH_DBS" as a comma-delimited list + * + * @param args + */ + protected void addChoiceOfDatabase(List args) + { + String names = Cache.getProperty(Preferences.HMMSEARCH_DBS); + if (names == null || names.isEmpty()) + { + return; + } + + List filePaths = new ArrayList<>(); + List fileNames = new ArrayList<>(); + + String thisAlignment = MessageManager.getString(HMMSearch.THIS_ALIGNMENT_KEY); + filePaths.add(thisAlignment); + fileNames.add(thisAlignment); + + Scanner nameScanner = new Scanner(names); + nameScanner.useDelimiter(Preferences.COMMA); + + while (nameScanner.hasNext()) + { + String next = nameScanner.next(); + if ("null".equals(next)) + { + Cache.setProperty(Preferences.HMMSEARCH_DBS, ""); + } + else + { + filePaths.add(next); + int pos = next.lastIndexOf(File.separator); + String fileName = next.substring(pos + 1); + fileNames.add(fileName); + } + } + nameScanner.close(); + ArgumentI databasesOption = new StringParameter( + MessageManager.getString(HMMSearch.DATABASE_KEY), + MessageManager.getString("label.database_for_hmmsearch"), true, + thisAlignment, + thisAlignment, + filePaths, fileNames); + args.add(databasesOption); + } + + /** * Answers default parameters for hmmalign, taking into account any configured * as user preferences * @@ -216,7 +238,7 @@ public final class HMMERParamStore implements ParamDatastoreI String defseq = options.get(0); ArgumentI arg = new StringParameter( MessageManager.getString("label.use_hmm"), null, true, defseq, - defseq, options); + defseq, options, null); args.add(arg); } } @@ -256,7 +278,7 @@ public final class HMMERParamStore implements ParamDatastoreI */ if (!viewport.getAlignment().getGroups().isEmpty()) { - Collection options = new ArrayList<>(); + List options = new ArrayList<>(); options.add(MessageManager.getString("label.alignment")); options.add(MessageManager.getString("label.groups_and_alignment")); options.add(MessageManager.getString("label.groups")); diff --git a/src/jalview/util/StringUtils.java b/src/jalview/util/StringUtils.java index 2e8ace8..3c5ba92 100644 --- a/src/jalview/util/StringUtils.java +++ b/src/jalview/util/StringUtils.java @@ -107,29 +107,6 @@ public class StringUtils } /** - * Returns the last part of 'input' after the last occurrence of 'token'. For - * example to extract only the filename from a full path or URL. - * - * @param input - * @param token - * a delimiter which must be in regular expression format - * @return - */ - public static String getLastToken(String input, String token) - { - if (input == null) - { - return null; - } - if (token == null) - { - return input; - } - String[] st = input.split(token); - return st[st.length - 1]; - } - - /** * Parses the input string into components separated by the delimiter. Unlike * String.split(), this method will ignore occurrences of the delimiter which * are nested within single quotes in name-value pair values, e.g. a='b,c'. @@ -146,7 +123,7 @@ public class StringUtils { return null; } - List jv = new ArrayList(); + List jv = new ArrayList<>(); int cp = 0, pos, escape; boolean wasescaped = false, wasquoted = false; String lstitem = null; diff --git a/src/jalview/workers/InformationThread.java b/src/jalview/workers/InformationThread.java index d719189..d35025b 100644 --- a/src/jalview/workers/InformationThread.java +++ b/src/jalview/workers/InformationThread.java @@ -212,10 +212,13 @@ public class InformationThread extends AlignCalcWorker for (SequenceGroup group : alignment.getGroups()) { hmmSeqs = group.getHmmSequences(); - ProfilesI profiles = group.getHmmProfiles(); - float m = updateInformationAnnotation(hmmSeqs.get(0), profiles, group, - infos); - maxInformation = Math.max(maxInformation, m); + if (!hmmSeqs.isEmpty()) + { + ProfilesI profiles = group.getHmmProfiles(); + float m = updateInformationAnnotation(hmmSeqs.get(0), profiles, + group, infos); + maxInformation = Math.max(maxInformation, m); + } } /* diff --git a/src/jalview/ws/jws2/dm/JabaOption.java b/src/jalview/ws/jws2/dm/JabaOption.java index cbfbd3b..f1f5014 100644 --- a/src/jalview/ws/jws2/dm/JabaOption.java +++ b/src/jalview/ws/jws2/dm/JabaOption.java @@ -117,4 +117,10 @@ public class JabaOption implements jalview.ws.params.OptionI return opt; } + @Override + public List getDisplayNames() + { + return null; // not supported for Jaba options + } + } diff --git a/src/jalview/ws/params/OptionI.java b/src/jalview/ws/params/OptionI.java index 2c5386d..af8ae27 100644 --- a/src/jalview/ws/params/OptionI.java +++ b/src/jalview/ws/params/OptionI.java @@ -25,15 +25,49 @@ import java.util.List; public interface OptionI extends ArgumentI { - + /** + * Answers a URL with further details for this option, or null if none is + * known + * + * @return + */ URL getFurtherDetails(); + /** + * Answers true if the option is mandatory (a value must be chosen), false if + * it is optional + * + * @return + */ boolean isRequired(); + /** + * Answers the description of the option + * + * @return + */ String getDescription(); + /** + * Answers a list of possible values that may be chosen for the option (or + * null if not applicable) + * + * @return + */ List getPossibleValues(); - OptionI copy(); + /** + * Answers a list of display names corresponding to the possible values that + * may be chosen for the option (or null if not applicable) + * + * @return + */ + List getDisplayNames(); + /** + * Answers a new Option with a copy of the settings of this one + * + * @return + */ + OptionI copy(); } diff --git a/src/jalview/ws/params/simple/Option.java b/src/jalview/ws/params/simple/Option.java index f0126df..ce5d669 100644 --- a/src/jalview/ws/params/simple/Option.java +++ b/src/jalview/ws/params/simple/Option.java @@ -24,7 +24,6 @@ import jalview.ws.params.OptionI; import java.net.URL; import java.util.ArrayList; -import java.util.Collection; import java.util.List; public class Option implements OptionI @@ -43,12 +42,107 @@ public class Option implements OptionI String description; - ArrayList possibleVals = new ArrayList<>(); + List possibleVals; + + /* + * optional display names corresponding to possibleVals + */ + List displayVals; boolean required; URL fdetails; + /** + * Copy constructor + * + * @param opt + */ + public Option(Option opt) + { + name = opt.name; + value = opt.value; + defvalue = opt.defvalue; + description = opt.description; + if (opt.possibleVals != null) + { + possibleVals = new ArrayList<>(opt.possibleVals); + } + required = opt.required; + // URLs are singletons - so we copy by reference. nasty but true. + fdetails = opt.fdetails; + } + + public Option() + { + } + + /** + * Constructor including display names for possible values + * + * @param name2 + * @param description2 + * @param isrequired + * @param defValue + * @param val + * @param possibleVals + * @param fdetails + */ + public Option(String name2, String description2, boolean isrequired, + String defValue, String val, List possibleVals, + List displayNames, URL fdetails) + { + name = name2; + description = description2; + this.value = val; + this.required = isrequired; + this.defvalue = defValue; + if (possibleVals != null) + { + this.possibleVals = new ArrayList<>(possibleVals); + } + if (displayNames != null) + { + this.displayVals = new ArrayList<>(displayNames); + } + this.fdetails = fdetails; + } + + /** + * Constructor + * + * @param name2 + * @param description2 + * @param isrequired + * @param defValue + * @param val + * @param possibleVals + * @param fdetails + */ + public Option(String name2, String description2, boolean isrequired, + String defValue, String val, List possibleVals, + URL fdetails) + { + this(name2, description2, isrequired, defValue, val, possibleVals, null, + fdetails); + } + + @Override + public OptionI copy() + { + Option opt = new Option(this); + return opt; + } + + /** + * toString method to help identify options in the debugger only + */ + @Override + public String toString() + { + return this.getClass().getName() + ":" + name; + } + @Override public String getName() { @@ -91,64 +185,9 @@ public class Option implements OptionI return possibleVals; } - public Option(Option opt) - { - name = new String(opt.name); - if (opt.value != null) - { - value = new String(opt.value); - } - if (opt.defvalue != null) - { - defvalue = new String(opt.defvalue); - } - if (opt.description != null) - { - description = new String(opt.description); - } - if (opt.possibleVals != null) - { - possibleVals = (ArrayList) opt.possibleVals.clone(); - } - required = opt.required; - // URLs are singletons - so we copy by reference. nasty but true. - fdetails = opt.fdetails; - } - - public Option() - { - } - - public Option(String name2, String description2, boolean isrequired, - String defValue, String value, Collection possibleVals, - URL fdetails) - { - name = name2; - description = description2; - this.value = value; - this.required = isrequired; - this.defvalue = defValue; - if (possibleVals != null) - { - this.possibleVals = new ArrayList<>(); - this.possibleVals.addAll(possibleVals); - } - this.fdetails = fdetails; - } - @Override - public OptionI copy() - { - Option opt = new Option(this); - return opt; - } - - /** - * toString method to help identify options in the debugger only - */ - @Override - public String toString() + public List getDisplayNames() { - return this.getClass().getName() + ":" + name; + return displayVals; } } diff --git a/src/jalview/ws/params/simple/StringParameter.java b/src/jalview/ws/params/simple/StringParameter.java index b61836a..d3d899c 100644 --- a/src/jalview/ws/params/simple/StringParameter.java +++ b/src/jalview/ws/params/simple/StringParameter.java @@ -3,7 +3,7 @@ package jalview.ws.params.simple; import jalview.ws.params.ParameterI; import jalview.ws.params.ValueConstrainI; -import java.util.Collection; +import java.util.List; public class StringParameter extends Option implements ParameterI { @@ -46,6 +46,8 @@ public class StringParameter extends Option implements ParameterI { this.name = parm.name; this.defvalue = parm.defvalue; + this.possibleVals = parm.possibleVals; + this.displayVals = parm.displayVals; } public StringParameter(String name, String description, boolean required, @@ -65,7 +67,8 @@ public class StringParameter extends Option implements ParameterI } /** - * Constructor for a parameter with a list of possible values + * Constructor for a parameter with a list of possible values and (optionally) + * corresponding display names * * @param name2 * @param description2 @@ -73,12 +76,13 @@ public class StringParameter extends Option implements ParameterI * @param defValue * @param value * @param possibleVals + * @param displayNames */ public StringParameter(String name2, String description2, boolean isrequired, String defValue, String value, - Collection possibleVals) + List possibleVals, List displayNames) { super(name2, description2, isrequired, defValue, value, possibleVals, - null); + displayNames, null); } } diff --git a/src/jalview/ws/rest/InputType.java b/src/jalview/ws/rest/InputType.java index 88431a6..c83879a 100644 --- a/src/jalview/ws/rest/InputType.java +++ b/src/jalview/ws/rest/InputType.java @@ -30,7 +30,6 @@ import jalview.ws.params.simple.Option; import java.io.UnsupportedEncodingException; import java.nio.charset.Charset; import java.util.ArrayList; -import java.util.Collection; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -58,9 +57,9 @@ public abstract class InputType { NUC, PROT, MIX; - public static Collection toStringValues() + public static List toStringValues() { - Collection c = new ArrayList(); + List c = new ArrayList<>(); for (molType type : values()) { c.add(type.toString()); @@ -75,7 +74,7 @@ public abstract class InputType public int max = 0; // unbounded - protected ArrayList inputData = new ArrayList(); + protected List inputData = new ArrayList<>(); /** * initialise the InputType with a list of jalview data classes that the @@ -104,7 +103,9 @@ public abstract class InputType public boolean validFor(RestJob restJob) { if (!validFor(restJob.rsd)) + { return false; + } for (Class cl : inputData) { if (!restJob.hasDataOfType(cl)) @@ -118,7 +119,9 @@ public abstract class InputType public boolean validFor(RestServiceDescription restServiceDescription) { if (!restServiceDescription.inputParams.values().contains(this)) + { return false; + } return true; } @@ -270,7 +273,7 @@ public abstract class InputType public List getBaseOptions() { - ArrayList opts = new ArrayList(); + ArrayList opts = new ArrayList<>(); opts.add(new IntegerParameter("min", "Minimum number of data of this type", true, 1, min, 0, -1)); opts.add(new IntegerParameter("max", @@ -295,7 +298,7 @@ public abstract class InputType public void configureFromArgumentI(List currentSettings) throws InvalidArgumentException { - ArrayList urltoks = new ArrayList(); + List urltoks = new ArrayList<>(); String rg; for (ArgumentI arg : currentSettings) { diff --git a/test/jalview/util/StringUtilsTest.java b/test/jalview/util/StringUtilsTest.java index 084219a..9d805cc 100644 --- a/test/jalview/util/StringUtilsTest.java +++ b/test/jalview/util/StringUtilsTest.java @@ -87,19 +87,6 @@ public class StringUtilsTest } @Test(groups = { "Functional" }) - public void testGetLastToken() - { - assertNull(StringUtils.getLastToken(null, null)); - assertNull(StringUtils.getLastToken(null, "/")); - assertEquals("a", StringUtils.getLastToken("a", null)); - - assertEquals("abc", StringUtils.getLastToken("abc", "/")); - assertEquals("c", StringUtils.getLastToken("abc", "b")); - assertEquals("file1.dat", StringUtils.getLastToken( - "file://localhost:8080/data/examples/file1.dat", "/")); - } - - @Test(groups = { "Functional" }) public void testSeparatorListToArray() { String[] result = StringUtils.separatorListToArray( @@ -145,7 +132,7 @@ public class StringUtilsTest public void testListToDelimitedString() { assertEquals("", StringUtils.listToDelimitedString(null, ";")); - List list = new ArrayList(); + List list = new ArrayList<>(); assertEquals("", StringUtils.listToDelimitedString(list, ";")); list.add("now"); assertEquals("now", StringUtils.listToDelimitedString(list, ";")); -- 1.7.10.2