yyang-talend / gwt-ent

Automatically exported from code.google.com/p/gwt-ent
0 stars 0 forks source link

classType.getFields() method does not return fields in correct order #38

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
i have a DTO class in client side. if i am getting fields with 
classType.getFields() it returns with incorrect order.

Sample DTO class :

package gov.egmidb.ziyaretci.client.dto;

import java.util.Date;

import java.util.HashSet;

import java.util.Set;

import com.gwtent.reflection.client.Reflectable;

@Reflectable

public class TestDTO extends AbstractDTO {

    private Long id;

    private Date startDate;

    private Date endDate;

    private String description;

    private Set<String> guests = new HashSet<String>();

    public Long getId() {

        return id;

    }

    public void setId(Long id) {

        this.id = id;

    }

    public Date getStartDate() {

        return startDate;

    }

    public void setStartDate(Date startDate) {

        this.startDate = startDate;

    }

    public Date getEndDate() {

        return endDate;

    }

    public void setEndDate(Date endDate) {

        this.endDate = endDate;

    }

    public String getDescription() {

        return description;

    }

    public void setDescription(String description) {

        this.description = description;

    }

    public Set<String> getGuests() {

        return guests;

    }

    public void setGuests(Set<String> guests) {

        this.guests = guests;

    }

}

And getting fields with getField() method:

 ClassType classType= TypeOracle.Instance.getClassType(TestDTO.class);
 Fields[] fields = classType.getFields();
 for(Field field : fields){
   System.out.println(field.getName()+", "+field.getType().getSimpleSourceName());
 }

And the output is:

id, java.lang.Long

startDate, java.util.Date

description, java.lang.String

guests, java.util.Set

endDate, java.util.Date

But i think it should be as the same order with fields of TestDTO class like 
this:

id, java.lang.Long
startDate, java.util.Date
endDate, java.util.Date  
description, java.lang.String
guests, java.util.Set

i am using gwt 2.1 and gwtent 1.0.0RC1 but because of an issue i mannually get 
the r720 of gwtent.jar from svn repo and using it.  

In the class com.gwtent.reflection.client.impl.ClassTypeImpl.java there is a 
field property that is defined as HashMap. May be changing it as LinkedHashMap 
should solve this issue. 

Original issue reported on code.google.com by yavuzt...@gmail.com on 30 Dec 2010 at 10:03

Attachments: