Back to project page br.com.mirabilis.sqlite.
The source code is released under:
Apache License
If you think the Android project br.com.mirabilis.sqlite listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package br.com.mirabilis.sqlite.annotation; /* ww w . j a v a2 s . c om*/ import java.lang.reflect.Field; import java.util.ArrayList; import java.util.List; import br.com.mirabilis.sqlite.annotation.model.SQLiteAnnotationEntity; import br.com.mirabilis.sqlite.annotation.model.SQLiteAnnotationField; import br.com.mirabilis.sqlite.manager.exception.SQLiteException; import br.com.mirabilis.sqlite.manager.model.SQLiteEntity; import br.com.mirabilis.sqlite.manager.model.SQLiteField; /** * Recovery values of {@link SQLiteAnnotationEntity} and * {@link SQLiteAnnotationField} * * @author Rodrigo Sim?es Rosa */ public final class SQLiteParseAnnotation { public final static SQLiteEntity getValuesFromAnnotation( Class<?> classHasAnnotation) throws SQLiteException { SQLiteAnnotationEntity entityAnnotation = null; List<SQLiteField> fields = null; if (classHasAnnotation .isAnnotationPresent(SQLiteAnnotationEntity.class)) { entityAnnotation = classHasAnnotation .getAnnotation(SQLiteAnnotationEntity.class); /** * Get fields of superclass SQLiteTable */ for (Field field : classHasAnnotation.getSuperclass() .getDeclaredFields()) { if (field.isAnnotationPresent(SQLiteAnnotationField.class)) { /** * Initialize variable */ if (fields == null) { fields = new ArrayList<SQLiteField>(); } fields.add(getSQLiteField(field .getAnnotation(SQLiteAnnotationField.class))); } } for (Field field : classHasAnnotation.getDeclaredFields()) { if (field.isAnnotationPresent(SQLiteAnnotationField.class)) { /** * Initialize variable */ if (fields == null) { fields = new ArrayList<SQLiteField>(); } fields.add(getSQLiteField(field .getAnnotation(SQLiteAnnotationField.class))); } } } else { throw new SQLiteException("The class : ".concat( classHasAnnotation.getName()) .concat(" has not annotation!")); } SQLiteEntity entity = new SQLiteEntity(entityAnnotation.name(), fields); return entity; } /** * Return {@link SQLiteField} by {@link SQLiteParseAnnotation} * * @param annotation * @return * @throws SQLiteException */ public final static SQLiteField getSQLiteField( SQLiteAnnotationField annotation) throws SQLiteException { return new SQLiteField.Builder(annotation.name(), annotation.type()) .autoIncrement(annotation.autoIncrement()) .notNull(annotation.notNull()) .primaryKey(annotation.primaryKey()) .reference(annotation.reference()) .foreignKey(annotation.foreignKey()) .foreignKeyModifier(annotation.foreignKeyModifier()) .action(annotation.action()).build(); } }