Yes, No, NO NO NO NO
by in CodeSOD on 2024-07-31Mike was doing work for a mobile services provider. He found this in their code:
private static YesNoType toYesNo(String isYes)
{
if (isYes != null)
{
if (isYes.equalsIgnoreCase("Y"))
{
return YesNoType.fromString("Yes");
}
else
{
return YesNoType.fromString("No");
}
}
else
{
return YesNoType.fromString("No");
}
}
/**
* @param isYes
* @return
*/
private static YesNoType toYesNo(boolean isYes)
{
if (isYes)
{
return YesNoType.fromString("Yes");
}
else
{
return YesNoType.fromString("No");
}
}
/**
* @param isYes
* @return
*/
private static String fromYesNo(YesNoType isYes)
{
if (isYes != null)
{
String resultStr = isYes.toString();
if (resultStr.equalsIgnoreCase("Yes"))
{
return ("Yes");
}
else
{
return ("No");
}
}
else
{
return ("No");
}
}
/**
* @param isYes
* @return
*/
private static boolean isYesNo(YesNoType isYes)
{
boolean isBroadbandUser = false;
if (isYes != null && isYes.toString().equalsIgnoreCase("Yes"))
{
isBroadbandUser = true;
}
return isBroadbandUser;
}