@ JSONField ( serialize = false ) public AVQuery < T > getQuery ( Class < T > clazz ) { if ( getParent ( ) == null || StringUtil . isEmpty ( getParent ( ) . getObjectId ( ) ) ) { throw new IllegalStateException ( "unable to encode an association with an unsaved AVObject" ) ; } Map < String , Object > map = new HashMap < String , Object > ( ) ; map . put ( "object" , Utils . mapFromPointerObject ( AVRelation . this . getParent ( ) ) ) ; map . put ( "key" , AVRelation . this . getKey ( ) ) ; Map < String , Object > result = new HashMap < String , Object > ( ) ; result . put ( "$relatedTo" , map ) ; String targetClassName = getTargetClass ( ) ; if ( StringUtil . isEmpty ( getTargetClass ( ) ) ) { targetClassName = getParent ( ) . getClassName ( ) ; } AVQuery < T > query = new AVQuery < T > ( targetClassName , clazz ) ; query . addWhereItem ( "$relatedTo" , null , map ) ; if ( StringUtil . isEmpty ( getTargetClass ( ) ) ) { query . getParameters ( ) . put ( "redirectClassNameForKey" , this . getKey ( ) ) ; } return query ; }
Gets a query that can be used to query the subclass objects in this relation .