@Override public boolean primary() { return param.primary(); }
@Override public boolean primary() { return param.primary(); }
@Override public boolean primary() { return param.primary(); }
/** * Get the ParamModel that corresponds to the operand * (primary parameter). Return null if none. */ private ParamModel getOperandModel() { for (ParamModel pm : commandModel.getParameters()) { if (pm.getParam().primary()) return pm; } return null; }
/** * Get the ParamModel that corresponds to the operand * (primary parameter). Return null if none. */ protected ParamModel getOperandModel() { for (ParamModel pm : commandModel.getParameters()) { if (pm.getParam().primary()) return pm; } return null; }
/** * Get the ParamModel that corresponds to the operand * (primary parameter). Return null if none. */ private ParamModel getOperandModel() { for (ParamModel pm : commandModel.getParameters()) { if (pm.getParam().primary()) return pm; } return null; }
/** * Get the ParamModel that corresponds to the operand * (primary parameter). Return null if none. */ private ParamModel getOperandModel() { for (ParamModel pm : commandModel.getParameters()) { if (pm.getParam().primary()) return pm; } return null; }
Option(Param p, Field f) { final Class<?> ftype = f.getType(); name = p.name(); if(!ok(name)) { name = f.getName(); } required = !p.optional(); operand = p.primary(); defaultValue = p.defaultValue(); type = ftype; } @Override
/** * Get the ParamModel that corresponds to the operand * (primary parameter). Return null if none. */ protected ParamModel getOperandModel() { for (ParamModel pm : commandModel.getParameters()) { if (pm.getParam().primary()) return pm; } return null; }
public boolean isParamId(String key) { if (getParam().primary()) { return "DEFAULT".equals(key) || getName().equalsIgnoreCase(key); } return getName().equalsIgnoreCase(key) || getParam().shortName().equals(key) || getParam().alias().equalsIgnoreCase(key); }
private void extract(final Object target, final Collection<String> parameterNamesToExclude, final ParameterMap paramMap) throws IllegalArgumentException, IllegalAccessException { for (Field f : target.getClass().getFields()) { final Param param = f.getAnnotation(Param.class); if (param != null && ! parameterNamesToExclude.contains(f.getName())) { final Object fieldValue = f.get(target); if (fieldValue != null) { final String paramName = param.primary() ? "DEFAULT" : CommandModel.getParamName(param, f); if (param.multiple()) { paramMap.set(paramName, multipleValue(param, f.get(target))); } else { paramMap.set(paramName, singleValue(param, f.get(target))); } } } } }
private void extract(final Object target, final Collection<String> parameterNamesToExclude, final ParameterMap paramMap) throws IllegalArgumentException, IllegalAccessException { for (Field f : target.getClass().getFields()) { final Param param = f.getAnnotation(Param.class); if (param != null && ! parameterNamesToExclude.contains(f.getName())) { final Object fieldValue = f.get(target); if (fieldValue != null) { final String paramName = param.primary() ? "DEFAULT" : CommandModel.getParamName(param, f); if (param.multiple()) { paramMap.set(paramName, multipleValue(param, f.get(target))); } else { paramMap.set(paramName, singleValue(param, f.get(target))); } } } } }
private void extract(final Object target, final Collection<String> parameterNamesToExclude, final ParameterMap paramMap) throws IllegalArgumentException, IllegalAccessException { for (Field f : target.getClass().getFields()) { final Param param = f.getAnnotation(Param.class); if (param != null && ! parameterNamesToExclude.contains(f.getName())) { final Object fieldValue = f.get(target); if (fieldValue != null) { final String paramName = param.primary() ? "DEFAULT" : CommandModel.getParamName(param, f); if (param.multiple()) { paramMap.set(paramName, multipleValue(param, f.get(target))); } else { paramMap.set(paramName, singleValue(param, f.get(target))); } } } } }
public boolean isParamId(String key) { if (getParam().primary()) { return "DEFAULT".equals(key) || getName().equalsIgnoreCase(key); } return getName().equalsIgnoreCase(key) || getParam().shortName().equals(key) || getParam().alias().equalsIgnoreCase(key); }
/** * Get ParamModel for long option name. */ private ParamModel lookupLongOption(String s) { if (s == null || s.length() == 0) return null; // XXX - for now, fake it if no options if (options == null) { // no valid options specified so everything is valid return new ParamModelData(s, String.class, true, null); } for (ParamModel od : options) { if (od.getParam().primary()) continue; if (s.equalsIgnoreCase(od.getName())) return od; if (s.equalsIgnoreCase(od.getParam().alias())) return od; } return null; }
/** * Get ParamModel for long option name. */ private ParamModel lookupLongOption(String s) { if (s == null || s.length() == 0) return null; // XXX - for now, fake it if no options if (options == null) { // no valid options specified so everything is valid return new ParamModelData(s, String.class, true, null); } for (ParamModel od : options) { if (od.getParam().primary()) continue; if (s.equalsIgnoreCase(od.getName())) return od; if (s.equalsIgnoreCase(od.getParam().alias())) return od; } return null; }
if (opt.getParam().password()) continue; // don't print passwords if (opt.getParam().primary()) continue;
if (param.primary()) {
private void addParamUsage( ActionReport report, CommandModel.ParamModel model) { Param param = model.getParam(); if (param != null) { // this is a param. String paramName = model.getName().toLowerCase(Locale.ENGLISH); // skip "hidden" options if (paramName.startsWith("_")) { return; } // do not want to display password in the usage if (param.password()) { return; } // do not want to display obsolete options if (param.obsolete()) { return; } if (param.primary()) { // if primary then it's an operand report.getTopMessagePart().addProperty(paramName + "_operand", model.getLocalizedDescription()); } else { report.getTopMessagePart().addProperty(paramName, model.getLocalizedDescription()); } } }
private void addParamUsage( ActionReport report, CommandModel.ParamModel model) { Param param = model.getParam(); if (param != null) { // this is a param. String paramName = model.getName().toLowerCase(Locale.ENGLISH); // skip "hidden" options if (paramName.startsWith("_")) { return; } // do not want to display password in the usage if (param.password()) { return; } // do not want to display obsolete options if (param.obsolete()) { return; } if (param.primary()) { // if primary then it's an operand report.getTopMessagePart().addProperty(paramName + "_operand", model.getLocalizedDescription()); } else { report.getTopMessagePart().addProperty(paramName, model.getLocalizedDescription()); } } }