Skip to content

Commit 57705e9

Browse files
committed
Add FieldMismatchCallback abstract class
1 parent d15c709 commit 57705e9

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package org.apache.fury.serializer;
2+
3+
import java.lang.reflect.Field;
4+
5+
/** Callback interface for handling field mismatch during deserialization. */
6+
public interface FieldMismatchCallback {
7+
8+
/**
9+
* Called when a field mismatch is detected during deserialization.
10+
*
11+
* @param modifiedClass The class that is being deserialized
12+
* @param deserializedTypeName The name of the type that was deserialized
13+
* @param deserializedFieldName The name of the field that was deserialized
14+
* @return A FieldAdjustment that contains the target Field and a method to map the deserialized
15+
* value to the target field.
16+
*/
17+
FieldAdjustment onMismatch(
18+
Class<?> modifiedClass, String deserializedTypeName, String deserializedFieldName);
19+
20+
abstract class FieldAdjustment {
21+
private final Field targetField;
22+
23+
public FieldAdjustment(Field targetField) {
24+
this.targetField = targetField;
25+
}
26+
27+
public Field getTargetField() {
28+
return targetField;
29+
}
30+
31+
public abstract Object adjustValue(Object deserializedValue);
32+
}
33+
}

0 commit comments

Comments
 (0)