com.enonic.xp.convert.NumberConverter Maven / Gradle / Ivy
The newest version!
package com.enonic.xp.convert;
abstract class NumberConverter
implements Converter
{
private final Class type;
NumberConverter( final Class type )
{
this.type = type;
}
@Override
public final Class getType()
{
return this.type;
}
@Override
public final T convert( final Object value )
{
if ( value instanceof Number )
{
return fromNumber( (Number) value );
}
return parse( value.toString() );
}
protected abstract T fromNumber( Number value );
protected abstract T parse( String value );
}