*/
public class MapifyTranslatorFactory implements TranslatorFactory<Map<Object, Object>, Collection<Object>>
{
@Override
public Translator<Map<Object, Object>, Collection<Object>> create(TypeKey<Map<Object, Object>> tk, CreateContext ctx, Path path) {
Mapify mapify = tk.getAnnotation(Mapify.class);
if (mapify == null)
return null;
@SuppressWarnings("unchecked")
final Class<? extends Map<?, ?>> mapType = tk.getTypeAsClass();
if (!Map.class.isAssignableFrom(mapType))
return null; // We might be here processing the component type of the mapify map!
final ObjectifyFactory fact = ctx.getFactory();
Type componentType = GenericUtils.getMapValueType(tk.getType());
final Translator<Object, Object> componentTranslator = fact.getTranslators().get(new TypeKey(componentType, tk), ctx, path);
@SuppressWarnings("unchecked")
final Mapper<Object, Object> mapper = (Mapper<Object, Object>)fact.construct(mapify.value());
return new TranslatorRecycles<Map<Object, Object>, Collection<Object>>() {
@Override
public Map<Object, Object> loadInto(Collection<Object> node, LoadContext ctx, Path path, Map<Object, Object> map) throws SkipException {
if (node == null)