All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.fedy2.weather.binding.adapter.BarometricPressureStateAdapter Maven / Gradle / Ivy

There is a newer version: 2.0.2
Show newest version
/**
 * 
 */
package com.github.fedy2.weather.binding.adapter;

import javax.xml.bind.annotation.adapters.XmlAdapter;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.github.fedy2.weather.data.unit.BarometricPressureState;

/**
 * State of the barometric pressure adapter: steady (0), rising (1), or falling (2). 
 * (integer: 0, 1, 2)
 * @author "Federico De Faveri [email protected]"
 */
public class BarometricPressureStateAdapter extends	XmlAdapter {

	protected static final int FALLING = 2;
	protected static final int RISING = 1;
	protected static final int STEADY = 0;
	protected Logger logger = LoggerFactory.getLogger(BarometricPressureStateAdapter.class);
	
	/**
	 * {@inheritDoc}
	 */
	@Override
	public BarometricPressureState unmarshal(Integer v) throws Exception {
		switch (v) {
			case STEADY: return BarometricPressureState.STEADY;
			case RISING: return BarometricPressureState.RISING;
			case FALLING: return BarometricPressureState.FALLING;
		}
		logger.warn("Unknown barometric pressure state \""+v+"\"");
		return null;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public Integer marshal(BarometricPressureState v) throws Exception {
		switch (v) {
			case STEADY: return STEADY;
			case RISING: return RISING;
			case FALLING: return FALLING;
			default: return -1;
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy