jaroslav@770
|
1 |
/**
|
jaroslav@770
|
2 |
* Back 2 Browser Bytecode Translator
|
jaroslav@770
|
3 |
* Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
|
jaroslav@770
|
4 |
*
|
jaroslav@770
|
5 |
* This program is free software: you can redistribute it and/or modify
|
jaroslav@770
|
6 |
* it under the terms of the GNU General Public License as published by
|
jaroslav@770
|
7 |
* the Free Software Foundation, version 2 of the License.
|
jaroslav@770
|
8 |
*
|
jaroslav@770
|
9 |
* This program is distributed in the hope that it will be useful,
|
jaroslav@770
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
jaroslav@770
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
jaroslav@770
|
12 |
* GNU General Public License for more details.
|
jaroslav@770
|
13 |
*
|
jaroslav@770
|
14 |
* You should have received a copy of the GNU General Public License
|
jaroslav@770
|
15 |
* along with this program. Look for COPYING file in the top folder.
|
jaroslav@770
|
16 |
* If not, see http://opensource.org/licenses/GPL-2.0.
|
jaroslav@770
|
17 |
*/
|
jaroslav@770
|
18 |
package org.apidesign.bck2brwsr.htmlpage;
|
jaroslav@770
|
19 |
|
jaroslav@770
|
20 |
import org.apidesign.bck2brwsr.htmlpage.api.ComputedProperty;
|
jaroslav@770
|
21 |
import org.apidesign.bck2brwsr.htmlpage.api.Model;
|
jaroslav@914
|
22 |
import org.apidesign.bck2brwsr.htmlpage.api.OnFunction;
|
jaroslav@770
|
23 |
import org.apidesign.bck2brwsr.htmlpage.api.Property;
|
jaroslav@770
|
24 |
|
jaroslav@770
|
25 |
/**
|
jaroslav@770
|
26 |
*
|
jaroslav@770
|
27 |
* @author Jaroslav Tulach <jtulach@netbeans.org>
|
jaroslav@770
|
28 |
*/
|
jaroslav@770
|
29 |
@Model(className = "Person", properties = {
|
jaroslav@770
|
30 |
@Property(name = "firstName", type = String.class),
|
jaroslav@876
|
31 |
@Property(name = "lastName", type = String.class),
|
jaroslav@911
|
32 |
@Property(name = "sex", type = Sex.class)
|
jaroslav@770
|
33 |
})
|
jaroslav@770
|
34 |
final class PersonImpl {
|
jaroslav@770
|
35 |
@ComputedProperty
|
jaroslav@770
|
36 |
public static String fullName(String firstName, String lastName) {
|
jaroslav@770
|
37 |
return firstName + " " + lastName;
|
jaroslav@770
|
38 |
}
|
jaroslav@876
|
39 |
|
jaroslav@876
|
40 |
@ComputedProperty
|
jaroslav@911
|
41 |
public static String sexType(Sex sex) {
|
jaroslav@911
|
42 |
return sex == null ? "unknown" : sex.toString();
|
jaroslav@876
|
43 |
}
|
jaroslav@914
|
44 |
|
jaroslav@914
|
45 |
@OnFunction
|
jaroslav@914
|
46 |
static void changeSex(Person p) {
|
jaroslav@914
|
47 |
if (p.getSex() == Sex.MALE) {
|
jaroslav@914
|
48 |
p.setSex(Sex.FEMALE);
|
jaroslav@914
|
49 |
} else {
|
jaroslav@914
|
50 |
p.setSex(Sex.MALE);
|
jaroslav@914
|
51 |
}
|
jaroslav@914
|
52 |
}
|
jaroslav@925
|
53 |
|
jaroslav@925
|
54 |
@Model(className = "People", properties = {
|
jaroslav@925
|
55 |
@Property(array = true, name = "info", type = PersonImpl.class),
|
jaroslav@925
|
56 |
@Property(array = true, name = "nicknames", type = String.class),
|
jaroslav@925
|
57 |
@Property(array = true, name = "age", type = int.class),})
|
jaroslav@925
|
58 |
public class PeopleImpl {
|
jaroslav@925
|
59 |
}
|
jaroslav@770
|
60 |
}
|