1.1 --- a/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/PageProcessor.java Sun Mar 31 12:26:07 2013 +0200
1.2 +++ b/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/PageProcessor.java Sun Mar 31 13:26:27 2013 +0200
1.3 @@ -535,6 +535,7 @@
1.4 private String typeName(Element where, Property p) {
1.5 String ret;
1.6 boolean isModel = false;
1.7 + boolean isEnum = false;
1.8 try {
1.9 ret = p.type().getName();
1.10 } catch (MirroredTypeException ex) {
1.11 @@ -548,6 +549,9 @@
1.12 } else {
1.13 ret = tm.toString();
1.14 }
1.15 + TypeMirror enm = processingEnv.getElementUtils().getTypeElement("java.lang.Enum").asType();
1.16 + enm = processingEnv.getTypeUtils().erasure(enm);
1.17 + isEnum = processingEnv.getTypeUtils().isSubtype(tm, enm);
1.18 }
1.19 if (p.array()) {
1.20 String bt = findBoxedType(ret);
1.21 @@ -555,7 +559,7 @@
1.22 return bt;
1.23 }
1.24 }
1.25 - if (!isModel && !"java.lang.String".equals(ret)) {
1.26 + if (!isModel && !"java.lang.String".equals(ret) && !isEnum) {
1.27 String bt = findBoxedType(ret);
1.28 if (bt == null) {
1.29 processingEnv.getMessager().printMessage(
2.1 --- a/javaquery/api/src/test/java/org/apidesign/bck2brwsr/htmlpage/PersonImpl.java Sun Mar 31 12:26:07 2013 +0200
2.2 +++ b/javaquery/api/src/test/java/org/apidesign/bck2brwsr/htmlpage/PersonImpl.java Sun Mar 31 13:26:27 2013 +0200
2.3 @@ -28,7 +28,7 @@
2.4 @Model(className = "Person", properties = {
2.5 @Property(name = "firstName", type = String.class),
2.6 @Property(name = "lastName", type = String.class),
2.7 - @Property(name = "male", type = boolean.class)
2.8 + @Property(name = "sex", type = Sex.class)
2.9 })
2.10 final class PersonImpl {
2.11 @ComputedProperty
2.12 @@ -37,7 +37,7 @@
2.13 }
2.14
2.15 @ComputedProperty
2.16 - public static String sex(boolean male) {
2.17 - return male ? "Male" : "Female";
2.18 + public static String sexType(Sex sex) {
2.19 + return sex == null ? "unknown" : sex.toString();
2.20 }
2.21 }
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/javaquery/api/src/test/java/org/apidesign/bck2brwsr/htmlpage/Sex.java Sun Mar 31 13:26:27 2013 +0200
3.3 @@ -0,0 +1,26 @@
3.4 +/**
3.5 + * Back 2 Browser Bytecode Translator
3.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
3.7 + *
3.8 + * This program is free software: you can redistribute it and/or modify
3.9 + * it under the terms of the GNU General Public License as published by
3.10 + * the Free Software Foundation, version 2 of the License.
3.11 + *
3.12 + * This program is distributed in the hope that it will be useful,
3.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
3.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3.15 + * GNU General Public License for more details.
3.16 + *
3.17 + * You should have received a copy of the GNU General Public License
3.18 + * along with this program. Look for COPYING file in the top folder.
3.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
3.20 + */
3.21 +package org.apidesign.bck2brwsr.htmlpage;
3.22 +
3.23 +/**
3.24 + *
3.25 + * @author Jaroslav Tulach <jtulach@netbeans.org>
3.26 + */
3.27 +public enum Sex {
3.28 + MALE, FEMALE;
3.29 +}