0

I'm trying to use greenDAO's implementsInterface method, here is most of my main generator class:

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:

interface expected here 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. Can anyone tell me what I need to do here?

Allan Pereira
  • 2,572
  • 4
  • 21
  • 28
Martin Seal
  • 616
  • 2
  • 14
  • 32

1 Answers1

1

This is not a greenDAO problem: addNewCard is a class, not an interface. If your model class needs to inherit from another class, you have to use setSuperclass() method. Example:

original_pronoun.setSuperclass("addNewCard");

Note that greenDAO doesn't support another entity as a super class yet, if this is your intention.

Check greenDAO docs for Inheritance and Interfaces.
See also this question: Implements vs. Extends. When to use? What's the Difference?

Community
  • 1
  • 1
Allan Pereira
  • 2,572
  • 4
  • 21
  • 28
  • 1
    sorry i should have been clearer i know this isnt a greendao error, – Martin Seal Jun 23 '16 at 20:31
  • @MartinSeal Sorry if I seemed rude, this was not the intention. :D – Allan Pereira Jun 23 '16 at 21:01
  • not at all, i took on board your comments read the docs again ive researched what you said about implements and extends and looked at abstract classes but i am still completely baffled about how im going to move forward with this, but i appreciate your comments – Martin Seal Jun 23 '16 at 21:07