mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-05-30 22:25:37 +00:00
ref[protocol]: modify compatible annotation
This commit is contained in:
@@ -22,6 +22,6 @@ import java.lang.annotation.*;
|
||||
@Target({ElementType.FIELD})
|
||||
public @interface Compatible {
|
||||
|
||||
int order();
|
||||
int value();
|
||||
|
||||
}
|
||||
|
||||
@@ -403,7 +403,7 @@ public class ProtocolAnalysis {
|
||||
var compatibleFieldMap = new HashMap<Integer, Field>();
|
||||
for (var field : fields) {
|
||||
if (field.isAnnotationPresent(Compatible.class)) {
|
||||
var order = field.getAnnotation(Compatible.class).order();
|
||||
var order = field.getAnnotation(Compatible.class).value();
|
||||
var oldField = compatibleFieldMap.put(order, field);
|
||||
if (oldField != null) {
|
||||
throw new RunException("[{}]协议号中的[field:{}]和[field:{}]不能有相同的Compatible顺序[order:{}]", clazz.getCanonicalName(), oldField.getName(), field.getName(), oldField, order);
|
||||
|
||||
@@ -93,9 +93,9 @@ public class ComplexObject {
|
||||
private Set<Map<Integer, String>> sssss;
|
||||
|
||||
@Note("如果要修改协议并且兼容老协议,需要加上Compatible注解,按照增加的顺序添加order")
|
||||
@Compatible(order = 1)
|
||||
@Compatible(1)
|
||||
private int myCompatible;
|
||||
@Compatible(order = 2)
|
||||
@Compatible(2)
|
||||
private ObjectA myObject;
|
||||
|
||||
public byte getA() {
|
||||
|
||||
Reference in New Issue
Block a user