Android Open Source - adme A D M E Index Constraint






From Project

Back to project page adme.

License

The source code is released under:

Apache License

If you think the Android project adme listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.danielesegato.adme.annotation;
// w w  w.  j  ava  2 s  .  c om
import java.lang.annotation.Documented;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
 * Define an index and/or a constraint on one or more columns. Can be applied to a single field or a
 * class containing fields.
 * <p/>
 * At least one of {@link #index()} or {@link #unique()} should be defined.
 * <p/>
 * If the index/constraint is to be applied on a single field the annotation must be applied to that
 * field directly without specifying {@link #columns()}. This annotation will have no effect if the
 * field has no {@link ADMEField} annotation.
 * <p/>
 * If the index/constraint is to be applied on multiple fields the annotation must be added to the
 * array of {@link ADMEEntity#indexConstraints()} on the entity itself. And a list of
 * {@link #columns()} names must be specified (at least two columns). The column name is used, not
 * the field name, so be sure to consider the fact that fields marked with {@link ADMEField#foreign()}
 * end up with a suffix in the column name unless you overridden the column name with
 * {@link ADMEField#columnName()}. If a column name is not find a runtime error will be raised when
 * parsing the entity configuration.
 * <p/>
 * You can specify the {@link #indexName()} manually or let the system generate one for you.
 */
@Target(FIELD)
@Retention(RUNTIME)
@Documented()
@Inherited()
public @interface ADMEIndexConstraint {
    /**
     * Add an index to the field this is applied or to the list of columns defined, default is <em>false</em>
     *
     * @return <em>true</em> if this is an index, <em>false</em> otherwise
     */
    boolean index() default false;

    /**
     * Define a custom indexName for this index. If not defined it will be auto-generated.
     *
     * @return the indexName of the index in the database.
     */
    String indexName() default "";

    /**
     * Add an unique constraint to the field this is applied or to the list of columns defined, default is <em>false</em>
     *
     * @return <em>true</em> if this is an unique, <em>false</em> otherwise
     */
    boolean unique() default false;

    /**
     * List of columns this index apply. Be aware that foreign key column names do not match the field indexName by default.
     * <p/>
     * It is mandatory to include this array when defining an index which is not on a field, and it must have at least 2 columns.
     * An exception will be raised if you define it directly on a field.
     * <p/>
     * Be aware the foreign key columns, by default, are suffixed by {@link ADMEField.FOREIGN_FIELD_SUFFIX}
     * unless you specified a column name with {@link ADMEField#foreign()}
     *
     * @return an array of strings with the columns indexName being part of this index
     */
    String[] columns() default {};
}




Java Source Code List

com.danielesegato.adme.ADME.java
com.danielesegato.adme.annotation.ADMEEntity.java
com.danielesegato.adme.annotation.ADMEField.java
com.danielesegato.adme.annotation.ADMEIndexConstraint.java
com.danielesegato.adme.config.ADMEConfigUtils.java
com.danielesegato.adme.config.ADMEEntityConfig.java
com.danielesegato.adme.config.ADMEFieldConfig.java
com.danielesegato.adme.config.ADMEIndexConstraintConfig.java
com.danielesegato.adme.config.OnForeignUpdateDelete.java
com.danielesegato.adme.config.SQLiteType.java
com.danielesegato.adme.db.ADMESerializerMapping.java
com.danielesegato.adme.db.ADMESerializer.java
com.danielesegato.adme.db.ContentProviderUris.java
com.danielesegato.adme.db.SQLiteContentProvider.java
com.danielesegato.adme.db.serializer.BaseADMESerializer.java
com.danielesegato.adme.db.serializer.BigDecimalADMESerializer.java
com.danielesegato.adme.db.serializer.BooleanADMESerializer.java
com.danielesegato.adme.db.serializer.BooleanObjectADMESerializer.java
com.danielesegato.adme.db.serializer.CurrencyADMESerializer.java
com.danielesegato.adme.db.serializer.DateAsStringADMESerializer.java
com.danielesegato.adme.db.serializer.DateAsTimestampADMESerializer.java
com.danielesegato.adme.db.serializer.DoubleADMESerializer.java
com.danielesegato.adme.db.serializer.DoubleObjectADMESerializer.java
com.danielesegato.adme.db.serializer.EnumIntADMESerializer.java
com.danielesegato.adme.db.serializer.EnumStringADMESerializer.java
com.danielesegato.adme.db.serializer.IntADMESerializer.java
com.danielesegato.adme.db.serializer.IntObjectADMESerializer.java
com.danielesegato.adme.db.serializer.LongADMESerializer.java
com.danielesegato.adme.db.serializer.LongObjectADMESerializer.java
com.danielesegato.adme.db.serializer.StringADMESerializer.java
com.danielesegato.adme.provider.ADMEContentProviderComponent.java
com.danielesegato.adme.provider.ADMEContentProvider.java
com.danielesegato.adme.utils.DateHelper.java
com.danielesegato.adme.utils.SQLStringHelper.java
com.danielesegato.adme.utils.SQLiteScriptParser.java
com.danielesegato.demo.adme.ADMEDemoMainActivity.java
com.danielesegato.demo.adme.NavigationDrawerFragment.java