我的类实现了与方法的接口。哪些没有实现但没有错误

时间:2014-11-16 18:55:35

标签: java reflection interface extend implements

我创建了dao类,它实现了两个方法的接口。它们都没有在dao类中实现。我没有错。一切都在汇编和运作。

我做错了什么?

这是我的道教课程:

package com.derp.generic.dao;

import javax.persistence.MappedSuperclass;
import org.springframework.stereotype.Repository;

import com.derp.generic.model.GenericDictionaryModel;

@Repository
@MappedSuperclass
public abstract class GenericDictionaryModelDaoImpl <T extends GenericDictionaryModel<?>> extends GenericModelDaoImpl implements GenericDictionaryModelDao {
}

这是我的界面:

package com.derp.generic.dao;

public interface GenericDictionaryModelDao<T> extends GenericModelDao<T>{
    public T getByName(String name);
    public T getByActive(boolean active);
}

REST OF CLASSESS:

package com.derp.generic.dao;

import java.util.List;

public interface GenericModelDao<T> {
    public void add(T entityClass);
    public void update(T entityClass);
    public void delete(long id);
    public T get(long id);
    public List<T> get();
    public String toString();
}

package com.derp.generic.model;

import javax.persistence.MappedSuperclass;

@MappedSuperclass
public abstract class GenericDictionaryModel<T extends GenericDictionaryModel<?>> extends GenericModel<T> {
    private String name;
    private boolean active;

    public String getName() {return name;}
    public void setName(String name) {this.name = name;}
    public boolean getActive() {return active;}
    public void setActive(boolean stat) {this.active = stat;}
}

package com.derp.generic.model;

import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;

@MappedSuperclass
public abstract class GenericModel<T extends GenericModel<?>> {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    public long getId() {return id;}
    public void setId(long id) {this.id = id;}

}

1 个答案:

答案 0 :(得分:4)

您的GenericDictionaryModelDaoImpl类是抽象的,因此它不必实现GenericDictionaryModelDao接口的所有方法。任何将从您的抽象类继承的具体类都必须实现该接口的所有未实现的方法。