package com.airbnb.aerosolve.core.transforms;

import com.google.common.base.CaseFormat;
import com.typesafe.config.Config;

/**
 * Created by hector_yee on 8/25/14.
 */
public class TransformFactory {
  public static Transform createTransform(Config config, String key) {
    if (config == null || key == null) {
      return null;
    }
    String transformName = config.getString(key + ".transform");
    if (transformName == null) {
      return null;
    }

    String name = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, transformName);
    Transform result = null;
    try {
      result = (Transform) Class.forName("com.airbnb.aerosolve.core.transforms." + name + "Transform").newInstance();
      result.configure(config, key);
    } catch (InstantiationException e) {
      e.printStackTrace();
    } catch (IllegalAccessException e) {
      e.printStackTrace();
    } catch (ClassNotFoundException e) {
      e.printStackTrace();
    }
    return result;
  }
}

@@ -569,17 +569,10 @@
 sult
- = null
 ;%0A
+
     
@@ -703,135 +703,55 @@
     
-  result.configure(config, key);%0A    %7D catch (InstantiationException e) %7B%0A      e.printStackTrace();%0A    %7D catch (IllegalAccess
+%7D catch (Exception e) %7B%0A      throw new Runtime
 Exce
@@ -759,114 +759,53 @@
 tion
- e) %7B
+(e);
 %0A    
-  e.printStackTrace();%0A    %7D catch (ClassNotFoundException e) %7B%0A      e.printStackTrace();%0A    %7D
+%7D%0A    result.configure(config, key);
 %0A   

Throw exception if transform not found