ref[protocol]: modify compatible annotation

This commit is contained in:
sun
2023-09-26 13:42:45 +08:00
parent 62f72a9f5a
commit b2144eb081
3 changed files with 4 additions and 4 deletions
@@ -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() {