jsolve/sweetener — pull request #53 by tkurylek (2014-02-27 13:04:44+00:00)
Title: SW-29 Supported mapping collections of mappable objects

Related issue: #52

AnnotationDrivenMapper can now map collections of mappable objects.

Suppose we have a class `StudentWithListOfGrades` that looks like follows:
``` java
class StudentWithListOfGrades {
List grades;
}
```
and a class `StudentWithListOfGradeSnapshots`:
``` java
class StudentWithListOfGradeSnapshots {
List gradeSnapshots;
}
```
Assuming `Grade` is mappable to `GradeSnapshot`, properly annotated and working with AnnotationDrivenMapper you can map collection of `Grade` to collection of `GradeSnapshot` using annotations:
``` java
@MappableTo(StudentWithListOfGradeSnapshots.class)
class StudentWithListOfGrades {
@Map(to = "gradeSnapshots", elementsAs = GradeSnapshot.class)
List grades;
}
```
and a class `StudentWithListOfGradeSnapshots`:
``` java
@MappableTo(StudentWithListOfGrades.class)
class StudentWithListOfGradeSnapshots {
@Map(to = "grades", elementsAs = Grade.class)
List gradeSnapshots;
}
```
This will also work when mapping array of `Grade` to collection of `GradeSnapshot` and vice versa.