info.novatec.testit.livingdoc.runner.FactoryConverter Maven / Gradle / Ivy
/* Copyright (c) 2006 Pyxis Technologies inc.
*
* This is free software; you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF site:
* http://www.fsf.org. */
package info.novatec.testit.livingdoc.runner;
import static info.novatec.testit.livingdoc.util.CollectionUtil.shift;
import static info.novatec.testit.livingdoc.util.CollectionUtil.toList;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
import info.novatec.testit.livingdoc.util.ClassUtils;
import info.novatec.testit.livingdoc.util.cli.Converter;
/**
* A converter which creates a new instance of an object. This converter expects
* a semi-colon comma separated list of values. The first value is the class
* name of the object to instantiate. Following values represent a list of
* parameters. Any semi-colon special character
*
*
* %3B
*
*
* found inside an actual parameter will be converted to
*
*
* ;
*
*
* (way to keep semi-colon as parameter)
*
* The target class must abide to the following rules:
*
* - When no parameter is expected, it must provide a default constructor
* - Otherwise, if parameters are expected, it must provide a constructor
* accepting an array of string.
*
*
* Note: it could be interesting to see if we can make
* {@link info.novatec.testit.livingdoc.util.ClassUtils#findBestTypedConstructor(Class,java.lang.Object...)}
* smarter and use it.
*/
public class FactoryConverter implements Converter
© 2015 - 2025 Weber Informatics LLC | Privacy Policy