वैलिडेशन को type system में ले जाने वाली Java लाइब्रेरी (123 pre-defined types)
(github.com/JunggiKim)Java Refined एक ऐसी लाइब्रेरी है जो String, int की जगह NonBlankString, PositiveInt जैसे पहले से परिभाषित refinement types का उपयोग करके वैलिडेशन को 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 नहीं
अभी कोई टिप्पणी नहीं है.