Package com.googlecode.objectify.annotation

Examples of com.googlecode.objectify.annotation.Mapify


*/
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)
View Full Code Here

TOP

Related Classes of com.googlecode.objectify.annotation.Mapify

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.