1 ポイント 投稿者 k42kr 2 시간 전 | まだコメントはありません。 | 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% + PIT ミューテーションスコア 95%
  • 正直なところ: 1人プロジェクト、JMH ベンチマークなし、Jackson/@Valid ブリッジなし

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

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

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