package com.vmware.http.json;

import com.google.gson.FieldNamingStrategy;

import java.lang.reflect.Field;
import java.util.Map;


public class RuntimeFieldNamingStrategy implements FieldNamingStrategy {

    private Map<String, String> runtimeFieldNameMappings;

    public RuntimeFieldNamingStrategy(Map<String, String> runtimeFieldNameMappings) {
        this.runtimeFieldNameMappings = runtimeFieldNameMappings;
    }

    @Override
    public String translateName(Field field) {
        RuntimeFieldName runtimeFieldName = field.getAnnotation(RuntimeFieldName.class);
        if (runtimeFieldName == null) {
            return field.getName();
        }
        String fieldVariableName = runtimeFieldName.value();
        if (!runtimeFieldNameMappings.containsKey(fieldVariableName)) {
            throw new RuntimeException("No field name mapping for variable " + field.getName());
        }
        return runtimeFieldNameMappings.get(fieldVariableName);
    }
}

@@ -24,16 +24,58 @@
 .json;%0A%0A
+import com.google.gson.FieldNamingPolicy;%0A
 import c
@@ -241,16 +241,95 @@
 tegy %7B%0A%0A
+    private FieldNamingStrategy defaultStrategy = FieldNamingPolicy.IDENTITY;%0A%0A
     priv
@@ -747,30 +747,51 @@
  return 
-field.getName(
+defaultStrategy.translateName(field
 );%0A     

Update strategy to use IDENTITY as default strategy