22
33import com .github .houbb .csv .api .IReadConverter ;
44import com .github .houbb .csv .support .context .SingleReadContext ;
5+ import com .github .houbb .csv .support .context .SingleWriteContext ;
56import com .github .houbb .csv .support .convert .read .collection .ArrayReadConverter ;
67import com .github .houbb .csv .support .convert .read .collection .CollectionReadConverter ;
78import com .github .houbb .csv .support .convert .read .collection .MapReadConverter ;
9+ import com .github .houbb .csv .support .convert .read .entry .EntryReadConverter ;
810import com .github .houbb .csv .support .convert .read .type .ITypeConverter ;
911import com .github .houbb .csv .support .convert .read .type .impl .*;
12+ import com .github .houbb .csv .support .convert .write .entry .EntryWriteConverter ;
13+ import com .github .houbb .csv .util .CsvFieldUtil ;
14+ import com .github .houbb .csv .util .CsvInnerUtil ;
1015import com .github .houbb .heaven .annotation .ThreadSafe ;
1116import com .github .houbb .heaven .support .instance .impl .InstanceFactory ;
1217import com .github .houbb .heaven .support .instance .impl .Instances ;
18+ import com .github .houbb .heaven .support .sort .ISort ;
1319import com .github .houbb .heaven .util .lang .ObjectUtil ;
1420import com .github .houbb .heaven .util .lang .StringUtil ;
1521import com .github .houbb .heaven .util .lang .reflect .ClassTypeUtil ;
@@ -48,6 +54,8 @@ public class CommonReadConverter implements IReadConverter<Object> {
4854 public Object convert (final SingleReadContext context ) {
4955 final String value = context .value ();
5056 final Field field = context .field ();
57+ final String split = context .split ();
58+ final ISort sort = context .sort ();
5159
5260 //1. 为空判断
5361 if (StringUtil .isEmpty (value )) {
@@ -70,6 +78,19 @@ public Object convert(final SingleReadContext context) {
7078 if (ClassTypeUtil .isCollection (refType )) {
7179 return Instances .singletion (CollectionReadConverter .class ).convert (context );
7280 }
81+ // 2.4 对象
82+ // 当前字段指定为 @CsvEntry 且为对象
83+ if (CsvFieldUtil .isEntryAble (field )) {
84+ final String nextSplit = CsvInnerUtil .getNextSplit (split );
85+ SingleReadContext singleReadContext = new SingleReadContext ();
86+ singleReadContext .sort (sort )
87+ .value (value )
88+ .split (nextSplit )
89+ .classType (refType )
90+ .field (field )
91+ ;
92+ return Instances .singletion (EntryReadConverter .class ).convert (singleReadContext );
93+ }
7394
7495 // 3. 基本类型
7596 return this .convert (value , refType );
0 commit comments