import lombok.AccessLevel; import lombok.NonNull; import lombok.With; public class WithExample { @With private final int age; @With(AccessLevel.PROTECTED) @NonNull private final String name; public WithExample(String name, int age) { if (name == null) throw new NullPointerException(); this.name = name; this.age = age; } }