Skip to content

Commit d53ee57

Browse files
committed
200: Add a variant option when obtaining a UnitFormat from
FormatService. Task-Url: #200
1 parent ad6f19a commit d53ee57

File tree

5 files changed

+11
-173
lines changed

5 files changed

+11
-173
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<modelVersion>4.0.0</modelVersion>
55
<groupId>javax.measure</groupId>
66
<artifactId>unit-api</artifactId>
7-
<version>2.1.1-SNAPSHOT</version>
7+
<version>2.1</version>
88
<name>Units of Measurement API</name>
99
<packaging>bundle</packaging>
1010
<url>http://unitsofmeasurement.github.io/unit-api/</url>

src/main/java/javax/measure/format/ParserException.java

Lines changed: 0 additions & 81 deletions
This file was deleted.

src/main/java/javax/measure/spi/FormatService.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
* This interface represent the service to obtain instances of {@link UnitFormat} and {@link QuantityFormat}.
3939
*
4040
* @author <a href="mailto:werner@uom.technology">Werner Keil</a>
41-
* @version 2.0, November 4, 2020
41+
* @version 2.1, November 16, 2020
4242
* @since 2.0
4343
*/
4444
public interface FormatService {
@@ -93,10 +93,11 @@ public static enum FormatType {
9393
* Returns the unit format having the specified name or {@code null} if none.
9494
*
9595
* For example {@code getUnitFormat("Simple")} to return a simple {@link UnitFormat} implementation.<br>
96-
* The variant is an arbitrary value to allow a variation of a <code>UnitFormat</code>, for example <code>case sensitive</code> vs. <code>case insensitive</code> <a href="https://ucum.org/ucum.html">UCUM</a> format.
96+
* The variant is an arbitrary value to allow a variation of a <code>UnitFormat</code>, for example <code>case sensitive</code> vs. <code>case insensitive</code> <a href="https://ucum.org/ucum.html">UCUM</a> format.
97+
* <p>If no variant is applicable, the <code>UnitFormat</code> matching the name only is returned.</p>
9798
* @param name
9899
* the name of the format.
99-
* @param variant Any arbitrary value used to indicate a variation of a <code>UnitFormat</code>.
100+
* @param variant any arbitrary value used to indicate a variation of a <code>UnitFormat</code>.
100101
* @return the corresponding unit format.
101102
*/
102103
UnitFormat getUnitFormat(String name, String variant);

src/main/jdk9/javax/measure/format/ParserException.java

Lines changed: 0 additions & 81 deletions
This file was deleted.

src/test/java/javax/measure/test/format/MeasurementParseTest.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
package javax.measure.test.format;
3131

3232
import javax.measure.format.MeasurementParseException;
33-
import javax.measure.format.ParserException;
3433

3534
import org.junit.jupiter.api.Test;
3635
import static org.junit.jupiter.api.Assertions.*;
@@ -49,22 +48,22 @@ public void testExceptionWithMessage() {
4948

5049
@Test
5150
public void testOldExceptionWithMessageDataAndPos() {
52-
assertThrows(ParserException.class, () -> {
53-
throw new ParserException("Error", " ", 0);
51+
assertThrows(MeasurementParseException.class, () -> {
52+
throw new MeasurementParseException("Error", " ", 0);
5453
});
5554
}
5655

5756
@Test
5857
public void testOldExceptionWithMessageAndPos() {
59-
assertThrows(ParserException.class, () -> {
60-
throw new ParserException("Error", 0);
58+
assertThrows(MeasurementParseException.class, () -> {
59+
throw new MeasurementParseException("Error", 0);
6160
});
6261
}
6362

6463
@Test
6564
public void testOldExceptionWithCause() {
66-
assertThrows(ParserException.class, () -> {
67-
throw new ParserException(new IllegalArgumentException("Error"));
65+
assertThrows(MeasurementParseException.class, () -> {
66+
throw new MeasurementParseException(new IllegalArgumentException("Error"));
6867
});
6968
}
7069
}

0 commit comments

Comments
 (0)