public abstract class ServiceProvider extends java.lang.Object
All the methods in this class are safe to use by multiple concurrent threads.
Modifier | Constructor and Description |
---|---|
protected |
ServiceProvider()
Creates a new service provider.
|
Modifier and Type | Method and Description |
---|---|
static java.util.List<ServiceProvider> |
available()
Returns the list of available service providers.
|
static ServiceProvider |
current()
Returns the current
ServiceProvider . |
abstract FormatService |
getFormatService()
|
int |
getPriority()
This method allows to define a priority for a registered ServiceProvider instance.
|
abstract <Q extends Quantity<Q>> |
getQuantityFactory(java.lang.Class<Q> quantity)
Return a factory for this
Quantity . |
abstract SystemOfUnitsService |
getSystemOfUnitsService()
Returns the service to obtain a
SystemOfUnits , or null if none. |
abstract UnitFormatService |
getUnitFormatService()
Deprecated.
Use #getFormatService(), this method will be removed in a future version, it is here for backward compatibility only.
|
static ServiceProvider |
setCurrent(ServiceProvider provider)
Replaces the current
ServiceProvider . |
protected ServiceProvider()
public int getPriority()
public abstract SystemOfUnitsService getSystemOfUnitsService()
SystemOfUnits
, or null
if none.SystemOfUnits
, or null
.public abstract UnitFormatService getUnitFormatService()
UnitFormat
, or null
if none.UnitFormat
, or null
.public abstract FormatService getFormatService()
UnitFormat
and QuantityFormat
, or null
.public abstract <Q extends Quantity<Q>> QuantityFactory<Q> getQuantityFactory(java.lang.Class<Q> quantity)
Quantity
.Q
- the type of the Quantity
resultquantity
- the quantityQuantityFactory
public static java.util.List<ServiceProvider> available()
public static ServiceProvider current()
ServiceProvider
. If necessary the ServiceProvider
will be lazily loaded.
If there are no providers available, an IllegalStateException is thrown, otherwise the provider with the highest priority is used or
the one explicitly designated via setCurrent(ServiceProvider)
.
ServiceProvider
used.java.lang.IllegalStateException
- if no ServiceProvider
has been found.getPriority()
,
setCurrent(ServiceProvider)
public static ServiceProvider setCurrent(ServiceProvider provider)
ServiceProvider
.provider
- the new ServiceProvider
Copyright © 2014–2018 Jean-Marie Dautelle, Werner Keil, Otavio Santana. All rights reserved.