// Collection of code snippets by Arne Vajhøj 
// (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) 
package server;

import java.util.ArrayList;
import java.util.List;

import com.github.arteam.simplejsonrpc.core.annotation.JsonRpcMethod;
import com.github.arteam.simplejsonrpc.core.annotation.JsonRpcParam;
import com.github.arteam.simplejsonrpc.core.annotation.JsonRpcService;

import common.Data;

@JsonRpcService
public class Test {
	@JsonRpcMethod
    public int getInt() {
        return 123;
    }
	@JsonRpcMethod
    public String getString() {
        return "ABC";
    }
	@JsonRpcMethod
    public Data getData() {
        return new Data(123, "ABC");
    }
	@JsonRpcMethod
    public List<Integer> getListOfInts() {
        ArrayList<Integer> res = new ArrayList<Integer>();
        res.add(123);
        res.add(456);
        return res;
    }
	@JsonRpcMethod
    public List<String> getListOfStrings() {
        ArrayList<String> res = new ArrayList<String>();
        res.add("ABC");
        res.add("DEF");
        return res;
    }
	@JsonRpcMethod
    public List<Data> getListOfData() {
        ArrayList<Data> res = new ArrayList<Data>();
        res.add(new Data(123, "ABC"));
        res.add(new Data(456, "DEF"));
        return res;
    }
	@JsonRpcMethod
    public int add(@JsonRpcParam("a")int a, @JsonRpcParam("b")int b) {
        return a + b;
    }
	@JsonRpcMethod
    public String concat(@JsonRpcParam("s1")String a, @JsonRpcParam("s2")String b) {
        return a + b;
    }
	@JsonRpcMethod
    public Data modify(@JsonRpcParam("o")Data o) {
        Data o2 = new Data(o.getIval() + 1, o.getSval() + "X");
        return o2;
    }
}
