简体   繁体   English

扩展Serializable接口有什么影响

[英]What is the impact of extending Serializable interface

I have an interface for displayable Enums called IDisplayEnum . 我有一个名为IDisplayEnum可显示枚举的接口。 I use this for several wicket components where I call display() and get the right representation of the enum. 我将其用于几个检票口组件,在其中调用display()并获得枚举的正确表示。 To create a DisplayEnumLabel i have code like this: 创建一个DisplayEnumLabel我有这样的代码:

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". 现在有时我想在不需要Model.of(T object)时执行Model.of(T object) ,但是这里T应该扩展Serializable,因此我的枚举“不适合”。 I can solve this my extending IDisplayEnum with Serailizable . 我可以使用Serailizable解决我扩展的IDisplayEnum

Now my question is, what is the impact of this? 现在我的问题是,这会产生什么影响? I have a ~20 enums implementing this interface and it is used a lot. 我有约20个枚举来实现此接口,并且使用很多。 Will this affect performance, security or any of the usual Serializable interface downsides? 这会影响性能,安全性或任何常见的可序列化接口的缺点吗?

I'm not aware of any negative implications of implementing Serializable. 我不知道实现Serializable会有任何负面影响。

Everything that is referenced by the Wicket component tree has to be serializable anyway. 无论如何,Wicket组件树引用的所有内容都必须可序列化。 You can get around this by using IDetachableModels, but Model keeps a direct reference to the wrapped object. 您可以使用IDetachableModels解决此问题,但是Model保留对包装对象的直接引用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM