You might want to consider using Preconditions.checkState() here, slightly terser