blob: 2e8173eb9069b3d1e2293674f72298a49e641423 [file] [log] [blame]
/**
*
* Copyright (c) 2011, 2016 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany)
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Christophe Loetz (Loetz GmbH&Co.KG) - initial implementation
*/
package org.eclipse.osbp.xtext.functionlibrary.common.uomo;
//import static org.eclipse.uomo.units.SI.Prefix.*;
import static org.eclipse.uomo.units.SI.METRE;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.TreeMap;
import org.eclipse.uomo.units.SI;
import org.eclipse.uomo.units.impl.BaseAmount;
import org.eclipse.uomo.units.impl.quantity.LengthAmount;
import org.unitsofmeasurement.quantity.Length;
import org.unitsofmeasurement.unit.Unit;
/**
* System of metric length units
*/
public class MetricLengthUnit extends ASystemOfQuantityUnits<SI,Length> implements ISystemOfQuantityUnits<SI,Length> {
protected MetricLengthUnit() {
super("Metric Length Units", SI.class, Length.class, LengthAmount.class);
}
protected final static TreeMap<Double,Unit<?>> sUnits = new TreeMap<Double,Unit<?>> ();
protected static MetricLengthUnit INSTANCE = new MetricLengthUnit();
// public final static Unit<Length> MM = SI.addUnit(METRE.divide (1000.0), "mm").asType(Length.class);
// public final static Unit<Length> CM = SI.addUnit(METRE.divide ( 100.0), "cm").asType(Length.class);
// public final static Unit<Length> M = SI.addUnit(METRE, "m").asType(Length.class);
// public final static Unit<Length> KM = SI.addUnit(METRE.multiply(1000.0), "km").asType(Length.class);
public final static Unit<Length> MM = SI.addUnit(METRE.divide (1000.0)).asType(Length.class);
public final static Unit<Length> CM = SI.addUnit(METRE.divide ( 100.0)).asType(Length.class);
public final static Unit<Length> M = SI.addUnit(METRE).asType(Length.class);
public final static Unit<Length> KM = SI.addUnit(METRE.multiply(1000.0)).asType(Length.class);
// public final static Unit<Length> MM = SI.addUnit(MILLI(METRE)).asType(Length.class);
// public final static Unit<Length> CM = SI.addUnit(CENTI(METRE)).asType(Length.class);
// public final static Unit<Length> M = SI.addUnit(METRE).asType(Length.class);
// public final static Unit<Length> KM = SI.addUnit(KILO(METRE)).asType(Length.class);
static {
addUnits(sUnits, MM, CM, M, KM);
}
protected final static MetricLengthUnit getInstance() {
if (INSTANCE == null) {
INSTANCE = new MetricLengthUnit();
}
return INSTANCE;
}
@Override
public Set<Unit<?>> getUnits() {
return units();
}
/**
* @see #getUnits()
*/
public static Set<Unit<?>> units() {
return new LinkedHashSet<Unit<?>>(sUnits.values());
}
/**
* @see #createAmount(Number, Unit)
*/
public static BaseAmount<Length> amount(Number number, Unit<Length> unit) {
return getInstance().createAmount(number, unit);
}
}