0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Serializable with input check/ writeReplace, readResolve

Last updated at Posted at 2023-02-26

https://qiita.com/Natukasi/items/20f8756e9e956684396c
の改良版。
readObjectはconstructorを通さないために、入力チェックを使用できない
writeReplace/readResolveを使用することで、constructorを通すことができる。
このサンプルには入れていないが、constructor内に入力チェックを仕込んでおく

            return new Value2(this.name,this.price, this.val);
write replace
read resolve
v2-name:v2x v2.price:200v1-name:v1xv1-price:100
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?