com.abubusoft.kripton.android.annotation.BindDataSourceUpdateTask Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kripton-orm Show documentation
Show all versions of kripton-orm Show documentation
Kripton Persistence Library - ORM module
The newest version!
/**
*
*/
package com.abubusoft.kripton.android.annotation;
import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
import static java.lang.annotation.RetentionPolicy.CLASS;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import com.abubusoft.kripton.android.sqlite.SQLiteUpdateTask;
/**
*
* Database schema migrations are managed by migration tasks that are defined by
* SQLiteUpdateTask derived classes. You can define an update tasks set:
*
*
* - By code, typically in Application#onCreate method.
* - By annotation, in @BindDataSourceOptions annotation used in a data
* source definition.
*
*
*
* @BindContentProvider(authority = "com.abubusoft.contentprovidersample.provider")
* @BindDataSourceOptions(updateTasks = {
* @BindDataSourceUpdateTask(version = 2, task = PersonUpdateTask.class) }, populator = SamplePopulator.class)
* @BindDataSource(daoSet = { PersonDao.class }, fileName = "sample.db", version = 1)
* public interface SampleDataSource {
*
* }
*
*
*
* @BindDataSourceUpdateTask(version = 2, task = PersonUpdateTask.class)
will
* use the class PersonUpdateTask
to migrate from version 1 to version 2.
* Migration tasks support database migration from version n to version n+1. No
* gap versions are allowed. For this reason, you need only to specify target
* version, since star version is always defined as target version - 1.
*
*
*
public class PersonUpdateTask implements SQLiteUpdateTask {
@Override
public void execute(SQLiteDatabase database, int previousVersion, int currentVersion) {
...
}
}
*
* @author Francesco Benincasa ([email protected])
*/
@Retention(CLASS)
@Target(ANNOTATION_TYPE)
public @interface BindDataSourceUpdateTask {
/**
* Version.
*
* @return the int
*/
int version();
/**
* Task.
*
* @return the class<? extends SQ lite update task>
*/
Class extends SQLiteUpdateTask> task();
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy