content: /**
   * Created on 2019/6/7.
   */
  package com.alicp.jetcache.anno.support;
  
  import com.alicp.jetcache.CacheConfigException;
  import com.alicp.jetcache.anno.KeyConvertor;
  import com.alicp.jetcache.support.Fastjson2KeyConvertor;
  import com.alicp.jetcache.support.FastjsonKeyConvertor;
  import com.alicp.jetcache.support.JacksonKeyConvertor;
  
  import java.util.function.Function;
  
  /**
   * @author huangli
   */
  public class DefaultKeyConvertorParser implements KeyConvertorParser {
      @Override
      public Function<Object, Object> parseKeyConvertor(String convertor) {
          if (convertor == null) {
              return null;
          }
          if (KeyConvertor.FASTJSON.equalsIgnoreCase(convertor)) {
              return FastjsonKeyConvertor.INSTANCE;
          } else if (KeyConvertor.FASTJSON2.equalsIgnoreCase(convertor)) {
              return Fastjson2KeyConvertor.INSTANCE;
          } else if (KeyConvertor.JACKSON.equalsIgnoreCase(convertor)) {
              return JacksonKeyConvertor.INSTANCE;
          } else if (KeyConvertor.NONE.equalsIgnoreCase(convertor)) {
              return KeyConvertor.NONE_INSTANCE;
          }
          throw new CacheConfigException("not supported:" + convertor);
      }
  }
  