我是lambda的新手,正在学习阶段。 我只想将现有代码的几行转换为lambda函数。
private List < ResourceSpecCharacteristic > getResourceSpecAttributes(ResourceSpecification resource) {
List < ResourceSpecCharacteristic > resourceSpecCharacteristic = new ArrayList < ResourceSpecCharacteristic > ();
Iterator itr = resource.getResourceSpecAttrs().iterator();
while (itr.hasNext()) {
ResourceSpecAttr resourceSpecAttr = (ResourceSpecAttr) itr.next();
ResourceSpecCharacteristic resourceSpec = new ResourceSpecCharacteristic();
resourceSpec.setName(resourceSpecAttr.getName());
resourceSpec.setValueType(resourceSpecAttr.getValueType());
resourceSpec.setMaxCardinality(resourceSpecAttr.getMaxCard());
resourceSpec.setMinCardinality(resourceSpecAttr.getMinCard());
resourceSpecCharacteristic.add(resourceSpec);
}
return resourceSpecCharacteristic;
}
}