forked from alibaba/fastjson2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improve support custom deserialize & serialize
- Loading branch information
Showing
40 changed files
with
531 additions
and
129 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
core/src/main/java/com/alibaba/fastjson2/function/FieldBiConsumer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.alibaba.fastjson2.function; | ||
|
||
import java.util.function.BiConsumer; | ||
|
||
public final class FieldBiConsumer<T> | ||
implements BiConsumer<T, Object> { | ||
public final int fieldIndex; | ||
public final FieldConsumer<T> consumer; | ||
|
||
public FieldBiConsumer(int fieldIndex, FieldConsumer<T> consumer) { | ||
this.fieldIndex = fieldIndex; | ||
this.consumer = consumer; | ||
} | ||
|
||
@Override | ||
public void accept(T object, Object fieldValue) { | ||
consumer.accept(object, fieldIndex, fieldValue); | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
core/src/main/java/com/alibaba/fastjson2/function/FieldConsumer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.alibaba.fastjson2.function; | ||
|
||
@FunctionalInterface | ||
public interface FieldConsumer<T> { | ||
void accept(T object, int fieldIndex, Object fieldValue); | ||
} |
6 changes: 6 additions & 0 deletions
6
core/src/main/java/com/alibaba/fastjson2/function/FieldSupplier.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.alibaba.fastjson2.function; | ||
|
||
@FunctionalInterface | ||
public interface FieldSupplier<T> { | ||
Object get(T object, int fieldIndex); | ||
} |
19 changes: 19 additions & 0 deletions
19
core/src/main/java/com/alibaba/fastjson2/function/FieldSupplierFunction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.alibaba.fastjson2.function; | ||
|
||
import java.util.function.Function; | ||
|
||
public final class FieldSupplierFunction<T> | ||
implements Function<T, Object> { | ||
public final FieldSupplier<T> supplier; | ||
public final int fieldIndex; | ||
|
||
public FieldSupplierFunction(FieldSupplier<T> supplier, int fieldIndex) { | ||
this.supplier = supplier; | ||
this.fieldIndex = fieldIndex; | ||
} | ||
|
||
@Override | ||
public Object apply(T object) { | ||
return supplier.get(object, fieldIndex); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.