Closed GoogleCodeExporter closed 9 years ago
I forgot to mention stateInvalid would always throw an exception... the return
type is analogous to Throwables.propagate().
Original comment by adam.g...@evocatus.com
on 11 Oct 2012 at 8:02
How is this different from
throw new IllegalStateException(String.format(message, errorMessageArgs))
?
Original comment by lowas...@google.com
on 11 Oct 2012 at 8:38
Consistency and less typing.
The formatter in Preconditions.checkState is not the same as String.format. I'm
assuming the one in Guava is perhaps faster?
Of course one could make the argument for any of the Preconditions.check* "of
how is it any different then this inline Java" ?
Original comment by adam.g...@evocatus.com
on 11 Oct 2012 at 8:47
The Precondition methods are handy one-line versions of things that would
otherwise be more cluttered with plain Java, but the "throw new
IllegalStateException" approach is still one line -- it's just a few more
characters.
The formatter in Preconditions.checkState isn't necessarily faster, and doesn't
necessarily have to be -- we're not particularly concerned about the speed of
throwing exceptions. Preconditions.checkState uses a "subformat" of the format
used by String.format -- only accepting %s patterns -- so as to be emulatable
in GWT without too much code bloat. That's all.
Original comment by lowas...@google.com
on 11 Oct 2012 at 9:39
Merging this into 1382, rather than the other way around, because the
discussion seems more involved there.
Original comment by lowas...@google.com
on 3 May 2013 at 9:21
This issue has been migrated to GitHub.
It can be found at https://github.com/google/guava/issues/<id>
Original comment by cgdecker@google.com
on 1 Nov 2014 at 4:13
Original comment by cgdecker@google.com
on 3 Nov 2014 at 9:08
Original issue reported on code.google.com by
adam.g...@evocatus.com
on 11 Oct 2012 at 7:59