Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Builder
- static class Person {
- @NonNull
- private final String name;
- @NonNull
- private final Integer age;
- }
- public static void main(String[] args) {
- Person.builder()
- .name("Fred")
- .build(); // java.lang.NullPointerException: age is marked @NonNull but is null
- }
- @Builder
- static class Person {
- @NonNull
- private final String name;
- @NonNull
- private final Integer age;
- public static PersonBuilder builder(String name, Integer age) {
- return new PersonBuilder().name(name).age(age);
- }
- }
- public static void main(String[] args) {
- Person.builder("Fred", 11)
- .build();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement