Preconditions.checkState may be worth using here as it'll be more concise.