All Downloads are FREE. Search and download functionalities are using the official Maven repository.

br.com.objectos.way.etc.ToMapping Maven / Gradle / Ivy

The newest version!
/*
 * ToMapping.java criado em 07/09/2012
 * 
 * Propriedade de Objectos Fábrica de Software LTDA.
 * Reprodução parcial ou total proibida.
 */
package br.com.objectos.way.etc;

import static com.google.common.collect.Lists.transform;

import java.util.List;
import java.util.Map;

import com.google.common.base.Function;
import com.google.common.collect.ImmutableList;

/**
 * @author [email protected] (Marcio Endo)
 */
enum ToMapping implements Function, Mapping> {

  INSTANCE;

  @Override
  public Mapping apply(Map map) {
    return new MappingPojo(map);
  }

  @SuppressWarnings("unchecked")
  public static List load(Object load) {
    List> list;

    if (List.class.isAssignableFrom(load.getClass())) {
      list = (List>) load;
    } else {
      Map map = (Map) load;
      list = ImmutableList.of(map);
    }

    return transform(list, INSTANCE);
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy