From 276cb4da92534f1b6c630c2541cbe472b9b99c38 Mon Sep 17 00:00:00 2001 From: Redkale <22250530@qq.com> Date: Thu, 15 Jun 2017 08:08:38 +0800 Subject: [PATCH] --- src/org/redkale/convert/ConvertColumn.java | 7 ++++++ .../redkale/convert/ConvertColumnEntry.java | 24 +++++++++++++++++-- src/org/redkale/convert/ConvertFactory.java | 6 ++++- src/org/redkale/convert/DeMember.java | 7 ++++++ src/org/redkale/convert/EnMember.java | 7 ++++++ 5 files changed, 48 insertions(+), 3 deletions(-) diff --git a/src/org/redkale/convert/ConvertColumn.java b/src/org/redkale/convert/ConvertColumn.java index 6f6afbd8a..6769e0cf7 100644 --- a/src/org/redkale/convert/ConvertColumn.java +++ b/src/org/redkale/convert/ConvertColumn.java @@ -31,6 +31,13 @@ public @interface ConvertColumn { */ String name() default ""; + /** + * 给字段取个序号ID,值小靠前 + * + * @return 字段排序ID + */ + int index() default 0; + /** * 解析/序列化时是否屏蔽该字段 * diff --git a/src/org/redkale/convert/ConvertColumnEntry.java b/src/org/redkale/convert/ConvertColumnEntry.java index b713c5854..c73a2c17e 100644 --- a/src/org/redkale/convert/ConvertColumnEntry.java +++ b/src/org/redkale/convert/ConvertColumnEntry.java @@ -8,11 +8,15 @@ package org.redkale.convert; /** * ConvertColumn 对应的实体类 * - *
详情见: https://redkale.org + *
+ * 详情见: https://redkale.org
+ *
* @author zhangjx
*/
public final class ConvertColumnEntry {
+ private int index;
+
private String name = "";
private boolean ignore;
@@ -25,6 +29,7 @@ public final class ConvertColumnEntry {
public ConvertColumnEntry(ConvertColumn column) {
if (column == null) return;
this.name = column.name();
+ this.index = column.index();
this.ignore = column.ignore();
this.convertType = column.type();
}
@@ -32,7 +37,7 @@ public final class ConvertColumnEntry {
public ConvertColumnEntry(String name) {
this(name, false);
}
-
+
public ConvertColumnEntry(String name, boolean ignore) {
this.name = name;
this.ignore = ignore;
@@ -45,6 +50,13 @@ public final class ConvertColumnEntry {
this.convertType = convertType;
}
+ public ConvertColumnEntry(String name, int index, boolean ignore, ConvertType convertType) {
+ this.name = name;
+ this.index = index;
+ this.ignore = ignore;
+ this.convertType = convertType;
+ }
+
public String name() {
return name == null ? "" : name;
}
@@ -69,4 +81,12 @@ public final class ConvertColumnEntry {
this.convertType = convertType;
}
+ public int getIndex() {
+ return index;
+ }
+
+ public void setIndex(int index) {
+ this.index = index;
+ }
+
}
diff --git a/src/org/redkale/convert/ConvertFactory.java b/src/org/redkale/convert/ConvertFactory.java
index 3b4e67cc4..1ddfa87af 100644
--- a/src/org/redkale/convert/ConvertFactory.java
+++ b/src/org/redkale/convert/ConvertFactory.java
@@ -129,12 +129,16 @@ public abstract class ConvertFactory