
org.specrunner.converters.UtilConverter Maven / Gradle / Ivy
/*
SpecRunner - Acceptance Test Driven Development Tool
Copyright (C) 2011-2014 Thiago Santos
This program 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 3 of the License, or
(at your option) any later version.
This program 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, see
*/
package org.specrunner.converters;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.specrunner.SRServices;
import org.specrunner.plugins.PluginException;
import org.specrunner.plugins.core.objects.IObjectManager;
import org.specrunner.util.UtilLog;
/**
* Converter utilities.
*
* @author Thiago Santos
*
*/
public final class UtilConverter {
/**
* Map of primitive types for correct use of
* <type>.isInstance(...)
.
*/
public static final Map, Class>> PRIMITIVES = new HashMap, Class>>();
/**
* Default constructor.
*/
private UtilConverter() {
}
static {
PRIMITIVES.put(boolean.class, Boolean.class);
PRIMITIVES.put(char.class, Character.class);
PRIMITIVES.put(byte.class, Byte.class);
PRIMITIVES.put(short.class, Short.class);
PRIMITIVES.put(int.class, Integer.class);
PRIMITIVES.put(long.class, Long.class);
PRIMITIVES.put(float.class, Float.class);
PRIMITIVES.put(double.class, Double.class);
}
/**
* Get errors.
*
* @param clazz
* O errors.
* @return The class.
*/
public static Class> getWrapper(Class> clazz) {
Class> primitive = PRIMITIVES.get(clazz);
return primitive == null ? clazz : primitive;
}
/**
* Prepare arguments.
*
* @param method
* The method.
* @param arguments
* The arguments.
* @throws PluginException
* On preparation errors.
*/
public static void prepareMethodArguments(Method method, List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy