I think what you are looking for is something like Apache BeanUtils or Springs implementation. Just make sure the properties are named the same between the 2 objects you want to copy the data between. So taking your code:
void mapFooBar(List<Foo> fooList, List<Bar> barList) {
for (Bar bar : barList) {
for (Foo foo : fooList) {
if (bar.fooId.equals(foo.id)) {
BeanUtils.copyProperties(foo, bar);
}
}
}
}
Now that the copy is done lets look at your loop. Your best bet would be to keep the Objects in Maps using fooId as the key (assuming no objects duplicated).
void mapFooBar(Map<Integer, Foo> fooMap, Map<Integer, Bar> barMap) {
for (Integer key : fooMap.keySet()) {
if (barMap.containsKey(key) {
Bar bar = barMap.get(key);
Foo foo = fooMap.get(key);
BeanUtils.copyProperties(foo, bar);
}
}
}