public void registerSubclass ( ClassTranslator < ? extends P > translator ) { byDiscriminator . put ( translator . getDiscriminator ( ) , translator ) ; Subclass sub = translator . getDeclaredClass ( ) . getAnnotation ( Subclass . class ) ; for ( String alsoLoad : sub . alsoLoad ( ) ) byDiscriminator . put ( alsoLoad , translator ) ; byClass . put ( translator . getDeclaredClass ( ) , translator ) ; }
Register a subclass translator with this class translator . That way if we get called upon to translate an instance of the subclass we will forward to the correct translator .