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