@Test public void fromInstanceSimple() { assertEquals( newArrayList("56"), createFactory(new Errors(), Simple.class).build().getOrThrow() .fromInstance(new Simple(56))); }
@SuppressWarnings("unchecked") public List<String> fromInstance(T instance) { List<String> parameters = Lists.newArrayListWithCapacity(fields.length); for (int i = 0; i < fields.length; i++) { try { Field field = fields[i]; String parameterAsString; if (field != null) { Object value = field.get(instance); if (wrapInOption.get(i)) { value = ((Option<Object>) value).getOrElse((Object) null); } parameterAsString = value == null ? null : converters[i].toString(value); } else { parameterAsString = null; } parameters.add(parameterAsString); } catch (IllegalArgumentException e) { throw new RuntimeException(e); } catch (IllegalAccessException e) { throw new RuntimeException(e); } } return parameters; }
InstantiatorImpl implements Instantiator<T> { @SuppressWarnings("unchecked") public List<String> fromInstance(T instance) { List<String> parameters = Lists.newArrayListWithCapacity(fields.length); for (int i = 0; i < fields.length; i++) { try { Field field = fields[i]; String parameterAsString; if (field != null) { Object value = field.get(instance); if (wrapInOption.get(i)) { value = ((Option<Object>) value).getOrElse((Object) null); } parameterAsString = value == null ? null : converters[i].toString(value); } else { parameterAsString = null; } parameters.add(parameterAsString); } catch (IllegalArgumentException e) { throw new RuntimeException(e); } catch (IllegalAccessException e) { throw new RuntimeException(e); } } return parameters; } }
InstantiatorImpl implements Instantiator<T> { @SuppressWarnings("unchecked") public List<String> fromInstance(T instance) { List<String> parameters = Lists.newArrayListWithCapacity(fields.length); for (int i = 0; i < fields.length; i++) { try { Field field = fields[i]; String parameterAsString; if (field != null) { Object value = field.get(instance); if (wrapInOption.get(i)) { value = ((Option<Object>) value).getOrElse((Object) null); } parameterAsString = value == null ? null : converters[i].toString(value); } else { parameterAsString = null; } parameters.add(parameterAsString); } catch (IllegalArgumentException e) { throw new RuntimeException(e); } catch (IllegalAccessException e) { throw new RuntimeException(e); } } return parameters; } InstantiatorImpl(
      Constructor<T> constructor,
      Converter<?>[] converters,
      Field[] fields,
      BitSet optionality,
      BitSet wrapInOption,
      String[] defaultValues,
      Object[] defaultConstants,
      String[] parameterNames); }
InstantiatorImpl implements Instantiator<T> { @SuppressWarnings("unchecked") public List<String> fromInstance(T instance) { List<String> parameters = Lists.newArrayListWithCapacity(fields.length); for (int i = 0; i < fields.length; i++) { try { Field field = fields[i]; String parameterAsString; if (field != null) { Object value = field.get(instance); if (wrapInOption.get(i)) { value = ((Option<Object>) value).getOrElse((Object) null); } parameterAsString = value == null ? null : converters[i].toString(value); } else { parameterAsString = null; } parameters.add(parameterAsString); } catch (IllegalArgumentException e) { throw new RuntimeException(e); } catch (IllegalAccessException e) { throw new RuntimeException(e); } } return parameters; } InstantiatorImpl(
      Constructor<T> constructor,
      Converter<?>[] converters,
      Field[] fields,
      BitSet optionality,
      BitSet wrapInOption,
      String[] defaultValues,
      Object[] defaultConstants,
      String[] parameterNames); @Override T newInstance(String... values); @Override T newInstance(Map<String, String> namedValues); @Override T newInstance(Iterable<String> values); @SuppressWarnings("unchecked") List<String> fromInstance(T instance); @Override Constructor<T> getConstructor(); @Override String toString(); }
InstantiatorImpl implements Instantiator<T> { @SuppressWarnings("unchecked") public List<String> fromInstance(T instance) { List<String> parameters = Lists.newArrayListWithCapacity(fields.length); for (int i = 0; i < fields.length; i++) { try { Field field = fields[i]; String parameterAsString; if (field != null) { Object value = field.get(instance); if (wrapInOption.get(i)) { value = ((Option<Object>) value).getOrElse((Object) null); } parameterAsString = value == null ? null : converters[i].toString(value); } else { parameterAsString = null; } parameters.add(parameterAsString); } catch (IllegalArgumentException e) { throw new RuntimeException(e); } catch (IllegalAccessException e) { throw new RuntimeException(e); } } return parameters; } InstantiatorImpl(
      Constructor<T> constructor,
      Converter<?>[] converters,
      Field[] fields,
      BitSet optionality,
      BitSet wrapInOption,
      String[] defaultValues,
      Object[] defaultConstants,
      String[] parameterNames); @Override T newInstance(String... values); @Override T newInstance(Map<String, String> namedValues); @Override T newInstance(Iterable<String> values); @SuppressWarnings("unchecked") List<String> fromInstance(T instance); @Override Constructor<T> getConstructor(); @Override String toString();  }