Skip to content

Commit

Permalink
200: Add a variant option when obtaining a UnitFormat from
Browse files Browse the repository at this point in the history
FormatService.

Task-Url: #200
  • Loading branch information
keilw committed Nov 16, 2020
1 parent ad6f19a commit d53ee57
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 173 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>javax.measure</groupId>
<artifactId>unit-api</artifactId>
<version>2.1.1-SNAPSHOT</version>
<version>2.1</version>
<name>Units of Measurement API</name>
<packaging>bundle</packaging>
<url>http://unitsofmeasurement.github.io/unit-api/</url>
Expand Down
81 changes: 0 additions & 81 deletions src/main/java/javax/measure/format/ParserException.java

This file was deleted.

7 changes: 4 additions & 3 deletions src/main/java/javax/measure/spi/FormatService.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
* This interface represent the service to obtain instances of {@link UnitFormat} and {@link QuantityFormat}.
*
* @author <a href="mailto:[email protected]">Werner Keil</a>
* @version 2.0, November 4, 2020
* @version 2.1, November 16, 2020
* @since 2.0
*/
public interface FormatService {
Expand Down Expand Up @@ -93,10 +93,11 @@ public static enum FormatType {
* Returns the unit format having the specified name or {@code null} if none.
*
* For example {@code getUnitFormat("Simple")} to return a simple {@link UnitFormat} implementation.<br>
* 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.
* 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.
* <p>If no variant is applicable, the <code>UnitFormat</code> matching the name only is returned.</p>
* @param name
* the name of the format.
* @param variant Any arbitrary value used to indicate a variation of a <code>UnitFormat</code>.
* @param variant any arbitrary value used to indicate a variation of a <code>UnitFormat</code>.
* @return the corresponding unit format.
*/
UnitFormat getUnitFormat(String name, String variant);
Expand Down
81 changes: 0 additions & 81 deletions src/main/jdk9/javax/measure/format/ParserException.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
package javax.measure.test.format;

import javax.measure.format.MeasurementParseException;
import javax.measure.format.ParserException;

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

@Test
public void testOldExceptionWithMessageDataAndPos() {
assertThrows(ParserException.class, () -> {
throw new ParserException("Error", " ", 0);
assertThrows(MeasurementParseException.class, () -> {
throw new MeasurementParseException("Error", " ", 0);
});
}

@Test
public void testOldExceptionWithMessageAndPos() {
assertThrows(ParserException.class, () -> {
throw new ParserException("Error", 0);
assertThrows(MeasurementParseException.class, () -> {
throw new MeasurementParseException("Error", 0);
});
}

@Test
public void testOldExceptionWithCause() {
assertThrows(ParserException.class, () -> {
throw new ParserException(new IllegalArgumentException("Error"));
assertThrows(MeasurementParseException.class, () -> {
throw new MeasurementParseException(new IllegalArgumentException("Error"));
});
}
}

0 comments on commit d53ee57

Please sign in to comment.