-
-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Task-Url: #299
- Loading branch information
Showing
1 changed file
with
9 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,16 +93,16 @@ | |
* @author <a href="mailto:[email protected]">Werner Keil</a> | ||
* @author <a href="mailto:[email protected]">Jean-Marie Dautelle</a> | ||
* @author <a href="mailto:[email protected]">Otavio Santana</a> | ||
* @version 1.3, $Date: 2018-11-02 $ | ||
* @version 1.4, $Date: 2020-08-06 $ | ||
* @since 1.0 | ||
*/ | ||
public class DefaultQuantityFactory<Q extends Quantity<Q>> implements QuantityFactory<Q> { | ||
@SuppressWarnings("rawtypes") | ||
static final Map<Class, QuantityFactory> INSTANCES = new HashMap<>(); | ||
|
||
static final Logger logger = Logger.getLogger(DefaultQuantityFactory.class.getName()); | ||
static final Logger LOGGER = Logger.getLogger(DefaultQuantityFactory.class.getName()); | ||
|
||
static final Level LOG_LEVEL = Level.FINE; | ||
static final Level DEFAULT_LOG_LEVEL = Level.FINER; | ||
|
||
/** | ||
* The type of the quantities created by this factory. | ||
|
@@ -151,6 +151,11 @@ public class DefaultQuantityFactory<Q extends Quantity<Q>> implements QuantityFa | |
CLASS_TO_SYSTEM_UNIT.put(Acceleration.class, METRE_PER_SQUARE_SECOND); | ||
CLASS_TO_SYSTEM_UNIT.put(Area.class, SQUARE_METRE); | ||
CLASS_TO_SYSTEM_UNIT.put(Volume.class, CUBIC_METRE); | ||
|
||
if (LOGGER.isLoggable(Level.CONFIG)) { | ||
LOGGER.config(String.format("Registered quantity types: %s", | ||
CLASS_TO_SYSTEM_UNIT.keySet())); | ||
} | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
|
@@ -170,7 +175,7 @@ private DefaultQuantityFactory(Class<Q> quantity) { | |
*/ | ||
@SuppressWarnings("unchecked") | ||
public static <Q extends Quantity<Q>> QuantityFactory<Q> getInstance(final Class<Q> type) { | ||
logger.log(LOG_LEVEL, "Type: " + type + ": " + type.isInterface()); | ||
LOGGER.log(DEFAULT_LOG_LEVEL, "Type: " + type + ": " + type.isInterface()); | ||
QuantityFactory<Q> factory; | ||
factory = INSTANCES.get(type); | ||
if (factory != null) { | ||
|