anirudha-wegilant / lambdaj

Automatically exported from code.google.com/p/lambdaj
Apache License 2.0
0 stars 0 forks source link

project() conversion using on() statements has erroneous result when using Joda Date #117

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. I have a Class with some fields incl Joda.time.LocalDates 

package nl.mark.test;
import org.joda.time.LocalDate;
public class TestClass {
    private long long1;
    private long long2;
    private long long3;
    private String string1;
    private String string2;
    private String string3;
    private LocalDate date1;
    private LocalDate date2;
    private LocalDate date3;
...etc. (constructor, getters/setters)
...

2. and I have a DTO-class which is almost identical with the following 
constructor:

    public TestClassDTO(long long1, long long2, long long3, String string1, String string2, String string3, LocalDate date1, LocalDate date2, LocalDate date3) {
        super();
        this.long1 = long1;
        this.long2 = long2;
        this.long3 = long3;
        this.string1 = string1;
        this.string2 = string2;
        this.string3 = string3;
        this.date1 = date1;
        this.date2 = date2;
        this.date3 = date3;
    }

3. And in a TestApp I use LambdaJ to make conversion between the two:

public static void main(String[] args) {
        //create a test object and add it to a List

        TestClass obj1 = new TestClass(1L, 2L, 3L, "one", "two", "three", new LocalDate(2011, 1, 1), new LocalDate(2012, 2, 2), new LocalDate(2013, 3, 3));

        List<TestClass> testList = new ArrayList<TestClass>();
        testList.add(obj1);

        //use LambdaJ conversion to create List of dto's
        List<TestClassDTO> dtoList = project(testList, TestClassDTO.class, on(TestClass.class).getLong1(), on(TestClass.class).getLong2(),
                on(TestClass.class).getLong3(), on(TestClass.class).getString1(), on(TestClass.class).getString2(), on(TestClass.class).getString3(),
                on(TestClass.class).getDate1(), on(TestClass.class).getDate2(), on(TestClass.class).getDate3());

        //loop over the List and print the results
        for(TestClassDTO dto : dtoList){
            System.out.println("after LambdaJ conversion: " + dto.getLong1() + ", " + dto.getLong2() + ", " + dto.getLong3() + ", " + dto.getString1() + ", " + 
                                dto.getString2() + ", " + dto.getString3() + ", " + dto.getDate1() + ", " + dto.getDate2() + ", " + dto.getDate3());
        }

    }

What is the expected output? What do you see instead?
I'd expect to see the following in my console:
after LambdaJ conversion: 1, 2, 3, one, two, three, 2011-01-01, 2012-02-02, 
2013-03-03

Instead I see this:
after LambdaJ conversion: 1, 2, 3, one, two, three, 2013-03-03, 2013-03-03, 
2013-03-03

Apparently LambdaJ uses the value of the 3rd Joda LocalDate argument for all 3 
LocalDate arguments when invoking the DTO's constructor

What version of the product are you using? On what operating system?
LambdaJ 2.3.3

Please provide any additional information below.

Attached is a project with the test classes

Original issue reported on code.google.com by Rens...@gmail.com on 28 Jan 2014 at 10:27

Attachments: