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

com.enonic.xp.convert.NumberConverter Maven / Gradle / Ivy

There is a newer version: 7.14.4
Show 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 );
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy