mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-09-10 06:21:21 +00:00
del[protocol]: deprecate PROTOCOL_ID
This commit is contained in:
@@ -29,8 +29,6 @@ public interface IPacket {
|
||||
/**
|
||||
* 这个类的协议号,重写这个方法,使用多态获取协议号,可以微弱的提高一点性能
|
||||
* <p>
|
||||
* 子类可以不用重写这个方法,也能够通过反射自动获取到PROTOCOL_ID这个协议号,序列化一次对象只会调用一次,性能损失很小
|
||||
*
|
||||
* @return 协议号Id
|
||||
*/
|
||||
default short protocolId() {
|
||||
|
||||
@@ -601,10 +601,10 @@ public class ProtocolAnalysis {
|
||||
// 必须要有一个空的构造器
|
||||
Constructor<?> constructor = ReflectionUtils.publicEmptyConstructor(clazz);
|
||||
|
||||
var protocolClass = clazz.getDeclaredAnnotation(Protocol.class);
|
||||
var protocolAnnotation = clazz.getDeclaredAnnotation(Protocol.class);
|
||||
short protocolId = -1;
|
||||
if (protocolClass != null && protocolClass.id() != 0) {// 注解标注的协议号
|
||||
protocolId = protocolClass.id();
|
||||
if (protocolAnnotation != null) {
|
||||
protocolId = protocolAnnotation.id();
|
||||
AssertionUtils.isTrue(protocolIdField == null && protocolMethod == null, "[class:{}]已经使用了注解标注协议号,不能再使用protocolId()方法和[{}]字段", clazz.getCanonicalName(), PROTOCOL_ID);
|
||||
} else if (protocolIdField != null || protocolMethod != null) { // 字段标注的协议号
|
||||
AssertionUtils.isTrue(protocolIdField != null, "[class:{}]协议序列号[{}]不存在", clazz.getCanonicalName(), PROTOCOL_ID);
|
||||
|
||||
Reference in New Issue
Block a user