in a nutshell, i'm trying to build subclasses of an abstract class, all of which will be singletons. i'd like to just place the singleton "logic" in the super class. is this possible in Java? here is the code:
public abstract class Table {
//the static singleton instance. this will be inherited by subclasses of this class.
protected static Table m_Instance;
/**
* @param tableName the database table name.
*/
protected Table(String tableName, List<Column> columns) {
TABLE_NAME = tableName;
if(columns != null) {
if(!m_Columns.isEmpty())
m_Columns.clear();
m_Columns.addAll(columns);
} else {
throw new IllegalStateException("the columns list was null. this is a developer error. please report to support.");
}
}
protected static Table getInstance() {
if(m_Instance == null)
m_Instance = <? extends Table>;
}
}
and here is just a blurb for clarification of implementation:
public class CallTable extends Table {
//this class would inherit 'getInstance()' and the method would return a 'CallTable' object
}