com.github.fedy2.weather.binding.adapter.BarometricPressureStateAdapter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of yahoo-weather-java-api Show documentation
Show all versions of yahoo-weather-java-api Show documentation
A Java library for the yahoo weather RSS feed service
/**
*
*/
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;
}
}
}