feat: ResultCallback supports more types

This commit is contained in:
CaiHQ 2021-11-01 16:45:30 +08:00
parent 10431499f5
commit 57771dc26e
2 changed files with 18 additions and 0 deletions

View File

@ -1,7 +1,11 @@
package org.bdware.sc.conn;
import com.google.gson.JsonObject;
import io.netty.channel.Channel;
import io.netty.util.Timeout;
import org.bdware.sc.util.JsonUtil;
import java.util.Map;
public abstract class ResultCallback {
// private static final Logger LOGGER = LogManager.getLogger(ResultCallback.class);
@ -18,6 +22,12 @@ public abstract class ResultCallback {
public Channel getChannel() {
return channel;
}
public void onResult(Map<?,?> object){
onResult(JsonUtil.toJson(object));
}
public void onResult(JsonObject jo) {
onResult(jo.toString());
}
public abstract void onResult(String str);

View File

@ -1,8 +1,10 @@
package org.bdware.sc.util;
import com.google.gson.JsonObject;
import org.junit.Assert;
import org.junit.Test;
public class UtilTest {
@Test
public void testGetDir() {
@ -10,4 +12,10 @@ public class UtilTest {
String dirPath = FileUtil.getDir(fullPath);
Assert.assertEquals("123/", dirPath);
}
@Test
public void testJson(){
JsonObject jo = new JsonObject();
jo.addProperty("dafa","123");
System.out.println(jo.toString());
}
}