// Path: src/main/java/com/morcinek/android/codegenerator/codegeneration/providers/ResourceProvider.java
// public interface ResourceProvider {
// 
//     public Map<String, String> provideValues();
// 
//     public Set<String> provideInterface();
// 
//     public Set<String> provideMethod();
// 
//     public Set<String> provideAssignment();
// 
//     public Set<String> provideField();
// }
// 
// Path: src/main/java/com/morcinek/android/codegenerator/codegeneration/templates/TemplateManager.java
// public class TemplateManager {
// 
//     private String template;
// 
//     public TemplateManager(String template) {
//         this.template = template;
//     }
// 
//     public void addTemplateValue(String key, String value) {
//         template = template.replace(getKeyWrapper(key), value);
//     }
// 
//     public void addTemplateValues(Map<String, String> templateValueMap) {
//         for (String key : templateValueMap.keySet()) {
//             addTemplateValue(key, templateValueMap.get(key));
//         }
//     }
// 
//     public String getResult() {
//         return template.replaceAll("\\$\\{\\w+\\}", "").replaceAll("[ ]+\n", "");
//     }
// 
//     private String getKeyWrapper(String key) {
//         return "${" + key + "}";
//     }
// }
// 
// Path: src/main/java/com/morcinek/android/codegenerator/codegeneration/templates/TemplatesProvider.java
// public interface TemplatesProvider {
// 
//     String provideTemplateForName(String templateName);
// }


import com.morcinek.android.codegenerator.codegeneration.providers.ResourceProvider;
import com.morcinek.android.codegenerator.codegeneration.templates.TemplateManager;
import com.morcinek.android.codegenerator.codegeneration.templates.TemplatesProvider;
import java.util.List;
package com.morcinek.android.codegenerator.codegeneration.builders.resources;



/**
 * Copyright 2014 Tomasz Morcinek. All rights reserved.
 */
public class FieldsBuilder extends ResourceCodeBuilder {

    private StringBuilder stringBuilder;

    public FieldsBuilder(List<ResourceProvider> resourceProviders, TemplatesProvider templatesProvider) {
        super(resourceProviders, templatesProvider);
    }

    @Override
    protected void initializeFields() {
        stringBuilder = new StringBuilder();
    }

    @Override
    protected void processResourceProvider(ResourceProvider resourceProvider) {
        if (resourceProvider.provideField() != null) {
            for (String field : resourceProvider.provideField()) {
                TemplateManager templateManager = getTemplateManager(field);
                templateManager.addTemplateValues(resourceProvider.provideValues());
                stringBuilder.append(templateManager.getResult());
            }
        }
    }

    private TemplateManager getTemplateManager(String assignment) {
// Path: src/main/java/com/morcinek/android/codegenerator/codegeneration/providers/ResourceProvider.java
// public interface ResourceProvider {
// 
//     public Map<String, String> provideValues();
// 
//     public Set<String> provideInterface();
// 
//     public Set<String> provideMethod();
// 
//     public Set<String> provideAssignment();
// 
//     public Set<String> provideField();
// }
// 
// Path: src/main/java/com/morcinek/android/codegenerator/codegeneration/templates/TemplateManager.java
// public class TemplateManager {
// 
//     private String template;
// 
//     public TemplateManager(String template) {
//         this.template = template;
//     }
// 
//     public void addTemplateValue(String key, String value) {
//         template = template.replace(getKeyWrapper(key), value);
//     }
// 
//     public void addTemplateValues(Map<String, String> templateValueMap) {
//         for (String key : templateValueMap.keySet()) {
//             addTemplateValue(key, templateValueMap.get(key));
//         }
//     }
// 
//     public String getResult() {
//         return template.replaceAll("\\$\\{\\w+\\}", "").replaceAll("[ ]+\n", "");
//     }
// 
//     private String getKeyWrapper(String key) {
//         return "${" + key + "}";
//     }
// }
// 
// Path: src/main/java/com/morcinek/android/codegenerator/codegeneration/templates/TemplatesProvider.java
// public interface TemplatesProvider {
// 
//     String provideTemplateForName(String templateName);
// }


// Path: src/main/java/com/morcinek/android/codegenerator/codegeneration/builders/resources/FieldsBuilder.java
import com.morcinek.android.codegenerator.codegeneration.providers.ResourceProvider;
import com.morcinek.android.codegenerator.codegeneration.templates.TemplateManager;
import com.morcinek.android.codegenerator.codegeneration.templates.TemplatesProvider;
import java.util.List;

package com.morcinek.android.codegenerator.codegeneration.builders.resources;



/**
 * Copyright 2014 Tomasz Morcinek. All rights reserved.
 */
public class FieldsBuilder extends ResourceCodeBuilder {

    private StringBuilder stringBuilder;

    public FieldsBuilder(List<ResourceProvider> resourceProviders, TemplatesProvider templatesProvider) {
        super(resourceProviders, templatesProvider);
    }

    @Override
    protected void initializeFields() {
        stringBuilder = new StringBuilder();
    }

    @Override
    protected void processResourceProvider(ResourceProvider resourceProvider) {
        if (resourceProvider.provideField() != null) {
            for (String field : resourceProvider.provideField()) {
                TemplateManager templateManager = getTemplateManager(field);
                templateManager.addTemplateValues(resourceProvider.provideValues());
                stringBuilder.append(templateManager.getResult());
            }
        }
    }

    private TemplateManager getTemplateManager(String assignment) {
        return new TemplateManager(templatesProvider.provideTemplateForName("Field_"+ assignment +"_template"));