[英]Error when implementing interfaces with greenDAO
I'm trying to use greenDAO's implementsInterface
method, here is most of my main generator class: 我正在尝试使用greenDAO的
implementsInterface
方法,这是我的大多数主要生成器类:
private static void addTables(final Schema schema) {
Entity photo_pronoun = addCard(schema);
Entity simple_pronoun = addSimpleCard(schema);
Entity original_pronoun = addOriginalCard(schema);
//implementsInterface method
original_pronoun.implementsInterface("addNewCard");
simple_pronoun.implementsInterface("addNewCard");
}
private static Entity addCard(final Schema schema) {
Entity card = schema.addEntity("addNewCard");
card.addIdProperty().primaryKey().autoincrement();
card.addStringProperty("cardName").notNull();
card.addStringProperty("cardSpeech");
card.addByteArrayProperty("cardIcon");
return card;
}
private static Entity addSimpleCard(final Schema schema) {
Entity card = schema.addEntity("addSimpleCard");
card.addIdProperty().primaryKey().autoincrement();
card.addStringProperty("cardName").notNull();
card.addStringProperty("cardSpeech");
card.addByteArrayProperty("cardIcon");
return card;
}
private static Entity addOriginalCard(final Schema schema) {
Entity card = schema.addEntity("addOriginalCard");
card.addIdProperty().primaryKey().autoincrement();
card.addStringProperty("cardName").notNull();
card.addStringProperty("cardSpeech");
card.addByteArrayProperty("cardIcon");
return card;
}
When I run this to create my files I get an error in original_pronoun and in simple_pronoun on my first line at addNewCard
: 当我运行它来创建文件时,在第一行的
addNewCard
上,original_pronoun和simple_pronoun出现错误:
interface expected here
public class addOriginalCard implements addNewCard {
此处需要的接口
public class addOriginalCard implements addNewCard {
I get that error because its not an interface, but I'm confused on how to fix it. 我收到该错误,因为它不是接口,但是我对如何解决它感到困惑。 The
implementsInterface
method says it takes a string but I've tried this and the database name with no joy. implementsInterface
方法说它需要一个字符串,但是我已经尝试过了,而且数据库名称也没有问题。 Can anyone tell me what I need to do here? 谁能告诉我我在这里需要做什么?
This is not a greenDAO problem: addNewCard
is a class, not an interface. 这不是greenDAO的问题:
addNewCard
是一个类,而不是一个接口。 If your model class needs to inherit from another class, you have to use setSuperclass()
method. 如果您的模型类需要从另一个类继承,则必须使用
setSuperclass()
方法。 Example: 例:
original_pronoun.setSuperclass("addNewCard");
Note that greenDAO doesn't support another entity as a super class yet, if this is your intention. 请注意,如果您打算这样做,greenDAO尚不支持另一个实体作为超类。
Check greenDAO docs for Inheritance and Interfaces . 检查greenDAO文档中的继承和接口 。
See also this question: Implements vs. Extends. 另请参阅以下问题: 实施与扩展。 When to use?
什么时候使用? What's the Difference?
有什么不同?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.