
com.pervasivecode.utils.measure.SimpleUnitLabelProvider Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of measurement-utils-jsr363 Show documentation
Show all versions of measurement-utils-jsr363 Show documentation
Classes for using and formatting data and data-rate values in the JSR 363 Units of Measurement API.
The newest version!
package com.pervasivecode.utils.measure;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Map;
import javax.measure.Quantity;
import javax.measure.Unit;
/**
* This class provides unit labels for a single locale by looking them up in a static mapping of
* units to labels.
*/
public class SimpleUnitLabelProvider> implements UnitLabelProvider {
private final Map, String> unitLabels;
/**
* Set up a new instance with a static mapping of units to labels.
*
* @param unitLabels The mapping of units to labels.
*/
public SimpleUnitLabelProvider(Map, String> unitLabels) {
this.unitLabels = checkNotNull(unitLabels);
}
@Override
public String getLabel(Unit unit) {
return this.unitLabels.get(unit);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy