Closed GoogleCodeExporter closed 9 years ago
Hey Stefan,
You're best bet is to just inline the checkNotNull with your assignments. In
fact, you'll end up with even fewer lines of code doing this than if we had
checkNotNullForAll(). For example:
public Person (@Nonnull final String name,@Nonnull final String surname, final
Adress adress) {
this.name = Preconditions.checkNotNull(name);
this.surname = Preconditions.checkNotNull(surname);
this.address = Preconditions.checkNotNull(adress);
}
A common approach is to actually static import checkNotNull as well. Then you
end up with just:
public Person (@Nonnull final String name,@Nonnull final String surname, final
Adress adress) {
this.name = checkNotNull(name);
this.surname = checkNotNull(surname);
this.address = checkNotNull(adress);
}
Thanks,
-Kurt
Original comment by kurt.kluever
on 13 Jun 2013 at 3:12
Hey Kurt,
that´s a pretty solution - I missed the return value of
Preconditions.checkNotNull().
Thanks a lot!
Stefan
Original comment by stefan.b...@gmail.com
on 13 Jun 2013 at 3:52
This issue has been migrated to GitHub.
It can be found at https://github.com/google/guava/issues/<issue id>
Original comment by cgdecker@google.com
on 1 Nov 2014 at 4:12
Original comment by cgdecker@google.com
on 3 Nov 2014 at 9:08
Original issue reported on code.google.com by
stefan.b...@gmail.com
on 13 Jun 2013 at 12:23