我有以下方法,我在其中创建多个列表和计数器。从 Java 的角度来看,我认为这不是正确的方法。我在想我可以使用具有键值对的映射,并且应该有键并且它的值类型是列表。您能否告知如何将我的以下代码更改为使用地图,以及如何对其进行编辑以使其更有意义。
public Map<String, Object> abclistcount(String Id)
{
List<abcIdentifierabcobject> successfulboaabcIdentifierabcobjects = new ArrayList <abcIdentifierabcobject>();
List<abcIdentifierabcobject> failureboaabcIdentifierabcobjects = new ArrayList <abcIdentifierabcobject>();
List<abcIdentifierabcobject> exceptionboasettlement = new ArrayList <abcIdentifierabcobject>();
List<abcIdentifierabcobject> successfulboasettlement = new ArrayList <abcIdentifierabcobject>();
HashMap<String, Object> data = new HashMap<String, Object>();
List<defInfo> reportData = new ArrayList<defInfo>();
List<abcIdentifierabcobject> abcIdentifierabcobjects = futuresFeedHome.getabcIdentifierabcobjects(fileIdentifier);
//counter to track
int failurecounterboafeed = 0;
int failurecounterboasettlement =0;
int sucessboasettlement =0;
int successboacount=0;
if (abcIdentifierabcobjects !=null && abcIdentifierabcobjects.size()>0)
{
for (abcIdentifierabcobject f : abcIdentifierabcobjects)
{
defInfo abjkfeed = new defInfo();
// INVALID_STATIC_DATA fails at boa_futures feed side itself
if ("INVALID_STATIC_DATA".equalsIgnoreCase(f.getStatus()) /* INVALID RECORD*/)
{
failureboaabcIdentifierabcobjects.add(f) ;
failurecounterboafeed++;
abjkfeed.setHeader("Futures Intraday Report");
abjkfeed.setData(failureboaabcIdentifierabcobjects);
reportData.add(abjkfeed);
}
//if not fail in boa_futures_feed then
successfulboaabcIdentifierabcobjects.add(f);
successboacount++;
}
for (abcIdentifierabcobject f : successfulboaabcIdentifierabcobjects)
{
Settlement settlement = f.getSettlement();
//tracking the records that are fail on boa_settlement side
//futher filtering fail at GEN EX queue or Awaiting ack
if (fwqConstants.AF_T_ZY_SETTLEMENT_EXCEPTION.equalsIgnoreCase(settlement.getCurrentWFQueue()) || fwqConstants.AF_T_ZY_SETTLEMENT_SENT_EX.equalsIgnoreCase(settlement.getCurrentWFQueue()))
{
exceptionboasettlement.add(f);
failurecounterboasettlement++;
}
defInfo successfulpayments = new defInfo();
//seprating the successful list of boa_settlement one in a seprate list
if (fwqConstants.AF_T_ZY_COMPLETED.equalsIgnoreCase(settlement.getCurrentWFQueue()) || fwqConstants.AF_T_ZY_SETTLEMENT_CREATED.equalsIgnoreCase(settlement.getCurrentWFQueue()))
{
successfulboasettlement.add(f);
sucessboasettlement++;
successfulpayments.setHeader("Successful Payments");
successfulpayments.setData(successfulboasettlement);
reportData.add(successfulpayments);
}
}
}
return data;
}
我将更正命名约定,但这次的重点是如何删除我在内部使用的许多数组列表。