Skip to content

Commit 7a0db62

Browse files
committed
https://java.net/jira/browse/UNITSOFMEASUREMENT-191
Could QuantityFactoryService be merged into ServiceProvider, too?
1 parent a0e8ee9 commit 7a0db62

3 files changed

Lines changed: 20 additions & 2 deletions

File tree

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636
*
3737
* @author <a href="mailto:units@catmedia.us">Werner Keil</a>
3838
* @author <a href="mailto:otaviojava@java.net">Otavio Santana</a>
39-
* @version 0.2
39+
* @version 0.3
40+
* @deprecated Factory provided by {@link ServiceProvider} directly
4041
*/
4142
public interface QuantityFactoryService {
4243

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
* <p>
4545
* All the methods in this class are safe for use by multiple concurrent threads.
4646
*
47-
* @version 0.8.2, April 1, 2016
47+
* @version 0.9, May 11, 2016
4848
* @author Werner Keil
4949
* @author Martin Desruisseaux
5050
*/
@@ -94,9 +94,19 @@ public int getPriority() {
9494
* Returns the service to obtain a {@link Quantity}, or {@code null} if none.
9595
*
9696
* @return the service to obtain a {@link Quantity}, or {@code null}.
97+
* @deprecated use {@link #getQuantityFactory(Class)} instead
9798
*/
9899
public abstract QuantityFactoryService getQuantityFactoryService();
99100

101+
/**
102+
* Return a factory for this {@link Quantity}.
103+
*
104+
* @param quantity
105+
* the quantity
106+
* @return the {@link QuantityFactory}
107+
*/
108+
public abstract <Q extends Quantity<Q>> QuantityFactory<Q> getQuantityFactory(Class<Q> quantity);
109+
100110
/**
101111
* Gets all {@link ServiceProvider}. This method loads the provider when first needed.
102112
*/

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333

3434
import static org.junit.Assert.*;
3535

36+
import javax.measure.Quantity;
37+
3638
/**
3739
* Tests for {@link ServiceProvider}.
3840
*/
@@ -79,5 +81,10 @@ public UnitFormatService getUnitFormatService() {
7981
public QuantityFactoryService getQuantityFactoryService() {
8082
return null;
8183
}
84+
85+
@Override
86+
public <Q extends Quantity<Q>> QuantityFactory<Q> getQuantityFactory(Class<Q> quantity) {
87+
return null;
88+
}
8289
}
8390
}

0 commit comments

Comments
 (0)