Sometimes, when deserializing an Java object with GSON, you may want GSON to provide some hook for initializing transient fields according to other deserialized fields. By default GSON does not provide an easy way to do that. One possible solution is to use gson-fire but it is probably too overkill for me. Adding a new library is a really serious commitment.

After searching on StackOverflow, The solution to How to invoke default deserialize with gson is closest to what I want. I learned how to solve it with a custom TypeAdapterFactory and getDelegateAdapter. I also added a new PostProcessable interface to make this approach more reusable:

public class PostProcessingEnabler implements TypeAdapterFactory {
    public interface PostProcessable {
        void postProcess();
    }

    public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
        final TypeAdapter<T> delegate = gson.getDelegateAdapter(this, type);

        return new TypeAdapter<T>() {
            public void write(JsonWriter out, T value) throws IOException {
                delegate.write(out, value);
            }

            public T read(JsonReader in) throws IOException {
                T obj = delegate.read(in);
                if (obj instanceof PostProcessable) {
                    ((PostProcessable)obj).postProcess();
                }
                return obj;
            }
        };
    }
}

You need to register this new TypeAdapterFactory for your GSON instance:

Gson gson = new GsonBuilder().registerTypeAdapterFactory(new PostProcessingEnabler()).create();

Implementing PostProcessingEnabler.PostProcessable should be straightforward:

public class Flight implements Serializable, PostProcessingEnabler.PostProcessable {
    @Override
    public void postProcess() {
        // initialize transient fields here...
    }
}