私は Java を初めて使用し、値の ArrayList を含む LinkedHashMap をロードしようとしています。API ベースのクエリ結果 (Salesforce) からクエリ結果の値を読み込もうとしています。
ここにエラーがあります:「別のメソッドで定義された内部クラス内の非最終変数ブレークダウンを参照できません」-ブレークダウン変数に赤で下線が引かれ、このメッセージが表示されます。以下の懸念のある行に注意してください。
コード
public LinkedHashMap<String, ArrayList<String>> sfFundIdsByContact;
public ArrayList<String> getFundsIDsForContact(Contact aContact)
{
QueryResult queryResults = null;
ArrayList<String> ids = new ArrayList<String>();
int index = 0;
Boolean done = false;
String contactid = aContact.getId();
String SCCPBId = null;
if(sfFundIdsByContact == null || sfFundIdsByContact.size() <= 0){
//Do the Salesforce API CALL and Return the results
...
while (! done)
{
SObject[] records = queryResults.getRecords();
for ( int i = 0; i < records.length; ++i )
{
if(sfFundIdsByContact.containsKey(breakdown.getSalesConnect__Contact__c())){
sfFundIdsByContact.get(breakdown.getSalesConnect__Contact__c()).add(breakdown.getId());
} else {
//Line below in the add(breakdown.getId() - contains the error
sfFundIdsByContact.put(breakdown.getSalesConnect__Contact__c(), new ArrayList<String>() {{ add(breakdown.getId()); }});
}
}
すべての提案を歓迎します。