/** * Returns the default units factory. This factory uses the unit service provider which is * {@linkplain ServiceProvider#current() current} at the time of the first invocation of this method. * * @return the default units factory. */ public static synchronized Units getDefault() { if (DEFAULT == null) { DEFAULT = new Units(ServiceProvider.current().getSystemOfUnitsService().getSystemOfUnits()); } return DEFAULT; }
/** * Returns the default units factory. This factory uses the unit service provider which is * {@linkplain ServiceProvider#current() current} at the time of the first invocation of this method. * * @return the default units factory. */ public static synchronized Units getDefault() { if (DEFAULT == null) { DEFAULT = new Units(ServiceProvider.current().getSystemOfUnitsService().getSystemOfUnits()); } return DEFAULT; }
/** * Tests the "Imperial" system of units. */ @Test public void testImperial() { final ServiceProvider provider = ServiceProvider.current(); Set<? extends Unit<?>> units = provider.getSystemOfUnitsService().getSystemOfUnits("Imperial").getUnits(); assertFalse("METRE", units.contains(Units.METRE)); assertFalse("KILOMETRE", units.contains(Units.KILOMETRE)); assertFalse("CUBIC_METRE", units.contains(Units.CUBIC_METRE)); assertFalse("METRES_PER_SECOND", units.contains(Units.METRES_PER_SECOND)); assertFalse("KILOMETRES_PER_HOUR", units.contains(Units.KILOMETRES_PER_HOUR)); assertTrue ("STATUTE_MILE", units.contains(Units.STATUTE_MILE)); assertFalse("DEGREE", units.contains(Units.DEGREE)); assertFalse("RADIAN", units.contains(Units.RADIAN)); assertFalse("GRAD", units.contains(Units.GRAD)); }
/** * Tests the "SI" system of units. */ @Test public void testSI() { final ServiceProvider provider = ServiceProvider.current(); Set<? extends Unit<?>> units = provider.getSystemOfUnitsService().getSystemOfUnits("SI").getUnits(); assertTrue ("METRE", units.contains(Units.METRE)); assertTrue ("KILOMETRE", units.contains(Units.KILOMETRE)); assertTrue ("CUBIC_METRE", units.contains(Units.CUBIC_METRE)); assertTrue ("METRES_PER_SECOND", units.contains(Units.METRES_PER_SECOND)); assertFalse("KILOMETRES_PER_HOUR", units.contains(Units.KILOMETRES_PER_HOUR)); assertFalse("NAUTICAL_MILE", units.contains(Units.NAUTICAL_MILE)); assertFalse("STATUTE_MILE", units.contains(Units.STATUTE_MILE)); assertFalse("DEGREE", units.contains(Units.DEGREE)); assertTrue ("RADIAN", units.contains(Units.RADIAN)); assertFalse("GRAD", units.contains(Units.GRAD)); }
/** * Tests the "SI + accepted" system of units. */ @Test public void testAccepted() { final ServiceProvider provider = ServiceProvider.current(); Set<? extends Unit<?>> units = provider.getSystemOfUnitsService().getSystemOfUnits("SI + accepted").getUnits(); assertTrue ("METRE", units.contains(Units.METRE)); assertTrue ("KILOMETRE", units.contains(Units.KILOMETRE)); assertTrue ("CUBIC_METRE", units.contains(Units.CUBIC_METRE)); assertTrue ("METRES_PER_SECOND", units.contains(Units.METRES_PER_SECOND)); assertTrue ("KILOMETRES_PER_HOUR", units.contains(Units.KILOMETRES_PER_HOUR)); assertFalse("NAUTICAL_MILE", units.contains(Units.NAUTICAL_MILE)); assertFalse("STATUTE_MILE", units.contains(Units.STATUTE_MILE)); assertTrue ("DEGREE", units.contains(Units.DEGREE)); assertTrue ("RADIAN", units.contains(Units.RADIAN)); assertFalse("GRAD", units.contains(Units.GRAD)); }
/** * Tests the default system of units. */ @Test public void testDefaultSystemOfUnits() { final ServiceProvider provider = ServiceProvider.current(); Set<? extends Unit<?>> units = provider.getSystemOfUnitsService().getSystemOfUnits().getUnits(); assertTrue("METRE", units.contains(Units.METRE)); assertTrue("KILOMETRE", units.contains(Units.KILOMETRE)); assertTrue("CUBIC_METRE", units.contains(Units.CUBIC_METRE)); assertTrue("METRES_PER_SECOND", units.contains(Units.METRES_PER_SECOND)); assertTrue("KILOMETRES_PER_HOUR", units.contains(Units.KILOMETRES_PER_HOUR)); assertTrue("NAUTICAL_MILE", units.contains(Units.NAUTICAL_MILE)); assertTrue("STATUTE_MILE", units.contains(Units.STATUTE_MILE)); assertTrue("DEGREE", units.contains(Units.DEGREE)); assertTrue("RADIAN", units.contains(Units.RADIAN)); assertTrue("GRAD", units.contains(Units.GRAD)); }