added
class for name list<model>
This commit is contained in:
parent
fbf2bdc93e
commit
8fe158238d
|
@ -5,12 +5,17 @@ import com.loafle.overflow.db.api.DBGrpc;
|
||||||
import com.loafle.overflow.db.api.DBInput;
|
import com.loafle.overflow.db.api.DBInput;
|
||||||
import com.loafle.overflow.db.api.DBOutput;
|
import com.loafle.overflow.db.api.DBOutput;
|
||||||
import com.loafle.overflow.member.model.Member;
|
import com.loafle.overflow.member.model.Member;
|
||||||
|
import com.loafle.overflow.target.model.Target;
|
||||||
import io.grpc.ManagedChannel;
|
import io.grpc.ManagedChannel;
|
||||||
import io.grpc.ManagedChannelBuilder;
|
import io.grpc.ManagedChannelBuilder;
|
||||||
import io.grpc.StatusRuntimeException;
|
import io.grpc.StatusRuntimeException;
|
||||||
import org.codehaus.jackson.map.ObjectMapper;
|
import org.codehaus.jackson.map.ObjectMapper;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
@ -81,4 +86,33 @@ public class TestClient {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testClassName() throws ClassNotFoundException, IOException {
|
||||||
|
|
||||||
|
String testRes = "[{\"ip\":3232235882,\"port\":5432,\"targetType\":\"DATABASE\",\"vendorName\":\"PostgreSQL 9.5.0\",\"kinds\":\"PostgreSQL2222\",\"version\":\"9.5.0\",\"createDate\":-62135596800000,\"portType\":\"TCP\",\"member\":{\"id\":1,\"email\":\"\",\"pwSalt\":\"\",\"digest\":\"\",\"name\":\"\",\"company\":\"\",\"phone\":\"\",\"authorizedDate\":0}},{\"ip\":3232235882,\"port\":5432,\"targetType\":\"DATABASE\",\"vendorName\":\"PostgreSQL 9.5.0\",\"kinds\":\"PostgreSQL3333\",\"version\":\"9.5.0\",\"createDate\":-62135596800000,\"portType\":\"TCP\",\"member\":{\"id\":1,\"email\":\"\",\"pwSalt\":\"\",\"digest\":\"\",\"name\":\"\",\"company\":\"\",\"phone\":\"\",\"authorizedDate\":0}},{\"ip\":3232235882,\"port\":5432,\"targetType\":\"DATABASE\",\"vendorName\":\"PostgreSQL 9.5.0\",\"kinds\":\"PostgreSQL4444\",\"version\":\"9.5.0\",\"createDate\":-62135596800000,\"portType\":\"TCP\",\"member\":{\"id\":1,\"email\":\"\",\"pwSalt\":\"\",\"digest\":\"\",\"name\":\"\",\"company\":\"\",\"phone\":\"\",\"authorizedDate\":0}},{\"ip\":3232235882,\"port\":5432,\"targetType\":\"DATABASE\",\"vendorName\":\"PostgreSQL 9.5.0\",\"kinds\":\"PostgreSQL5555\",\"version\":\"9.5.0\",\"createDate\":-62135596800000,\"portType\":\"TCP\",\"member\":{\"id\":1,\"email\":\"\",\"pwSalt\":\"\",\"digest\":\"\",\"name\":\"\",\"company\":\"\",\"phone\":\"\",\"authorizedDate\":0}},{\"ip\":3232235882,\"port\":5432,\"targetType\":\"DATABASE\",\"vendorName\":\"PostgreSQL 9.5.0\",\"kinds\":\"PostgreSQL6666\",\"version\":\"9.5.0\",\"createDate\":-62135596800000,\"portType\":\"TCP\",\"member\":{\"id\":1,\"email\":\"\",\"pwSalt\":\"\",\"digest\":\"\",\"name\":\"\",\"company\":\"\",\"phone\":\"\",\"authorizedDate\":0}}]";
|
||||||
|
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
Class<?> cls = Class.forName("[L" + "com.loafle.overflow.target.model.Target" + ";");
|
||||||
|
// Class<?> cls = Class.forName("java.util.List<com.loafle.overflow.target.model.Target>");
|
||||||
|
|
||||||
|
Object obj = mapper.readValue(testRes, cls);
|
||||||
|
|
||||||
|
|
||||||
|
List<Object> aa = Arrays.asList((Object[])obj);
|
||||||
|
|
||||||
|
System.out.println(aa.getClass());
|
||||||
|
// List<Target> tl = (List<Target>)aa;
|
||||||
|
|
||||||
|
|
||||||
|
// List<Target> aaa = (List<Target>)obj.;
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// for( Target t : aaa) {
|
||||||
|
// System.out.println(t);
|
||||||
|
// }
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user