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

com.github.fedy2.weather.binding.adapter.WeekDayAdapter 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.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;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy