Given:
public class Dummy
{
/**
* Constructor meant to be used for test code.
* @param scope test-specific "globals"
* @param value some user-supplied value
*/
public Dummy(SingletonScope scope, int value)
{
// ...
}
/**
* Constructor meant to be used by end-users.
* @param value some user-supplied value
*/
public Dummy(int value)
{
scope = someDefaultValue();
// ...
}
}
Is there a design pattern that will allow me to expose the first method to test classes that are scattered across multiple packages, and the second method to end-users?
I don't want to expose the first constructor to end-users because it clutters the API specification and I don't want it to form a de-facto standard (similar to sun.misc.Unsafe
). The solution cannot use dependency injection or reflection.
Aucun commentaire:
Enregistrer un commentaire