private List < Class < ? > > getClassesByDiscriminators ( Collection < String > discriminators ) { Map < String , Class < ? > > entitiesByName = new HashMap <> ( ) ; // Prepare a Map of discriminator name -> entity class for ( QEntity child : entity . getSubEntities ( ) ) { entitiesByName . put ( child . getDiscriminatorValue ( ) , child . getEntityClass ( ) ) ; } // If the root class isn't abstract then add it to the list of possible discriminators too if ( ! entity . isEntityClassAbstract ( ) ) entitiesByName . put ( entity . getDiscriminatorValue ( ) , entity . getEntityClass ( ) ) ; // Translate the discriminator string values to classes List < Class < ? > > classes = new ArrayList <> ( discriminators . size ( ) ) ; for ( String discriminator : discriminators ) { final Class < ? > clazz = entitiesByName . get ( discriminator ) ; if ( clazz != null ) classes . add ( clazz ) ; else throw new IllegalArgumentException ( "Invalid class discriminator '" + discriminator + "', expected one of: " + entitiesByName . keySet ( ) ) ; } return classes ; }
Translates the set of string discriminators into entity classes