[MNG-8150] Remove unused locale argument from FileSizeFormat (#1579)

## Summary

Addressing https://github.com/apache/maven/pull/1575#discussion_r1634977808

 - [x] I hereby declare this contribution to be licenced under the [Apache License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0)

---

https://issues.apache.org/jira/browse/MNG-8150
This commit is contained in:
Pavlo Shevchenko 2024-06-11 21:48:41 +00:00 committed by GitHub
parent e995ba62eb
commit db33754938
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 11 additions and 21 deletions

View File

@ -19,7 +19,6 @@
package org.apache.maven.cli.transfer;
import java.io.PrintStream;
import java.util.Locale;
import org.apache.maven.api.services.MessageBuilder;
import org.apache.maven.api.services.MessageBuilderFactory;
@ -72,7 +71,7 @@ public abstract class AbstractMavenTransferListener extends AbstractTransferList
TransferResource resource = event.getResource();
long contentLength = event.getTransferredBytes();
FileSizeFormat format = new FileSizeFormat(Locale.ENGLISH);
FileSizeFormat format = new FileSizeFormat();
MessageBuilder message = messageBuilderFactory.builder();
message.append(action).style(STYLE).append(' ').append(direction).append(' ');

View File

@ -21,7 +21,6 @@ package org.apache.maven.cli.transfer;
import java.io.PrintStream;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Locale;
import java.util.Map;
import org.apache.maven.api.services.MessageBuilderFactory;
@ -37,7 +36,7 @@ import org.eclipse.aether.transfer.TransferResource;
public class ConsoleMavenTransferListener extends AbstractMavenTransferListener {
private final Map<TransferResourceIdentifier, TransferResourceAndSize> transfers = new LinkedHashMap<>();
private final FileSizeFormat format = new FileSizeFormat(Locale.ENGLISH); // use in a synchronized fashion
private final FileSizeFormat format = new FileSizeFormat(); // use in a synchronized fashion
private final StringBuilder buffer = new StringBuilder(128); // use in a synchronized fashion
private final boolean printResourceNames;

View File

@ -18,8 +18,6 @@
*/
package org.apache.maven.cli.transfer;
import java.util.Locale;
import org.apache.maven.api.services.MessageBuilder;
/**
@ -101,8 +99,6 @@ public class FileSizeFormat {
}
}
public FileSizeFormat(Locale locale) {}
public String format(long size) {
return format(size, null);
}

View File

@ -18,8 +18,6 @@
*/
package org.apache.maven.cli.transfer;
import java.util.Locale;
import org.eclipse.aether.transfer.AbstractTransferListener;
import org.eclipse.aether.transfer.TransferCancelledException;
import org.eclipse.aether.transfer.TransferEvent;
@ -75,7 +73,7 @@ public class Slf4jMavenTransferListener extends AbstractTransferListener {
TransferResource resource = event.getResource();
long contentLength = event.getTransferredBytes();
FileSizeFormat format = new FileSizeFormat(Locale.ENGLISH);
FileSizeFormat format = new FileSizeFormat();
StringBuilder message = new StringBuilder();
message.append(action).append(' ').append(direction).append(' ').append(resource.getRepositoryId());

View File

@ -18,8 +18,6 @@
*/
package org.apache.maven.cli.transfer;
import java.util.Locale;
import org.apache.maven.cli.transfer.FileSizeFormat.ScaleUnit;
import org.junit.jupiter.api.Test;
@ -30,7 +28,7 @@ class FileSizeFormatTest {
@Test
void testNegativeSize() {
FileSizeFormat format = new FileSizeFormat(Locale.ENGLISH);
FileSizeFormat format = new FileSizeFormat();
long negativeSize = -100L;
assertThrows(IllegalArgumentException.class, () -> format.format(negativeSize));
@ -38,7 +36,7 @@ class FileSizeFormatTest {
@Test
void testSize() {
FileSizeFormat format = new FileSizeFormat(Locale.ENGLISH);
FileSizeFormat format = new FileSizeFormat();
long _0_bytes = 0L;
assertEquals("0 B", format.format(_0_bytes));
@ -103,7 +101,7 @@ class FileSizeFormatTest {
@Test
void testSizeWithSelectedScaleUnit() {
FileSizeFormat format = new FileSizeFormat(Locale.ENGLISH);
FileSizeFormat format = new FileSizeFormat();
long _0_bytes = 0L;
assertEquals("0 B", format.format(_0_bytes));
@ -206,7 +204,7 @@ class FileSizeFormatTest {
@Test
void testNegativeProgressedSize() {
FileSizeFormat format = new FileSizeFormat(Locale.ENGLISH);
FileSizeFormat format = new FileSizeFormat();
long negativeProgressedSize = -100L;
assertThrows(IllegalArgumentException.class, () -> format.formatProgress(negativeProgressedSize, 10L));
@ -214,14 +212,14 @@ class FileSizeFormatTest {
@Test
void testNegativeProgressedSizeBiggerThanSize() {
FileSizeFormat format = new FileSizeFormat(Locale.ENGLISH);
FileSizeFormat format = new FileSizeFormat();
assertThrows(IllegalArgumentException.class, () -> format.formatProgress(100L, 10L));
}
@Test
void testProgressedSizeWithoutSize() {
FileSizeFormat format = new FileSizeFormat(Locale.ENGLISH);
FileSizeFormat format = new FileSizeFormat();
long _0_bytes = 0L;
assertEquals("0 B", format.formatProgress(_0_bytes, -1L));
@ -238,7 +236,7 @@ class FileSizeFormatTest {
@Test
void testProgressedBothZero() {
FileSizeFormat format = new FileSizeFormat(Locale.ENGLISH);
FileSizeFormat format = new FileSizeFormat();
long _0_bytes = 0L;
assertEquals("0 B", format.formatProgress(_0_bytes, _0_bytes));
@ -246,7 +244,7 @@ class FileSizeFormatTest {
@Test
void testProgressedSizeWithSize() {
FileSizeFormat format = new FileSizeFormat(Locale.ENGLISH);
FileSizeFormat format = new FileSizeFormat();
long _0_bytes = 0L;
long _400_bytes = 400L;