Skip to content

Commit 4020e07

Browse files
committed
195: Priority not for sorting in ServiceProvider?
Task-Url: #195
1 parent 09029f7 commit 4020e07

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,18 @@ public static enum FormatType {
8989
*/
9090
UnitFormat getUnitFormat(String name);
9191

92+
/**
93+
* Returns the unit format having the specified name or {@code null} if none.
94+
*
95+
* 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.
97+
* @param name
98+
* the name of the format.
99+
* @param variant Any arbitrary value used to indicate a variation of a <code>UnitFormat</code>.
100+
* @return the corresponding unit format.
101+
*/
102+
UnitFormat getUnitFormat(String name, String variant);
103+
92104
/**
93105
* Gets a list with available format names of a given type for this format service.
94106
*

src/test/java/javax/measure/spi/FormatServiceTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,17 @@ public UnitFormat getUnitFormat(String formatName) {
8282
Objects.requireNonNull(formatName, "Format name required");
8383
return unitFormats.get(formatName);
8484
}
85+
86+
/*
87+
* (non-Javadoc)
88+
*
89+
* @see UnitFormatService#getUnitFormat(String)
90+
*/
91+
@Override
92+
public UnitFormat getUnitFormat(String formatName, String variant) {
93+
Objects.requireNonNull(formatName, "Format name required");
94+
return unitFormats.get(formatName);
95+
}
8596

8697
/*
8798
* (non-Javadoc)

0 commit comments

Comments
 (0)