/** * Copyright (c) 2010-2016 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ package org.openhab.binding.enocean.internal.converter; import java.math.BigDecimal; import org.opencean.core.common.values.NumberWithUnit; import org.opencean.core.common.values.Unit; import org.openhab.core.library.types.DecimalType; /** * A converter to convert a NumberWithUnit type to a DecimalNumber * * @author Thomas Letsch (contact@thomas-letsch.de) * @since 1.3.0 * */ public class TemperatureNumberWithUnitConverter extends StateConverter<NumberWithUnit, DecimalType> { @Override protected NumberWithUnit convertFromImpl(DecimalType source) { return new NumberWithUnit(Unit.DEGREE_CELSIUS, source.toBigDecimal()); } @Override protected DecimalType convertToImpl(NumberWithUnit source) { return new DecimalType((BigDecimal) source.getValue()); } }