LoginSignup
1
0

More than 5 years have passed since last update.

CheckStyle"インライン条件を使用しない"への対応

Posted at

以下のようなソースがあったときにCheckStyleをすると、
String foo = hoge();
String bar = foo == null ? "" : foo;
「インライン条件を使用しない。」と警告される。

CheckStyleの設定を変更すれば、警告を出さなくできるけど、
警告を出さないソースについて調べてみた。

結論

みんな大好きapache.commonsを使えば良さそう。
String bar = StringUtils.defaultString(foo)

おまけ

String hoge = BooleanUtils.toString(true, "真", "偽");
みたいなのも、インライン警告を消すときに重宝しそう。

1
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
1
0