I am currently writing a java-class that wraps an SQLite database. This class has two ways to be instantiated:
- Open an existing database.
- Create a new database.
This is what I came up with:
public class SQLiteDatabaseWrapper {
public static SQLiteDatabaseWrapper openExisting(File PathToDB) {
return new SQLiteDatabaseWrapper(PathToDB);
}
public static SQLiteDatabaseWrapper createNew(File PathToDB) {
CreateAndInitializeNewDatabase(PathToDB);
return new SQLiteDatabaseWrapper(PathToDB);
}
private SQLiteDatabaseWrapper(File PathToDB) {
// Open connection and setup wrapper
}
}
Is this the way to go in Java, or is there any other best practice for this situation?