Package cn.leancloud

Class LCRelation<T extends LCObject>

java.lang.Object
cn.leancloud.LCRelation<T>

public class LCRelation<T extends LCObject> extends Object
  • Constructor Details

    • LCRelation

      public LCRelation()
    • LCRelation

      public LCRelation(LCObject parent, String key)
    • LCRelation

      public LCRelation(String targetClass)
  • Method Details

    • getKey

      public String getKey()
    • setKey

      public void setKey(String key)
    • getParent

      public LCObject getParent()
    • setParent

      public void setParent(LCObject parent)
    • getTargetClass

      public String getTargetClass()
    • setTargetClass

      public void setTargetClass(String targetClass)
    • add

      public void add(T object)
      Adds an object to this relation.
      Parameters:
      object - The object to add to this relation.
    • addAll

      public void addAll(Collection<T> objects)
      Adds many objects to this relation.
      Parameters:
      objects - The objects to add to this relation.
    • remove

      public void remove(LCObject object)
      Removes an object from this relation.
      Parameters:
      object - The object to remove from this relation.
    • getQuery

      public LCQuery<T> getQuery()
      Gets a query that can be used to query the objects in this relation.
      Returns:
      A AVQuery that restricts the results to objects in this relations.
    • getQuery

      public LCQuery<T> getQuery(Class<T> clazz)
      Gets a query that can be used to query the subclass objects in this relation.
      Parameters:
      clazz - The AVObject subclass.
      Returns:
      A AVQuery that restricts the results to objects in this relations.
    • reverseQuery

      public static <M extends LCObject> LCQuery<M> reverseQuery(String parentClassName, String relationKey, LCObject child)
      Create a query that can be used to query the parent objects in this relation.
      Type Parameters:
      M - template type.
      Parameters:
      parentClassName - The parent class name
      relationKey - The relation field key in parent
      child - The child object.
      Returns:
      A AVQuery that restricts the results to parent objects in this relations.
    • reverseQuery

      public static <M extends LCObject> LCQuery<M> reverseQuery(Class<M> theParentClazz, String relationKey, LCObject child)
      Create a query that can be used to query the parent objects in this relation.
      Type Parameters:
      M - template type.
      Parameters:
      theParentClazz - The parent subclass.
      relationKey - The relation field key in parent
      child - The child object.
      Returns:
      A AVQuery that restricts the results to parent objects in this relations.