Search code examples
javaserializationwicketwicket-1.5

What is the impact of extending Serializable interface


I have an interface for displayable Enums called IDisplayEnum. I use this for several wicket components where I call display() and get the right representation of the enum. To create a DisplayEnumLabel i have code like this:

public class DisplayEnumLabel extends Label {
    public DisplayEnumLabel(String id, IModel<? extends IDisplayEnum> model) {
        super(id, model);
    }
}

Which I then create using:

add(new DisplayEnumLabel(new PropertyModel(object,"fieldname")));

Now sometimes I want to do Model.of(T object) when PropertyModel is not needed but here T should extend Serializable so my enums "don't fit". I can solve this my extending IDisplayEnum with Serailizable.

Now my question is, what is the impact of this? I have a ~20 enums implementing this interface and it is used a lot. Will this affect performance, security or any of the usual Serializable interface downsides?


Solution

  • I'm not aware of any negative implications of implementing Serializable.

    Everything that is referenced by the Wicket component tree has to be serializable anyway. You can get around this by using IDetachableModels, but Model keeps a direct reference to the wrapped object.