I have a Record class. In this Record class i have a save() method which saves data to a database. I have several other classes that extend this Record class, for example, a Person class. In my Person class i would like to define the database table name and columns for the People database table. I would like to make these final static properties that all instances of Person reference. How do I let Record, the extended class, know this property will exist in all extended class? How do i define a static property for a class that the base class knows exists?
Would this be an appropriate use of an interface?
public class Record {
protected String table_name;
protected String[] table_columns;
private void save(){
//save data based on table_name and table_columns;
}
}
public class Person extends Record{
protected final static String table_name = "People";
protected final static String[] table_columns = {"_id","name"}
}