Replace to(Upper|Lower)Case with Ascii.to$1Case

The presubmits are warning that toUpperCase() and toLowerCase() are locale-specific, and advise using Ascii.toUpperCase() and Ascii.toLowerCase() as a local-invariant alternative.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=127583677
This commit is contained in:
mountford 2016-07-15 15:10:13 -07:00 committed by Ben McIlwain
parent d9596fa30c
commit e72491e59b
22 changed files with 62 additions and 38 deletions

View file

@ -26,6 +26,7 @@ import static google.registry.tools.CommandUtilities.addHeader;
import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters;
import com.google.common.base.Ascii;
import com.google.common.base.Function;
import com.google.common.base.Joiner;
import com.google.common.base.Splitter;
@ -134,7 +135,7 @@ final class AllocateDomainCommand extends MutatingEppToolCommand {
ImmutableMap.Builder<String, String> contactsMapBuilder = new ImmutableMap.Builder<>();
for (DesignatedContact contact : application.getContacts()) {
contactsMapBuilder.put(
contact.getType().toString().toLowerCase(),
Ascii.toLowerCase(contact.getType().toString()),
contact.getContactRef().get().getForeignKey());
}
LaunchNotice launchNotice = application.getLaunchNotice();

View file

@ -14,6 +14,7 @@
package google.registry.tools;
import com.google.common.base.Ascii;
import com.google.common.base.Strings;
/** Container class for static utility methods. */
@ -25,6 +26,6 @@ class CommandUtilities {
/** Prompts for yes/no input using promptText, defaulting to no. */
static boolean promptForYes(String promptText) {
return System.console().readLine(promptText + " (y/N): ").toUpperCase().startsWith("Y");
return Ascii.toUpperCase(System.console().readLine(promptText + " (y/N): ")).startsWith("Y");
}
}

View file

@ -19,6 +19,7 @@ import static google.registry.util.DomainNameUtils.canonicalizeDomainName;
import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters;
import com.google.common.base.Ascii;
import google.registry.tools.Command.GtechCommand;
import google.registry.util.Idn;
import java.io.IOException;
@ -37,7 +38,7 @@ final class ConvertIdnCommand implements Command, GtechCommand {
public void run() throws IOException {
for (String label : mainParameters) {
if (label.startsWith(ACE_PREFIX)) {
System.out.println(Idn.toUnicode(label.toLowerCase()));
System.out.println(Idn.toUnicode(Ascii.toLowerCase(label)));
} else {
System.out.println(canonicalizeDomainName(label));
}

View file

@ -18,6 +18,7 @@ import static google.registry.util.PreconditionsUtils.checkArgumentNotNull;
import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters;
import com.google.common.base.Ascii;
import com.google.template.soy.data.SoyMapData;
import google.registry.model.domain.launch.LaunchPhase;
import google.registry.tools.Command.GtechCommand;
@ -53,8 +54,8 @@ final class DomainApplicationInfoCommand extends EppToolCommand implements Gtech
@Override
void initEppToolCommand() {
LaunchPhase launchPhase =
checkArgumentNotNull(LaunchPhase.fromValue(phase.toLowerCase()), "Illegal launch phase.");
LaunchPhase launchPhase = checkArgumentNotNull(
LaunchPhase.fromValue(Ascii.toLowerCase(phase)), "Illegal launch phase.");
setSoyTemplate(
DomainApplicationInfoSoyInfo.getInstance(),

View file

@ -17,6 +17,7 @@ package google.registry.tools;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkState;
import com.google.common.base.Ascii;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import google.registry.config.RegistryEnvironment;
@ -61,7 +62,7 @@ enum RegistryToolEnvironment {
* @see #get()
*/
static RegistryToolEnvironment parseFromArgs(String[] args) {
return valueOf(getFlagValue(args, FLAGS).toUpperCase());
return valueOf(Ascii.toUpperCase(getFlagValue(args, FLAGS)));
}
/**

View file

@ -23,6 +23,7 @@ import static google.registry.util.CollectionUtils.isNullOrEmpty;
import static google.registry.util.DomainNameUtils.ACE_PREFIX;
import static java.util.Arrays.asList;
import com.google.common.base.Ascii;
import com.google.common.base.Function;
import com.google.common.base.Joiner;
import com.google.common.base.Predicate;
@ -250,7 +251,7 @@ public class VerifyOteAction implements Runnable, JsonAction {
/** Returns a more human-readable translation of the enum constant. */
String description() {
return this.name().replace('_', ' ').toLowerCase();
return Ascii.toLowerCase(this.name().replace('_', ' '));
}
/** An {@link EppInput} might match multiple actions, so check if this action matches. */