我有一个常量文件abcder.constants
,如下所示
public static final String ABC_abbject_EOD = "DDD_Report";
public static final String CDE_abbject_INTRADAY = "FFD_Report";
现在我有下面的方法,如下所示
public void Gen(String[] toAddress, String[] ccAddress, String abbject,
String message, String defIdentifier, Date date)
现在在这个方法中可能有两种情况,要么defIdentifier
是,null
要么abbject
参数有值
- 因此,如果
defIdentifier
为 null 则abbject
具有来自 a 的值,abcderconstant
因此在这种情况下我必须做一些事情。这取决于它可以是ABC_abbject_EOD
或CDE_abbject_INTRADAY
- 如果
defIdentifier
不为空,abbject
则为空,那么在这种情况下,我必须执行其他操作
所以,我开发了如下所示的代码,请告知这是正确的方法
if (defIdentifier != null && abbject== null)
{
String s = defIdentifier + "-" + formatter.format(now.getTime()) + "." + "doc";
}
if (defIdentifier == null && abbject.equalsIgnoreCase(abcderconstants.ABC_abbject_EOD))
{
String s = "DDD-Report" + "-" + formatter.format(now.getTime()) + "." + "doc";
}
if (defIdentifier == null && abbject.equalsIgnoreCase(abcderconstants.CDE_abbject_INTRADAY))
{
String s = "FFD-Report" + "-" + formatter.format(now.getTime()) + "." + "doc";
}