これが工場出荷時のパターンかどうかについて、先生と少し議論しています。あなたの意見を聞いてもいいですか?
public class UrlFactory {
private static boolean testMode;
private static long testDate;
public static URLConnection fetchConnection(String url)
throws IOException
{
URL address = new URL(url);
if(testMode)
return new MockURLConnection(address, testDate);
return address.openConnection();
}
public static void SetTestMode(long testDate)
{
UrlFactory.testMode = true;
UrlFactory.testDate = testDate;
}
public static void UnSetTestMode()
{
UrlFactory.testMode = false;
}
}