metagloss 0.0.2

net.sf.metagloss.db
Annotation Type CursorBind


@Target(value={METHOD,FIELD})
@Retention(value=RUNTIME)
@Inherited
public @interface CursorBind

Annotation to mark setter for data injection from a Cursor object and getters to ContentValues.

Both fields and methods can be marked with CursorBind, though a public, single argument, setter method is still required for injection. When extracting setter and getter methods from field names, the method must observe the following naming convention: (s|g)etCamelCasedNameOfField

Classes inherit CursorBind annotated fields and methods from super class.

If both a field and setter/getter are annotated with CursorBind pointing to the same setter/getter, the CursorBind annotating the method(s) takes precedence over the field's.

Exemplified

public class ParentClass
{
    @CursorBind("data") // inherited by both getter and setter
    private int data;
    
    @CursorBind("some_text")
    private String text;


    // annotated methods take precedence over annotated fields.
    @CursorBind("some_text_again_hmm")
    public void setData(int data)
    {
        this.data = data;
    }
    
    public int getData()
    {
        return this.data;
    }

    public void setText(String text)
    {
        this.text = text;
    }

    public String getText()
    {
        return this.text;
    }
}

public class ChildClass extends ParentClass
{
    @CursorBind("child_text") // overrides parent's annotation
    @Override
    public void setText(String text)
    {
        super.setText(text);
    }

    @CursorBind("child_text") // same here
    @Override
    public String getText()
    {
        return super.getText();
    }

    // (g|s)etData is untouched and its annotation inherited
}

See Also:
DBUtils.buildContentValues(Object), AssistCursor.inject(Object), XMLBind

Required Element Summary
 java.lang.String value
          The name of the column, as stored in the database
 

Element Detail

value

public abstract java.lang.String value
The name of the column, as stored in the database

Returns:
The name of the column.