当前位置: 代码迷 >> Eclipse >> must implement the inherited abstract 如何解决
  详细解决方案

must implement the inherited abstract 如何解决

热度:851   发布时间:2016-04-23 02:01:20.0
must implement the inherited abstract 怎么解决
出错信息:
must implement the inherited abstract 
 method TypeConverter.convertIfNecessary(Object, Class<T>, Field)

代码如下:
引用
import java.util.Date;

import net.paoding.rose.web.paramresolver.ResolverFactoryImpl.DateEditor;

import org.springframework.beans.SimpleTypeConverter;
import org.springframework.beans.TypeConverter;
import org.springframework.beans.TypeMismatchException;
import org.springframework.core.MethodParameter;

public class ThreadSafedSimpleTypeConverter implements TypeConverter {

    @SuppressWarnings("unchecked")
    @Override
    public Object convertIfNecessary(Object value, Class requiredType) throws TypeMismatchException {
        return simpleTypeConverters.get().convertIfNecessary(value, requiredType);
    }

    @SuppressWarnings("unchecked")
    @Override
    public Object convertIfNecessary(Object value, Class requiredType, MethodParameter methodParam)
            throws TypeMismatchException {
        return simpleTypeConverters.get().convertIfNecessary(value, requiredType, methodParam);
    }

    ThreadLocal<SimpleTypeConverter> simpleTypeConverters = new ThreadLocal<SimpleTypeConverter>() {

        @Override
        protected SimpleTypeConverter initialValue() {
            return createSimpleTypeConverter();
        }
    };

    public SimpleTypeConverter getSimpleTypeConverter() {
        return simpleTypeConverters.get();
    }

    protected SimpleTypeConverter createSimpleTypeConverter() {
        // simpleTypeConverter is not for concurrency!
        SimpleTypeConverter simpleTypeConverter = new SimpleTypeConverter();
        simpleTypeConverter.useConfigValueEditors();
        simpleTypeConverter.registerCustomEditor(Date.class, new DateEditor(Date.class));
        simpleTypeConverter.registerCustomEditor(java.sql.Date.class, new DateEditor(
                java.sql.Date.class));
        simpleTypeConverter.registerCustomEditor(java.sql.Time.class, new DateEditor(
                java.sql.Time.class));
        simpleTypeConverter.registerCustomEditor(java.sql.Timestamp.class, new DateEditor(
                java.sql.Timestamp.class));
        return simpleTypeConverter;
  相关解决方案