Android Open Source - Glowplug Glowplug Attribute






From Project

Back to project page Glowplug.

License

The source code is released under:

MIT License

If you think the Android project Glowplug 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.adecker.glowplug;
/*from  w  ww.j ava2  s  . c o m*/
import com.adecker.glowplugannotations.GlowplugType;

import java.util.ArrayList;

/**
 * Created by alex on 10/29/13.
 */
public class GlowplugAttribute extends GlowplugProperty {

    private final String tableName;
    private final String name;
    private final GlowplugType type;
    private final int index;

    private boolean primaryKey = false;
    private boolean autoIncrement = false;
    private String primaryKeyConflict = "";

    private ArrayList<String> constaints = new ArrayList<String>();

    private String sqliteType;
    private String sqliteName;

    private String remoteName;


    public GlowplugAttribute(String tableName, String name, GlowplugType type, int index) {
        this.tableName = tableName;
        this.name = name;
        this.type = type;
        this.index = index;

        sqliteName = name;
        sqliteType = "";

        remoteName = name;
    }

    @Override
    public String getName() {
        return name;
    }

    @Override
    public String getSqliteName() {
        return sqliteName;
    }

    @Override
    public String getRemoteName() {
        return remoteName;
    }

    @Override
    public String getFQName() {
        return tableName + "." + getSqliteName();
    }

    @Override
    public GlowplugType getType() {
        return type;
    }

    public String getSqliteType() {
        return sqliteType;
    }

    public String[] getConstraints() {
        return new String[0];
    }

    public boolean isPrimaryKey() {
        return primaryKey;
    }

    public boolean isAutoIncrement() {
        return autoIncrement;
    }

    public String getPrimaryKeyConflictClause() {
        return primaryKeyConflict;
    }

    public GlowplugAttribute addConstraint(String constraint) {
        constaints.add(constraint);
        return this;
    }

    public GlowplugAttribute setPrimaryKey(boolean primaryKey) {
        setPrimaryKey(primaryKey, false);
        return this;
    }

    /**
     * @param primaryKey
     * @param autoIncrement set to add the autoincrement clause to the primary key, property is ignored if primary key is composite
     * @return
     */
    public GlowplugAttribute setPrimaryKey(boolean primaryKey, boolean autoIncrement) {
        setPrimaryKey(primaryKey, autoIncrement, null);
        return this;
    }

    /**
     * @param primaryKey
     * @param autoIncrement  set to add the autoincrement clause to the primary key, property is ignored if primary key is composite
     * @param conflictClause use to specify an ON CONFLICT clause for the primary key
     * @return
     */
    public GlowplugAttribute setPrimaryKey(boolean primaryKey, boolean autoIncrement, String conflictClause) {
        this.primaryKey = primaryKey;
        this.autoIncrement = autoIncrement;
        this.primaryKeyConflict = conflictClause;
        return this;
    }

    public GlowplugAttribute setSqliteName(String sqliteName) {
        if (!sqliteName.isEmpty()) {
            this.sqliteName = sqliteName;
        }
        return this;
    }

    public GlowplugAttribute setSqliteType(String sqliteType) {
        this.sqliteType = sqliteType;
        return this;
    }

    public GlowplugAttribute setRemoteName(String remoteName) {
        if (!remoteName.isEmpty()) {
            this.remoteName = remoteName;
        }
        return this;
    }

    public int getIndex() {
        return index;
    }
}




Java Source Code List

com.adecker.glowplug.GlowplugAttribute.java
com.adecker.glowplug.GlowplugContentProvider.java
com.adecker.glowplug.GlowplugEntity.java
com.adecker.glowplug.GlowplugOpenHelper.java
com.adecker.glowplug.GlowplugProperty.java
com.adecker.glowplug.GlowplugRelationship.java
com.adecker.glowplugannotations.Attribute.java
com.adecker.glowplugannotations.Entity.java
com.adecker.glowplugannotations.GlowplugType.java
com.adecker.glowplugannotations.Model.java
com.adecker.glowplugannotations.Relationship.java
com.adecker.glowplugcompiler.EntityProcessor.java
com.adecker.glowplugcompiler.Util.java
com.adecker.glowplugcompiler.VariableParser.java
com.adecker.glowplugcompiler.example.ActorListFragment.java
com.adecker.glowplugcompiler.example.FilmListFragment.java
com.adecker.glowplugcompiler.example.MainActivity.java
com.adecker.glowplugcompiler.example.model.DataModel.java
com.adecker.glowplugcompiler.example.model.MyActor.java
com.adecker.glowplugcompiler.example.model.MyFilm.java
com.adecker.glowplugcompiler.example.model.SakilaHelper.java
.file.java