All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.peterwippermann.junit4.parameterizedsuite.ParameterContext Maven / Gradle / Ivy

package com.github.peterwippermann.junit4.parameterizedsuite;

import java.lang.reflect.Array;

/**
 * This singleton stores a parameter. This way parameters can be transferred between test classes.
* The type of the parameter is unbound and can also be an {@link Array}. Null is interpreted as "parameter is not set". *

* This implementation is not thread-safe. Concurrent implementations e.g. could use * {@link ThreadLocal}. * */ public class ParameterContext { private static Object context; public static

void setParameter(P parameter) { context = parameter; } /** * Retrieve the stored parameter. * * @param parameterClass - Enables type-safety at compile time. */ @SuppressWarnings("unchecked") public static

P getParameter(Class

parameterClass) { return (P) context; } public static void removeParameter() { setParameter(null); } /** * @return true, if parameter is not null. */ public static boolean isParameterSet() { return getParameter(Object.class) != null; } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy