class QuantityType extends Number implements PrimitiveType, State, Command, Comparable<QuantityType<T>> {

    @Override
    public <U extends State> @Nullable U as(@Nullable Class<U> target) {
        if (target == OnOffType.class) {
            if (intValue() == 0) {
                return target.cast(OnOffType.OFF);
            } else if (SmartHomeUnits.PERCENT.equals(getUnit())) {
                return target.cast(toBigDecimal().compareTo(BigDecimal.ZERO) > 0 ? OnOffType.ON : OnOffType.OFF);
            } else if (toBigDecimal().compareTo(BigDecimal.ONE) == 0) {
                return target.cast(OnOffType.ON);
            } else {
                return null;
            }
        } else if (target == UpDownType.class) {
            if (doubleValue() == 0) {
                return target.cast(UpDownType.UP);
            } else if (toBigDecimal().compareTo(BigDecimal.ONE) == 0) {
                return target.cast(UpDownType.DOWN);
            } else {
                return null;
            }
        } else if (target == OpenClosedType.class) {
            if (doubleValue() == 0) {
                return target.cast(OpenClosedType.CLOSED);
            } else if (toBigDecimal().compareTo(BigDecimal.ONE) == 0) {
                return target.cast(OpenClosedType.OPEN);
            } else {
                return null;
            }
        } else if (target == HSBType.class) {
            return target.cast(
                    new HSBType(DecimalType.ZERO, PercentType.ZERO, new PercentType(toBigDecimal().multiply(HUNDRED))));
        } else if (target == PercentType.class) {
            if (SmartHomeUnits.PERCENT.equals(getUnit())) {
                return target.cast(new PercentType(toBigDecimal()));
            }
            return target.cast(new PercentType(toBigDecimal().multiply(HUNDRED)));
        } else if (target == DecimalType.class) {
            return target.cast(new DecimalType(toBigDecimal()));
        } else {
            return State.super.as(target);
        }
    }

    @SuppressWarnings("unchecked") public  QuantityType();
    @SuppressWarnings("unchecked") public  QuantityType(String value);
    public  QuantityType(Number value, Unit<T> unit);
    private  QuantityType(Quantity<T> quantity);

}