restygwt/src/main/java/org/fusesource/restygwt/rebind/JsonEncoderDecoderClassCreator.java
private List<JField> getFields(JClassType type) {
        List<JField> allFields = getFields(new ArrayList<JField>(), type);
        Map<String, JMethod> getters = new HashMap<String, JMethod>();
        Map<String, JMethod> setters = new HashMap<String, JMethod>();

        JType booleanType = null;
        try {
            booleanType = find(Boolean.class, getLogger(), context);
        } catch (UnableToCompleteException e) {
            // do nothing
        }
        for (JMethod m : type.getInheritableMethods()) {
            if (m.getName().startsWith("set") && m.getParameterTypes().length == 1 &&
                m.getReturnType() == JPrimitiveType.VOID && !isIgnored(m)) {
                setters.put(m.getName().substring("set".length()), m);
            } else if (m.getName().startsWith("get") && m.getParameterTypes().length == 0 &&
                m.getReturnType() != JPrimitiveType.VOID && !isIgnored(m)) {
                getters.put(m.getName().substring("get".length()), m);
            } else if (m.getName().startsWith("is") && m.getParameterTypes().length == 0 &&
                (m.getReturnType() == JPrimitiveType.BOOLEAN || m.getReturnType().equals(booleanType)) &&
                !isIgnored(m)) {
                getters.put(m.getName().substring("is".length()), m);
            } else if (m.getName().startsWith("has") && m.getParameterTypes().length == 0 &&
                (m.getReturnType() == JPrimitiveType.BOOLEAN || m.getReturnType().equals(booleanType)) &&
                !isIgnored(m)) {
                getters.put(m.getName().substring("has".length()), m);
            }
        }
        for (Map.Entry<String, JMethod> entry : getters.entrySet()) {
            JMethod getter = entry.getValue();
            JMethod setter = setters.get(entry.getKey());

            if (null != setter && setter.getParameterTypes()[0].equals(getter.getReturnType())) {
                String name = entry.getKey().substring(0, 1).toLowerCase() + entry.getKey().substring(1);
                JField f = null;
                for (JField field : allFields) {
                    if (field.getName().equals(name)) {
                        f = field;
                        break;
                    }
                }

                if (f != null && isJsonIgnored(f)) {
                    continue;
                }

                JsonProperty propName = getJsonPropertyFromGetterSetter(getter, setter);

                // if have a field and an annotation from the getter/setter then use that annotation
                if (f != null) {
                    if (propName != null && !f.getName().equals(propName.value())) {
                        allFields.remove(f);
                        DummyJField dummy = new DummyJField(name, getter.getReturnType(), getter);
                        dummy.setAnnotation(propName);
                        allFields.add(dummy);
                    }
                } else {
                    DummyJField dummy = new DummyJField(name, getter.getReturnType(), getter);
                    if (getter.isAnnotationPresent(JsonProperty.class)) {
                        dummy.setAnnotation(getAnnotation(getter, JsonProperty.class));
                    }
                    allFields.add(dummy);
                }
            }
        }

        // remove fields annotated with JsonIgnore
        for (Iterator<JField> iter = allFields.iterator(); iter.hasNext(); ) {
            JField field = iter.next();
            if (isJsonIgnored(field)) {
                iter.remove();
            }
        }

        return allFields;
    }
private List<JField> getFields(JClassType type) {
        List<JField> allFields = getFields(new ArrayList<JField>(), type);
        Map<String, JMethod> getters = new HashMap<String, JMethod>();
        Map<String, JMethod> setters = new HashMap<String, JMethod>();

        JType booleanType = null;
        try {
            booleanType = find(Boolean.class, getLogger(), context);
        } catch (UnableToCompleteException e) {
            // do nothing
        }
        for (JMethod m : type.getInheritableMethods()) {
            if (m.getName().startsWith("set") && m.getParameterTypes().length == 1 &&
                m.getReturnType() == JPrimitiveType.VOID && !isIgnored(m)) {
                setters.put(m.getName().substring("set".length()), m);
            } else if (m.getName().startsWith("get") && m.getParameterTypes().length == 0 &&
                m.getReturnType() != JPrimitiveType.VOID && !isIgnored(m)) {
                getters.put(m.getName().substring("get".length()), m);
            } else if (m.getName().startsWith("is") && m.getParameterTypes().length == 0 &&
                (m.getReturnType() == JPrimitiveType.BOOLEAN || m.getReturnType().equals(booleanType)) &&
                !isIgnored(m)) {
                getters.put(m.getName().substring("is".length()), m);
            } else if (m.getName().startsWith("has") && m.getParameterTypes().length == 0 &&
                (m.getReturnType() == JPrimitiveType.BOOLEAN || m.getReturnType().equals(booleanType)) &&
                !isIgnored(m)) {
                getters.put(m.getName().substring("has".length()), m);
            }
        }
        for (Map.Entry<String, JMethod> entry : getters.entrySet()) {
            JMethod getter = entry.getValue();
            JMethod setter = setters.get(entry.getKey());

            if (null != setter && setter.getParameterTypes()[0].equals(getter.getReturnType())) {
                String name = entry.getKey().substring(0, 1).toLowerCase() + entry.getKey().substring(1);
                JField f = null;
                for (JField field : allFields) {
                    if (field.getName().equals(name)) {
                        f = field;
                        break;
                    }
                }

                if (f != null && isJsonIgnored(f)) {
                    continue;
                }

                JsonProperty propName = getJsonPropertyFromGetterSetter(getter, setter);

                // if have a field and an annotation from the getter/setter then use that annotation
                if (f != null) {
                    if (propName != null && !f.getName().equals(propName.value())) {
                        allFields.remove(f);
                        DummyJField dummy = new DummyJField(name, getter.getReturnType(), getter);
                        dummy.setAnnotation(propName);
                        allFields.add(dummy);
                    }
                } else {
                    DummyJField dummy = new DummyJField(name, getter.getReturnType(), getter);
                    if (getter.isAnnotationPresent(JsonProperty.class)) {
                        dummy.setAnnotation(getAnnotation(getter, JsonProperty.class));
                    }
                    allFields.add(dummy);
                }
            }
        }

        // remove fields annotated with JsonIgnore
        for (Iterator<JField> iter = allFields.iterator(); iter.hasNext(); ) {
            JField field = iter.next();
            if (isJsonIgnored(field)) {
                iter.remove();
            }
        }

        return allFields;
    }
private List < JField > getFields ( JClassType type ) { List < JField > allFields = getFields ( new ArrayList < JField > ( ) , type ) ; Map < String , JMethod > getters = new HashMap < String , JMethod > ( ) ; Map < String , JMethod > setters = new HashMap < String , JMethod > ( ) ; JType booleanType = null ; try { booleanType = find ( Boolean . class , getLogger ( ) , context ) ; } catch ( UnableToCompleteException e ) { // do nothing } for ( JMethod m : type . getInheritableMethods ( ) ) { if ( m . getName ( ) . startsWith ( "set" ) && m . getParameterTypes ( ) . length == 1 && m . getReturnType ( ) == JPrimitiveType . VOID && ! isIgnored ( m ) ) { setters . put ( m . getName ( ) . substring ( "set" . length ( ) ) , m ) ; } else if ( m . getName ( ) . startsWith ( "get" ) && m . getParameterTypes ( ) . length == 0 && m . getReturnType ( ) != JPrimitiveType . VOID && ! isIgnored ( m ) ) { getters . put ( m . getName ( ) . substring ( "get" . length ( ) ) , m ) ; } else if ( m . getName ( ) . startsWith ( "is" ) && m . getParameterTypes ( ) . length == 0 && ( m . getReturnType ( ) == JPrimitiveType . BOOLEAN || m . getReturnType ( ) . equals ( booleanType ) ) && ! isIgnored ( m ) ) { getters . put ( m . getName ( ) . substring ( "is" . length ( ) ) , m ) ; } else if ( m . getName ( ) . startsWith ( "has" ) && m . getParameterTypes ( ) . length == 0 && ( m . getReturnType ( ) == JPrimitiveType . BOOLEAN || m . getReturnType ( ) . equals ( booleanType ) ) && ! isIgnored ( m ) ) { getters . put ( m . getName ( ) . substring ( "has" . length ( ) ) , m ) ; } } for ( Map . Entry < String , JMethod > entry : getters . entrySet ( ) ) { JMethod getter = entry . getValue ( ) ; JMethod setter = setters . get ( entry . getKey ( ) ) ; if ( null != setter && setter . getParameterTypes ( ) [ 0 ] . equals ( getter . getReturnType ( ) ) ) { String name = entry . getKey ( ) . substring ( 0 , 1 ) . toLowerCase ( ) + entry . getKey ( ) . substring ( 1 ) ; JField f = null ; for ( JField field : allFields ) { if ( field . getName ( ) . equals ( name ) ) { f = field ; break ; } } if ( f != null && isJsonIgnored ( f ) ) { continue ; } JsonProperty propName = getJsonPropertyFromGetterSetter ( getter , setter ) ; // if have a field and an annotation from the getter/setter then use that annotation if ( f != null ) { if ( propName != null && ! f . getName ( ) . equals ( propName . value ( ) ) ) { allFields . remove ( f ) ; DummyJField dummy = new DummyJField ( name , getter . getReturnType ( ) , getter ) ; dummy . setAnnotation ( propName ) ; allFields . add ( dummy ) ; } } else { DummyJField dummy = new DummyJField ( name , getter . getReturnType ( ) , getter ) ; if ( getter . isAnnotationPresent ( JsonProperty . class ) ) { dummy . setAnnotation ( getAnnotation ( getter , JsonProperty . class ) ) ; } allFields . add ( dummy ) ; } } } // remove fields annotated with JsonIgnore for ( Iterator < JField > iter = allFields . iterator ( ) ; iter . hasNext ( ) ; ) { JField field = iter . next ( ) ; if ( isJsonIgnored ( field ) ) { iter . remove ( ) ; } } return allFields ; }
Inspects the supplied type and all super classes up to but excluding
Object and returns a list of all fields found in these classes.

@param type
@return
Inspects the supplied type and all super classes up to but excluding Object and returns a list of all fields found in these classes .