mirror of
https://gitee.com/BDWare/common
synced 2025-04-28 15:02:18 +00:00
feat: ResultCallback supports more types
This commit is contained in:
parent
10431499f5
commit
57771dc26e
@ -1,7 +1,11 @@
|
|||||||
package org.bdware.sc.conn;
|
package org.bdware.sc.conn;
|
||||||
|
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
import io.netty.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
import io.netty.util.Timeout;
|
import io.netty.util.Timeout;
|
||||||
|
import org.bdware.sc.util.JsonUtil;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public abstract class ResultCallback {
|
public abstract class ResultCallback {
|
||||||
// private static final Logger LOGGER = LogManager.getLogger(ResultCallback.class);
|
// private static final Logger LOGGER = LogManager.getLogger(ResultCallback.class);
|
||||||
@ -18,6 +22,12 @@ public abstract class ResultCallback {
|
|||||||
public Channel getChannel() {
|
public Channel getChannel() {
|
||||||
return channel;
|
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);
|
public abstract void onResult(String str);
|
||||||
|
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
package org.bdware.sc.util;
|
package org.bdware.sc.util;
|
||||||
|
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
|
||||||
public class UtilTest {
|
public class UtilTest {
|
||||||
@Test
|
@Test
|
||||||
public void testGetDir() {
|
public void testGetDir() {
|
||||||
@ -10,4 +12,10 @@ public class UtilTest {
|
|||||||
String dirPath = FileUtil.getDir(fullPath);
|
String dirPath = FileUtil.getDir(fullPath);
|
||||||
Assert.assertEquals("123/", dirPath);
|
Assert.assertEquals("123/", dirPath);
|
||||||
}
|
}
|
||||||
|
@Test
|
||||||
|
public void testJson(){
|
||||||
|
JsonObject jo = new JsonObject();
|
||||||
|
jo.addProperty("dafa","123");
|
||||||
|
System.out.println(jo.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user