javaquery/demo-calculator-dynamic/src/main/java/org/apidesign/bck2brwsr/demo/calc/HistoryImpl.java
author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Tue, 02 Apr 2013 15:49:42 +0200
branchmodel
changeset 915 b219134a2782
parent 910 52cb50cea1df
permissions -rw-r--r--
Show usage of @OnFunction on @Model class
jaroslav@910
     1
/**
jaroslav@910
     2
 * Back 2 Browser Bytecode Translator
jaroslav@910
     3
 * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
jaroslav@910
     4
 *
jaroslav@910
     5
 * This program is free software: you can redistribute it and/or modify
jaroslav@910
     6
 * it under the terms of the GNU General Public License as published by
jaroslav@910
     7
 * the Free Software Foundation, version 2 of the License.
jaroslav@910
     8
 *
jaroslav@910
     9
 * This program is distributed in the hope that it will be useful,
jaroslav@910
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
jaroslav@910
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
jaroslav@910
    12
 * GNU General Public License for more details.
jaroslav@910
    13
 *
jaroslav@910
    14
 * You should have received a copy of the GNU General Public License
jaroslav@910
    15
 * along with this program. Look for COPYING file in the top folder.
jaroslav@910
    16
 * If not, see http://opensource.org/licenses/GPL-2.0.
jaroslav@910
    17
 */
jaroslav@910
    18
package org.apidesign.bck2brwsr.demo.calc;
jaroslav@910
    19
jaroslav@910
    20
import org.apidesign.bck2brwsr.htmlpage.api.ComputedProperty;
jaroslav@910
    21
import org.apidesign.bck2brwsr.htmlpage.api.Model;
jaroslav@915
    22
import org.apidesign.bck2brwsr.htmlpage.api.OnFunction;
jaroslav@910
    23
import org.apidesign.bck2brwsr.htmlpage.api.Property;
jaroslav@910
    24
jaroslav@910
    25
/**
jaroslav@910
    26
 *
jaroslav@910
    27
 * @author Jaroslav Tulach <jtulach@netbeans.org>
jaroslav@910
    28
 */
jaroslav@910
    29
@Model(className = "History", properties = {
jaroslav@910
    30
    @Property(name = "value", type = double.class),
jaroslav@910
    31
    @Property(name = "operation", type = String.class)
jaroslav@910
    32
})
jaroslav@910
    33
public class HistoryImpl {
jaroslav@910
    34
    @ComputedProperty
jaroslav@910
    35
    static String resultOf(String operation) {
jaroslav@910
    36
        return "result of " + operation;
jaroslav@910
    37
    }
jaroslav@915
    38
    
jaroslav@915
    39
    @OnFunction
jaroslav@915
    40
    static void twice(History data) {
jaroslav@915
    41
        data.setValue(2.0 * data.getValue());
jaroslav@915
    42
    }
jaroslav@910
    43
}