0

何か助けが必要です。私のコードは次のテンプレートです。customObject に複数の property1、property2、..property100 があるとします。

List<CustomObject> customObjectList = /*<method call to external API that returns the said list >*/
if(customObjectList != null && customObjectList.size() > 0){
    //*** point A ***<clone the Object>
    resultList = <some method that process the above list>(customObjectList)

    if(resultList.size() > 0){
        for(Iterator<Map.Entry<CustomObject, ExternalResponse>> itr = resultList.entrySet().iterator(); itr.hasNext();) {
            //code that modifies the properties in the CustomObjects
            //*** point B ***resetAProperty(<Object clone>)
        }
    }
}

ポイント B では、元のオブジェクトの変更されていない特定のプロパティを 1 つメソッドで使用する必要があります。これには2つの戦略があります。

  1. ポイント A でオブジェクトを複製し、複製されたコピーを使用して、上記のコードに示すようにプロパティを取得します。ポイント A では、for ループと
  2. マップしてオブジェクト名、プロパティの元の値の関連配列を形成し、それらをトラバースしてポイント B のプロパティの初期値を取得します。
4

1 に答える 1