return sb.toString();
}
- // Helper methods with safety checks
- protected static ArgValues getArgValues(Map<Arg, ArgValues> m, Arg a)
- {
- return m == null ? null : m.get(a);
- }
-
- public static List<ArgValue> getArgValueList(Map<Arg, ArgValues> m, Arg a)
- {
- ArgValues av = getArgValues(m, a);
- return av == null ? null : av.getArgValueList();
- }
-
- public static ArgValue getArgValue(Map<Arg, ArgValues> m, Arg a)
- {
- List<ArgValue> vals = getArgValueList(m, a);
- return (vals == null || vals.size() == 0) ? null : vals.get(0);
- }
-
- public static String getValue(Map<Arg, ArgValues> m, Arg a)
- {
- ArgValue av = getArgValue(m, a);
- return av == null ? null : av.getValue();
- }
-
- public static boolean hasValue(Map<Arg, ArgValues> m, Arg a)
- {
- if (!m.containsKey(a))
- return false;
- return getArgValue(m, a) != null;
- }
-
- public static boolean getBoolean(Map<Arg, ArgValues> m, Arg a)
- {
- ArgValues av = getArgValues(m, a);
- return av == null ? false : av.getBoolean();
- }
-
public static SubVals getSubVals(String item)
{
return new SubVals(item);
}
}
+ /**
+ * Helper class to allow easy extraction of information about specific
+ * argument values (without having to check for null etc all the time)
+ */
+ protected static class ArgValuesMap
+ {
+ protected Map<Arg, ArgValues> m;
+
+ protected ArgValuesMap(Map<Arg, ArgValues> map)
+ {
+ this.m = map;
+ }
+
+ protected ArgValues getArgValues(Arg a)
+ {
+ return m == null ? null : m.get(a);
+ }
+
+ protected List<ArgValue> getArgValueList(Arg a)
+ {
+ ArgValues av = getArgValues(a);
+ return av == null ? null : av.getArgValueList();
+ }
+
+ protected ArgValue getArgValue(Arg a)
+ {
+ List<ArgValue> vals = getArgValueList(a);
+ return (vals == null || vals.size() == 0) ? null : vals.get(0);
+ }
+
+ protected String getValue(Arg a)
+ {
+ ArgValue av = getArgValue(a);
+ return av == null ? null : av.getValue();
+ }
+
+ protected boolean hasValue(Arg a)
+ {
+ if (!m.containsKey(a))
+ return false;
+ return getArgValue(a) != null;
+ }
+
+ protected boolean getBoolean(Arg a)
+ {
+ ArgValues av = getArgValues(a);
+ return av == null ? false : av.getBoolean();
+ }
+ }
+
private static final Collection<String> bootstrapArgs = new ArrayList(
Arrays.asList("props", "debug"));