This commit is contained in:
@@ -31,6 +31,13 @@ public @interface ConvertColumn {
|
|||||||
*/
|
*/
|
||||||
String name() default "";
|
String name() default "";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 给字段取个序号ID,值小靠前
|
||||||
|
*
|
||||||
|
* @return 字段排序ID
|
||||||
|
*/
|
||||||
|
int index() default 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 解析/序列化时是否屏蔽该字段
|
* 解析/序列化时是否屏蔽该字段
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -8,11 +8,15 @@ package org.redkale.convert;
|
|||||||
/**
|
/**
|
||||||
* ConvertColumn 对应的实体类
|
* ConvertColumn 对应的实体类
|
||||||
*
|
*
|
||||||
* <p> 详情见: https://redkale.org
|
* <p>
|
||||||
|
* 详情见: https://redkale.org
|
||||||
|
*
|
||||||
* @author zhangjx
|
* @author zhangjx
|
||||||
*/
|
*/
|
||||||
public final class ConvertColumnEntry {
|
public final class ConvertColumnEntry {
|
||||||
|
|
||||||
|
private int index;
|
||||||
|
|
||||||
private String name = "";
|
private String name = "";
|
||||||
|
|
||||||
private boolean ignore;
|
private boolean ignore;
|
||||||
@@ -25,6 +29,7 @@ public final class ConvertColumnEntry {
|
|||||||
public ConvertColumnEntry(ConvertColumn column) {
|
public ConvertColumnEntry(ConvertColumn column) {
|
||||||
if (column == null) return;
|
if (column == null) return;
|
||||||
this.name = column.name();
|
this.name = column.name();
|
||||||
|
this.index = column.index();
|
||||||
this.ignore = column.ignore();
|
this.ignore = column.ignore();
|
||||||
this.convertType = column.type();
|
this.convertType = column.type();
|
||||||
}
|
}
|
||||||
@@ -45,6 +50,13 @@ public final class ConvertColumnEntry {
|
|||||||
this.convertType = convertType;
|
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() {
|
public String name() {
|
||||||
return name == null ? "" : name;
|
return name == null ? "" : name;
|
||||||
}
|
}
|
||||||
@@ -69,4 +81,12 @@ public final class ConvertColumnEntry {
|
|||||||
this.convertType = convertType;
|
this.convertType = convertType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getIndex() {
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIndex(int index) {
|
||||||
|
this.index = index;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -129,12 +129,16 @@ public abstract class ConvertFactory<R extends Reader, W extends Writer> {
|
|||||||
|
|
||||||
public abstract ConvertType getConvertType();
|
public abstract ConvertType getConvertType();
|
||||||
|
|
||||||
public abstract boolean isReversible();
|
public abstract boolean isReversible(); //是否可逆的
|
||||||
|
|
||||||
public abstract ConvertFactory createChild();
|
public abstract ConvertFactory createChild();
|
||||||
|
|
||||||
public abstract ConvertFactory createChild(boolean tiny);
|
public abstract ConvertFactory createChild(boolean tiny);
|
||||||
|
|
||||||
|
public boolean isIndexSort() { //是否使用@ConvertColumn.index排序
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public Convert getConvert() {
|
public Convert getConvert() {
|
||||||
return convert;
|
return convert;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ import org.redkale.util.Attribute;
|
|||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public final class DeMember<R extends Reader, T, F> implements Comparable<DeMember<R, T, F>> {
|
public final class DeMember<R extends Reader, T, F> implements Comparable<DeMember<R, T, F>> {
|
||||||
|
|
||||||
|
protected int index;
|
||||||
|
|
||||||
protected final Attribute<T, F> attribute;
|
protected final Attribute<T, F> attribute;
|
||||||
|
|
||||||
protected Decodeable<R, F> decoder;
|
protected Decodeable<R, F> decoder;
|
||||||
@@ -68,9 +70,14 @@ public final class DeMember<R extends Reader, T, F> implements Comparable<DeMemb
|
|||||||
return this.attribute;
|
return this.attribute;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getIndex() {
|
||||||
|
return this.index;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final int compareTo(DeMember<R, T, F> o) {
|
public final int compareTo(DeMember<R, T, F> o) {
|
||||||
if (o == null) return 1;
|
if (o == null) return 1;
|
||||||
|
if (this.index != o.index) return this.index - o.index;
|
||||||
return this.attribute.field().compareTo(o.attribute.field());
|
return this.attribute.field().compareTo(o.attribute.field());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,8 @@ public final class EnMember<W extends Writer, T, F> implements Comparable<EnMemb
|
|||||||
//final boolean isnumber;
|
//final boolean isnumber;
|
||||||
final boolean isbool;
|
final boolean isbool;
|
||||||
|
|
||||||
|
protected int index;
|
||||||
|
|
||||||
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;
|
||||||
@@ -61,9 +63,14 @@ public final class EnMember<W extends Writer, T, F> implements Comparable<EnMemb
|
|||||||
return attribute.field().equals(name);
|
return attribute.field().equals(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getIndex() {
|
||||||
|
return this.index;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final int compareTo(EnMember<W, T, F> o) {
|
public final int compareTo(EnMember<W, T, F> o) {
|
||||||
if (o == null) return 1;
|
if (o == null) return 1;
|
||||||
|
if (this.index != o.index) return this.index - o.index;
|
||||||
return this.attribute.field().compareTo(o.attribute.field());
|
return this.attribute.field().compareTo(o.attribute.field());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user