Skip to content

Commit

Permalink
Replace deprecated java.util.Locale constructors on factory methods (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Captain1653 committed Feb 14, 2024
1 parent 23c6568 commit 9f65083
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2021 Oracle and/or its affiliates.
* Copyright (c) 2017, 2024 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -34,7 +34,7 @@ public Locale apply(Config config) throws ConfigMappingException, MissingValueEx
String country = config.get("country").asString().orElse("");
String variant = config.get("variant").asString().orElse("");

return new Locale(language, country, variant);
return Locale.of(language, country, variant);
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2021 Oracle and/or its affiliates.
* Copyright (c) 2017, 2024 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -34,7 +34,7 @@ public Locale apply(Config config) throws ConfigMappingException, MissingValueEx
String country = config.get("country").asString().orElse("");
String variant = config.get("variant").asString().orElse("");

return new Locale("m2:" + language, "m2:" + country, "m2:" + variant);
return Locale.of("m2:" + language, "m2:" + country, "m2:" + variant);
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2021 Oracle and/or its affiliates.
* Copyright (c) 2017, 2024 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -45,7 +45,7 @@ public void testLogger() {

@Test
public void testLocale() {
assertThat(getLocale(), is(new Locale("TEST:cs", "TEST:CZ", "TEST:Praha")));
assertThat(getLocale(), is(Locale.of("TEST:cs", "TEST:CZ", "TEST:Praha")));
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2021 Oracle and/or its affiliates.
* Copyright (c) 2017, 2024 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -35,7 +35,7 @@ public void testLogger() {

@Test
public void testLocale() {
assertThat(getLocale(), is(new Locale("cs", "CZ", "Praha")));
assertThat(getLocale(), is(Locale.of("cs", "CZ", "Praha")));
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2021 Oracle and/or its affiliates.
* Copyright (c) 2017, 2024 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -34,7 +34,7 @@ public Locale apply(Config config) throws ConfigMappingException, MissingValueEx
String country = config.get("country").asString().orElse("");
String variant = config.get("variant").asString().orElse("");

return new Locale("TEST:" + language, "TEST:" + country, "TEST:" + variant);
return Locale.of("TEST:" + language, "TEST:" + country, "TEST:" + variant);
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2021 Oracle and/or its affiliates.
* Copyright (c) 2017, 2024 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -42,7 +42,7 @@ public void testLogger() {
*/
@Test
public void testLocale() {
assertThat(getLocale(), is(new Locale("m2:cs", "m2:CZ", "m2:Praha")));
assertThat(getLocale(), is(Locale.of("m2:cs", "m2:CZ", "m2:Praha")));
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2021 Oracle and/or its affiliates.
* Copyright (c) 2017, 2024 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -34,7 +34,7 @@ public Locale apply(Config config) throws ConfigMappingException, MissingValueEx
String country = config.get("country").asString().get();
String variant = config.get("variant").asString().get();

return new Locale("TEST:" + language, "TEST:" + country, "TEST:" + variant);
return Locale.of("TEST:" + language, "TEST:" + country, "TEST:" + variant);
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2022 Oracle and/or its affiliates.
* Copyright (c) 2018, 2024 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -297,7 +297,7 @@ private static Locale toLocale(String locale) {
Matcher matcher = LOCALE_PATTERN.matcher(locale);
Locale result;
if (matcher.matches()) {
result = new Locale(matcher.group(1), matcher.group(2));
result = Locale.of(matcher.group(1), matcher.group(2));
} else {
result = Locale.forLanguageTag(locale);
}
Expand Down

0 comments on commit 9f65083

Please sign in to comment.