com.github.fedy2.weather.binding.adapter.WeekDayAdapter 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
The 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.WeekDay;
/**
* @author "Federico De Faveri [email protected]"
*
*/
public class WeekDayAdapter extends XmlAdapter {
private Logger logger = LoggerFactory.getLogger(WeekDayAdapter.class);
@Override
public WeekDay unmarshal(String v) throws Exception {
try {
return WeekDay.valueOf(v.toUpperCase());
} catch (Exception e)
{
logger.warn("Unknow week day \"{}\"", v);
}
return null;
}
@Override
public String marshal(WeekDay v) throws Exception {
return v!=null?v.toString():null;
}
}