mirror of https://github.com/apache/maven.git
[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:
parent
e995ba62eb
commit
db33754938
|
@ -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(' ');
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue