如何将类的一个参数的值复制到另一个Collection对象?

时间:2016-12-17 18:12:57

标签: java data-structures collections

class ResourceDTO {
      String resourceName;
      List<AssociateResource> associateResource = new ArrayList<AssociateResource>;
      // getter-setter...
}


class AssociateResource {
      String associateName;
      // other attributes...
      // getter-setters...
}

现在,我有一个挑战,即每当ResourceDTO填充任何resourceName时,associateName都是相同的。我该怎么做?

Ex: - 如果一个流正在填充ResourceDTO,那么在“AssociateResource”变量列表中,“resourceName”应包含相同的名称。我该怎么做?任何帮助高度赞赏。

1 个答案:

答案 0 :(得分:1)

/home/ubuntu/Ytutor_Server/node_modules/mongodb-core/lib/topologies/shared.js:18 var nodejsversion = f('Node.js %s, %s', process.version, os.endianness()); ^ TypeError: Object #<Object> has no method 'endianness' at Object.<anonymous> (/home/ubuntu/Ytutor_Server/node_modules/mongodb-core/lib/topologies/shared.js:18:61) at Module._compile (module.js:449:26) at Object.Module._extensions..js (module.js:467:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Module.require (module.js:362:17) at require (module.js:378:17) at Object.<anonymous> (/home/ubuntu/Ytutor_Server/node_modules/mongodb-core/lib/connection/pool.js:11:12) at Module._compile (module.js:449:26) at Object.Module._extensions..js (module.js:467:10)

的设置器中设置所有相关资源的名称
ResourceDTO