com.beust.jcommander.Parameterized Java Examples
The following examples show how to use
com.beust.jcommander.Parameterized.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JCommanderPrefixTranslator.java From geowave with Apache License 2.0 | 6 votes |
public JCommanderPrefixTranslator() { try { // HP Fortify "Access Specifier Manipulation" // These fields are being modified by trusted code, // in a way that is not influenced by user input paraField = Parameterized.class.getDeclaredField("field"); paraField.setAccessible(true); paraMethod = Parameterized.class.getDeclaredField("method"); paraMethod.setAccessible(true); } catch (final NoSuchFieldException e) { // This is a programmer error, and will only happen if another // version of JCommander is being used. // newer versions of JCommander have renamed the member variables, try the old names try { paraField = Parameterized.class.getDeclaredField("m_field"); paraField.setAccessible(true); paraMethod = Parameterized.class.getDeclaredField("m_method"); paraMethod.setAccessible(true); } catch (NoSuchFieldException e2) { throw new RuntimeException(e); } } }
Example #2
Source File: TranslationEntryTest.java From geowave with Apache License 2.0 | 6 votes |
@Before public void setUp() { try { final Arguments args = new Arguments(); final ArrayList<Parameterized> params = (ArrayList<Parameterized>) Parameterized.parseArg(args); if (params.size() == 0) { fail("Could not find parameter"); } param = params.get(0); } catch (final SecurityException e) { // Should never trigger e.printStackTrace(); } obj = 4; prefix = "prefix"; aElement = Integer.class; entry = new TranslationEntry(param, obj, prefix, aElement); }
Example #3
Source File: JCommanderTranslationMap.java From geowave with Apache License 2.0 | 5 votes |
/** * This is a mapping between the created facade's field (e.g., field_0) and the JCommander * parameter (param) which lives in the object it was parsed from, 'item'. */ protected void addEntry( final String newFieldName, final Object item, final Parameterized param, final String prefix, final AnnotatedElement member) { translations.put(newFieldName, new TranslationEntry(param, item, prefix, member)); }
Example #4
Source File: TranslationEntry.java From geowave with Apache License 2.0 | 5 votes |
protected TranslationEntry( final Parameterized param, final Object object, final String prefix, final AnnotatedElement member) { this.param = param; this.object = object; this.prefix = prefix; this.member = member; prefixedNames = addPrefixToNames(); }
Example #5
Source File: JCommanderWrapper.java From jadx with Apache License 2.0 | 5 votes |
public void overrideProvided(T obj) { List<ParameterDescription> fieldsParams = jc.getParameters(); List<ParameterDescription> parameters = new ArrayList<>(1 + fieldsParams.size()); parameters.add(jc.getMainParameterValue()); parameters.addAll(fieldsParams); for (ParameterDescription parameter : parameters) { if (parameter.isAssigned()) { // copy assigned field value to obj Parameterized parameterized = parameter.getParameterized(); Object val = parameterized.get(parameter.getObject()); parameterized.set(obj, val); } } }
Example #6
Source File: TranslationEntry.java From geowave with Apache License 2.0 | 4 votes |
public Parameterized getParam() { return param; }