This commit is contained in:
@@ -35,6 +35,8 @@ public final class EnMember<W extends Writer, T, F> {
|
|||||||
|
|
||||||
protected int position; //从1开始
|
protected int position; //从1开始
|
||||||
|
|
||||||
|
protected int tag; //主要给protobuf使用
|
||||||
|
|
||||||
public EnMember(Attribute<T, F> attribute, Encodeable<W, F> encoder) {
|
public EnMember(Attribute<T, F> attribute, Encodeable<W, F> encoder) {
|
||||||
this.attribute = attribute;
|
this.attribute = attribute;
|
||||||
this.encoder = encoder;
|
this.encoder = encoder;
|
||||||
@@ -89,6 +91,10 @@ public final class EnMember<W extends Writer, T, F> {
|
|||||||
return this.position;
|
return this.position;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getTag() {
|
||||||
|
return this.tag;
|
||||||
|
}
|
||||||
|
|
||||||
public int compareTo(boolean fieldSort, EnMember<W, T, F> o) {
|
public int compareTo(boolean fieldSort, EnMember<W, T, F> o) {
|
||||||
if (o == null) return -1;
|
if (o == null) return -1;
|
||||||
if (this.position != o.position) return (this.position == 0 ? Integer.MAX_VALUE : this.position) - (o.position == 0 ? Integer.MAX_VALUE : o.position);
|
if (this.position != o.position) return (this.position == 0 ? Integer.MAX_VALUE : this.position) - (o.position == 0 ? Integer.MAX_VALUE : o.position);
|
||||||
|
|||||||
@@ -130,6 +130,7 @@ public class ObjectEncoder<W extends Writer, T> implements Encodeable<W, T> {
|
|||||||
while (pos.contains(++pidx));
|
while (pos.contains(++pidx));
|
||||||
member.position = pidx;
|
member.position = pidx;
|
||||||
}
|
}
|
||||||
|
initForEachEnMember(factory, member);
|
||||||
}
|
}
|
||||||
Arrays.sort(this.members, (a, b) -> a.compareTo(factory.isFieldSort(), b));
|
Arrays.sort(this.members, (a, b) -> a.compareTo(factory.isFieldSort(), b));
|
||||||
|
|
||||||
@@ -144,6 +145,13 @@ public class ObjectEncoder<W extends Writer, T> implements Encodeable<W, T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void initForEachEnMember(ConvertFactory factory, EnMember member) {
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setTag(EnMember member, int tag) {
|
||||||
|
member.tag = tag;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void convertTo(W out, T value) {
|
public void convertTo(W out, T value) {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user