XStream

allow transient fields to be optionally deserialized

Details

  • Type: New Feature New Feature
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: 1.3
  • Component/s: Converters
  • Labels:
    None

Description

It would be nice to be able to optionally allow transient fields to be deserialized. We'd like to use this as part of a deprecation/data migrations strategy.

If AbstractReflectionConverter had a method like:

protected boolean shouldDeserializeTransientField(){
return false
};

Then those of us who want this can trivially over-ride that in a customer ReflectionConverter

There are 2 places in AbstractReflectionConverter where the following code appears :

if (Modifier.isTransient(field.getModifiers()) {
reader.moveUp();
continue;
}

It could be easily modified to be

if (Modifier.isTransient(field.getModifiers() && !shouldDeserializeTransientField) {
reader.moveUp();
continue;
}

In this way, people could access this functionality with a trivial subclass of ReflectionConverter without any impact on current users or functionality.

Probably the "correct" way to do it is to put the query method in to the Mapper interface, but this would have more change/impact

Activity

Hide
Joerg Schaible added a comment -

Implemented as proposed. See head revision.

Show
Joerg Schaible added a comment - Implemented as proposed. See head revision.
Hide
Joerg Schaible added a comment -

Closing issues before next release.

Show
Joerg Schaible added a comment - Closing issues before next release.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: