au.net.causal.projo.prefs.transform.LongToStringTransformer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of projo Show documentation
Show all versions of projo Show documentation
API for binding preferences to Java classes.
The newest version!
package au.net.causal.projo.prefs.transform;
import au.net.causal.projo.prefs.PreferencesException;
/**
* Converts between {@link Long} values and string values.
*
* @author prunge
*/
public class LongToStringTransformer extends GenericToStringTransformer
{
public LongToStringTransformer()
{
super(Long.class);
}
@Override
protected Long stringToValue(String s) throws PreferencesException
{
try
{
return(Long.valueOf(s));
}
catch (NumberFormatException e)
{
throw new PreferencesException("Failed to convert value '" + s + "' to a long.", e);
}
}
@Override
protected String valueToString(Long value) throws PreferencesException
{
return(value.toString());
}
}