वैलिडेशन को type system में ले जाने वाली Java लाइब्रेरी (123 pre-defined types)
(github.com/JunggiKim)Java Refined एक ऐसी लाइब्रेरी है जो String, int की जगह NonBlankString, PositiveInt जैसे pre-defined refinement types का उपयोग करके validation को signature में ले जाती है।
// 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 तरह के pre-defined types (VAVR/Arrow केवल pattern देते हैं)
NonEmptyList<T>List<T>को सीधे implement करता है — unwrapping की जरूरत नहीं- Zero runtime deps · Java 8+ · MIT · Maven Central · Kotlin extension module अलग से
- 100% line coverage + 95% PIT mutation score
- साफ़ तौर पर: one-person project, JMH benchmark नहीं, Jackson/
@Validbridge नहीं
अभी कोई टिप्पणी नहीं है.