From 44ac7ea37b8cb3d4562a5575ddadba296d649a7a Mon Sep 17 00:00:00 2001 From: Ben Soares Date: Fri, 24 Feb 2023 14:43:38 +0000 Subject: [PATCH] JAL-629 helper function for getting sensible structure (or other arg value) --- src/jalview/bin/ArgParser.java | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/src/jalview/bin/ArgParser.java b/src/jalview/bin/ArgParser.java index 2290182..3dc7921 100644 --- a/src/jalview/bin/ArgParser.java +++ b/src/jalview/bin/ArgParser.java @@ -121,8 +121,6 @@ public class ArgParser private boolean defaultBoolValue = false; - private int argIndex = -1; - public String toLongString() { StringBuilder sb = new StringBuilder(); @@ -205,16 +203,6 @@ public class ArgParser { return defaultBoolValue; } - - private void setArgIndex(int i) - { - this.argIndex = i; - } - - protected int getArgIndex() - { - return this.argIndex; - } } public static class ArgValues @@ -869,6 +857,25 @@ public class ArgParser ArgValues av = getArgValues(a); return av == null ? false : av.getBoolean(); } + + protected ArgValue getClosestPreviousArgValueOfArg(ArgValue thisAv, + Arg a) + { + ArgValue closestAv = null; + int thisArgIndex = thisAv.getArgIndex(); + ArgValues compareAvs = this.getArgValues(a); + int closestPreviousIndex = -1; + for (ArgValue av : compareAvs.getArgValueList()) + { + int argIndex = av.getArgIndex(); + if (argIndex < thisArgIndex && argIndex > closestPreviousIndex) + { + closestPreviousIndex = argIndex; + closestAv = av; + } + } + return closestAv; + } } private static final Collection bootstrapArgs = new ArrayList( -- 1.7.10.2