1 ポイント 投稿者 k42kr 2026-05-19 | まだコメントはありません。 | WhatsAppで共有

Java Refinedは、Stringint の代わりに NonBlankStringPositiveInt のような事前定義の refined(精製)型を使い、検証をシグネチャへ移すライブラリです。

// Before  
void createUser(String name, int age, List<String> roles) {  
    if (name == null || name.isBlank()) throw new IAE("name");  
    if (age <= 0) throw new IAE("age");  
    if (roles == null || roles.isEmpty()) throw new IAE("roles");  
}  
  
// After  
void createUser(NonBlankString name, PositiveInt age, NonEmptyList<String> roles) { }  
  • すぐに import して使える 123種類 の事前定義型(VAVR/Arrow はパターンのみ提供)
  • NonEmptyList<T>List<T>直接実装 — アンラップ不要
  • ランタイム依存ゼロ · Java 8+ · MIT · Maven Central · Kotlin 拡張モジュールは別途提供
  • 100% の行カバレッジ + 95% の PIT ミューテーションスコア
  • 正直なところ: 1人プロジェクト、JMH ベンチマークなし、Jackson/@Valid ブリッジなし

GitHub: https://github.com/JunggiKim/java-refined

まだコメントはありません。

まだコメントはありません。