src/main/java/com/googlecode/objectify/impl/translate/ClassTranslator.java
@Override
	public Value<FullEntity<?>> saveSafe(final P pojo, final boolean index, final SaveContext ctx, final Path path) throws SkipException {
		// check if we need to redirect to a different translator
		if (pojo.getClass() != declaredClass) {
			// Sometimes generics are more of a hindrance than a help
			@SuppressWarnings("unchecked")
			final ClassTranslator<P> translator = (ClassTranslator<P>)byClass.get(pojo.getClass());
			if (translator == null)
				throw new IllegalStateException("Class '" + pojo.getClass() + "' is not a registered @Subclass");
			else
				return translator.save(pojo, index, ctx, path);
		} else {
			// This is a normal save
			final FullEntity.Builder<IncompleteKey> into = FullEntity.newBuilder();

			populator.save(pojo, index, ctx, path, into);

			if (discriminator != null) {
				into.set(DISCRIMINATOR_PROPERTY, StringValue.newBuilder(discriminator).setExcludeFromIndexes(true).build());

				if (!indexedDiscriminators.isEmpty())
					into.set(DISCRIMINATOR_INDEX_PROPERTY, ListValue.of(indexedDiscriminators));
			}

			// The question of whether to index this is weird. In order for subthings to be indexed, the entity needs
			// to be indexed. But then lists with index-heterogeous values (say, nulls) get reordered (!)
			// by the datastore. So we always index EntityValues and force all the list translators homogenize their lists.
			// Gross but seems to be the only way.
			return EntityValue.of(into.build());
		}
	}
@Override
	public Value<FullEntity<?>> saveSafe(final P pojo, final boolean index, final SaveContext ctx, final Path path) throws SkipException {
		// check if we need to redirect to a different translator
		if (pojo.getClass() != declaredClass) {
			// Sometimes generics are more of a hindrance than a help
			@SuppressWarnings("unchecked")
			final ClassTranslator<P> translator = (ClassTranslator<P>)byClass.get(pojo.getClass());
			if (translator == null)
				throw new IllegalStateException("Class '" + pojo.getClass() + "' is not a registered @Subclass");
			else
				return translator.save(pojo, index, ctx, path);
		} else {
			// This is a normal save
			final FullEntity.Builder<IncompleteKey> into = FullEntity.newBuilder();

			populator.save(pojo, index, ctx, path, into);

			if (discriminator != null) {
				into.set(DISCRIMINATOR_PROPERTY, StringValue.newBuilder(discriminator).setExcludeFromIndexes(true).build());

				if (!indexedDiscriminators.isEmpty())
					into.set(DISCRIMINATOR_INDEX_PROPERTY, ListValue.of(indexedDiscriminators));
			}

			// The question of whether to index this is weird. In order for subthings to be indexed, the entity needs
			// to be indexed. But then lists with index-heterogeous values (say, nulls) get reordered (!)
			// by the datastore. So we always index EntityValues and force all the list translators homogenize their lists.
			// Gross but seems to be the only way.
			return EntityValue.of(into.build());
		}
	}
@ Override public Value < FullEntity < ? > > saveSafe ( final P pojo , final boolean index , final SaveContext ctx , final Path path ) throws SkipException { // check if we need to redirect to a different translator if ( pojo . getClass ( ) != declaredClass ) { // Sometimes generics are more of a hindrance than a help @ SuppressWarnings ( "unchecked" ) final ClassTranslator < P > translator = ( ClassTranslator < P > ) byClass . get ( pojo . getClass ( ) ) ; if ( translator == null ) throw new IllegalStateException ( "Class '" + pojo . getClass ( ) + "' is not a registered @Subclass" ) ; else return translator . save ( pojo , index , ctx , path ) ; } else { // This is a normal save final FullEntity . Builder < IncompleteKey > into = FullEntity . newBuilder ( ) ; populator . save ( pojo , index , ctx , path , into ) ; if ( discriminator != null ) { into . set ( DISCRIMINATOR_PROPERTY , StringValue . newBuilder ( discriminator ) . setExcludeFromIndexes ( true ) . build ( ) ) ; if ( ! indexedDiscriminators . isEmpty ( ) ) into . set ( DISCRIMINATOR_INDEX_PROPERTY , ListValue . of ( indexedDiscriminators ) ) ; } // The question of whether to index this is weird. In order for subthings to be indexed, the entity needs // to be indexed. But then lists with index-heterogeous values (say, nulls) get reordered (!) // by the datastore. So we always index EntityValues and force all the list translators homogenize their lists. // Gross but seems to be the only way. return EntityValue . of ( into . build ( ) ) ; } }
/*
/ *