@Override
	public P loadSafe(final Value<FullEntity<?>> container, final LoadContext ctx, final Path path) throws SkipException {
		// check if we need to redirect to a different translator
		final String containerDiscriminator = container.get().contains(DISCRIMINATOR_PROPERTY) ? container.get().getString(DISCRIMINATOR_PROPERTY) : null;	// wow no Optional or nullable get
		if (!Objects.equals(discriminator, containerDiscriminator)) {
			final ClassTranslator<? extends P> translator = byDiscriminator.get(containerDiscriminator);
			if (translator == null) {
				throw new IllegalStateException("Datastore object has discriminator value '" + containerDiscriminator + "' but no relevant @Subclass is registered");
			} else {
				// This fixes alsoLoad names in discriminators by changing the discriminator to what the
				// translator expects for loading that subclass. Otherwise we'll get the error above since the
				// translator discriminator and the container discriminator won't match.
				final StringValue discriminatorValue = StringValue.newBuilder(translator.getDiscriminator()).setExcludeFromIndexes(true).build();
				final FullEntity<?> updatedEntity = FullEntity.newBuilder(container.get()).set(DISCRIMINATOR_PROPERTY, discriminatorValue).build();
				return translator.load(EntityValue.of(updatedEntity), ctx, path);
			}
		} else {
			// This is a normal load
			if (log.isTraceEnabled())
				log.trace(LogUtils.msg(path, "Instantiating a " + declaredClass.getName()));

			final P into = forge.construct(declaredClass);

			populator.load(container.get(), ctx, path, into);

			return into;
		}
	}
@ Override public P loadSafe ( final Value < FullEntity < ? > > container , final LoadContext ctx , final Path path ) throws SkipException { final String containerDiscriminator = container . get ( ) . contains ( DISCRIMINATOR_PROPERTY ) ? container . get ( ) . getString ( DISCRIMINATOR_PROPERTY ) : null ; if ( ! Objects . equals ( discriminator , containerDiscriminator ) ) { final ClassTranslator < ? extends P > translator = byDiscriminator . get ( containerDiscriminator ) ; if ( translator == null ) { throw new IllegalStateException ( "Datastore object has discriminator value '" + containerDiscriminator + "' but no relevant @Subclass is registered" ) ; } else { final StringValue discriminatorValue = StringValue . newBuilder ( translator . getDiscriminator ( ) ) . setExcludeFromIndexes ( true ) . build ( ) ; final FullEntity < ? > updatedEntity = FullEntity . newBuilder ( container . get ( ) ) . set ( DISCRIMINATOR_PROPERTY , discriminatorValue ) . build ( ) ; return translator . load ( EntityValue . of ( updatedEntity ) , ctx , path ) ; } } else { if ( log . isTraceEnabled ( ) ) log . trace ( LogUtils . msg ( path , "Instantiating a " + declaredClass . getName ( ) ) ) ; final P into = forge . construct ( declaredClass ) ; populator . load ( container . get ( ) , ctx , path , into ) ; return into ; } }
/*