private void findKeyFields ( Class < ? > inspect , CreateContext ctx , Path path ) { if ( inspect == Object . class ) return ; findKeyFields ( inspect . getSuperclass ( ) , ctx , path ) ; for ( Field field : inspect . getDeclaredFields ( ) ) { if ( field . getAnnotation ( Id . class ) != null ) { if ( this . idMeta != null ) throw new IllegalStateException ( "Multiple @Id fields in the class hierarchy of " + clazz . getName ( ) ) ; if ( ( field . getType ( ) != Long . class ) && ( field . getType ( ) != long . class ) && ( field . getType ( ) != String . class ) ) throw new IllegalStateException ( "@Id field '" + field . getName ( ) + "' in " + inspect . getName ( ) + " must be of type Long, long, or String" ) ; Property prop = new FieldProperty ( ctx . getFactory ( ) , clazz , field ) ; Translator < Object , Object > translator = ctx . getTranslator ( new TypeKey <> ( prop ) , ctx , path . extend ( prop . getName ( ) ) ) ; this . idMeta = new PropertyPopulator <> ( prop , translator ) ; } else if ( field . getAnnotation ( Parent . class ) != null ) { if ( this . parentMeta != null ) throw new IllegalStateException ( "Multiple @Parent fields in the class hierarchy of " + clazz . getName ( ) ) ; if ( ! isAllowedParentFieldType ( field . getType ( ) ) ) throw new IllegalStateException ( "@Parent fields must be Ref<?>, Key<?>, or datastore Key. Illegal parent: " + field ) ; Property prop = new FieldProperty ( ctx . getFactory ( ) , clazz , field ) ; Translator < Object , Object > translator = ctx . getTranslator ( new TypeKey <> ( prop ) , ctx , path . extend ( prop . getName ( ) ) ) ; this . parentMeta = new PropertyPopulator <> ( prop , translator ) ; } } }
Recursively go through the class hierarchy looking for the idMeta and parentMeta fields .