Search in sources :

Example 1 with LinkingObjects

use of io.realm.annotations.LinkingObjects in project realm-java by realm.

the class ClassMetaData method categorizeField.

private boolean categorizeField(Element element) {
    VariableElement variableElement = (VariableElement) element;
    // completely ignore any static fields
    if (variableElement.getModifiers().contains(Modifier.STATIC)) {
        return true;
    }
    if (variableElement.getAnnotation(Ignore.class) != null) {
        return true;
    }
    if (variableElement.getAnnotation(Index.class) != null) {
        if (!categorizeIndexField(element, variableElement)) {
            return false;
        }
    }
    if (variableElement.getAnnotation(Required.class) != null) {
        categorizeRequiredField(element, variableElement);
    } else {
        // RealmList and Primitive types are NOT nullable always. @Required annotation is not supported.
        if (!Utils.isPrimitiveType(variableElement) && !Utils.isRealmList(variableElement)) {
            nullableFields.add(variableElement);
        }
    }
    if (variableElement.getAnnotation(PrimaryKey.class) != null) {
        if (!categorizePrimaryKeyField(variableElement)) {
            return false;
        }
    }
    // Check @LinkingObjects last since it is not allowed to be either @Index, @Required or @PrimaryKey
    if (variableElement.getAnnotation(LinkingObjects.class) != null) {
        return categorizeBacklinkField(variableElement);
    }
    // Standard field that appear valid (more fine grained checks might fail later).
    fields.add(variableElement);
    return true;
}
Also used : LinkingObjects(io.realm.annotations.LinkingObjects) Ignore(io.realm.annotations.Ignore) Required(io.realm.annotations.Required) PrimaryKey(io.realm.annotations.PrimaryKey) Index(io.realm.annotations.Index) VariableElement(javax.lang.model.element.VariableElement)

Aggregations

Ignore (io.realm.annotations.Ignore)1 Index (io.realm.annotations.Index)1 LinkingObjects (io.realm.annotations.LinkingObjects)1 PrimaryKey (io.realm.annotations.PrimaryKey)1 Required (io.realm.annotations.Required)1 VariableElement (javax.lang.model.element.VariableElement)1