package se.kits.gakusei.init;

import se.kits.gakusei.content.model.Fact;
import se.kits.gakusei.content.model.Nugget;

import java.util.ArrayList;
import java.util.List;

public class TestDataHolder {

    private String english;
    private String katakana;
    private String kunyomi;
    private String kanji;
    private String type;

    public TestDataHolder() {
    }

    public String getEnglish() {
        return english;
    }

    public void setEnglish(String english) {
        if (english.equalsIgnoreCase("null") || english == null) {
            this.english = null;
        } else {
            this.english = english;
        }
    }

    public String getKatakana() {
        return katakana;
    }

    public void setKatakana(String katakana) {
        if (katakana.equalsIgnoreCase("null") || katakana == null) {
            this.katakana = null;
        } else {
            this.katakana = katakana;
        }
    }

    public String getKunyomi() {
        return kunyomi;
    }

    public void setKunyomi(String kunyomi) {
        if (kunyomi.equalsIgnoreCase("null") || kunyomi == null) {
            this.kunyomi = null;
        } else {
            this.kunyomi = kunyomi;
        }
    }

    public String getKanji() {
        return kanji;
    }

    public void setKanji(String kanji) {
        if (kanji.equalsIgnoreCase("null") || kanji == null) {
            this.kanji = null;
        } else {
            this.kanji = kanji;
        }
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        if (type.equalsIgnoreCase("null") || type == null) {
            this.type = null;
        } else {
            this.type = type;
        }
    }

    public Nugget createNugget() {
        if (this.type == null) {
            return null;
        }
        Nugget nugget = new Nugget();
        nugget.setType(this.type);
        if(this.english != null) {
            nugget.setDescription(this.english);
        }
        return nugget;
    }

    public List<Fact> createFacts() {
        if (this.english == null && this.katakana == null && this.kunyomi == null && this.kanji == null) {
            return null;
        }
        List<Fact> facts = new ArrayList<>();
        if (this.english != null) {
            Fact fact = new Fact();
            fact.setType("english_translation");
            fact.setData(this.english);
            facts.add(fact);
        }
        if (this.katakana != null) {
            Fact fact = new Fact();
            fact.setType("writing");
            fact.setData(this.katakana);
            facts.add(fact);
        }
        if (this.kunyomi != null) {
            Fact fact = new Fact();
            fact.setType("reading");
            fact.setData(this.kunyomi);
            facts.add(fact);
        }
        if (this.kanji != null) {
            Fact fact = new Fact();
            fact.setType("kanji");
            fact.setData(this.kanji);
            facts.add(fact);
        }
        return facts;
    }

    @Override
    public String toString() {
        return "TestDataHolder{" +
                "english='" + english + '\'' +
                ", katakana='" + katakana + '\'' +
                ", kunyomi='" + kunyomi + '\'' +
                ", kanji='" + kanji + '\'' +
                ", type='" + type + '\'' +
                '}';
    }
}

@@ -491,1242 +491,729 @@
     
-if (engl
+th
 is
-h
 .e
-qualsIgnoreCase(%22null%22) %7C%7C english == null) %7B%0A            this.english = null;%0A        %7D else %7B%0A            this.english = english;%0A        %7D%0A    %7D%0A%0A    public String getKatakana() %7B%0A        return katakana;%0A    %7D%0A%0A    public void setKatakana(String katakana) %7B%0A        if (katakana.equalsIgnoreCase(%22null%22) %7C%7C katakana == null) %7B%0A            this.katakana = null;%0A        %7D else %7B%0A            this.katakana = katakana;%0A        %7D%0A    %7D%0A%0A    public String getKunyomi() %7B%0A        return kunyomi;%0A    %7D%0A%0A    public void setKunyomi(String kunyomi) %7B%0A        if (kunyomi.equalsIgnoreCase(%22null%22) %7C%7C kunyomi == null) %7B%0A            this.kunyomi = null;%0A        %7D else %7B%0A            this.kunyomi = kunyomi;%0A        %7D%0A    %7D%0A%0A    public String getKanji() %7B%0A        return kanji;%0A    %7D%0A%0A    public void setKanji(String kanji) %7B%0A        if (kanji.equalsIgnoreCase(%22null%22) %7C%7C kanji == null) %7B%0A            this.kanji = null;%0A        %7D else %7B%0A            this.kanji = kanji;%0A        %7D%0A    %7D%0A%0A    public String getType() %7B%0A        return type;%0A    %7D%0A%0A    public void setType(String type) %7B%0A        if (type.equalsIgnoreCase(%22null%22) %7C%7C type == null) %7B%0A            this.type = null;%0A        %7D else %7B%0A            this.type = type;%0A        %7D
+nglish = parseIfStringIsNullValue(english);%0A    %7D%0A%0A    public String getKatakana() %7B%0A        return katakana;%0A    %7D%0A%0A    public void setKatakana(String katakana) %7B%0A        this.katakana = parseIfStringIsNullValue(katakana);%0A    %7D%0A%0A    public String getKunyomi() %7B%0A        return kunyomi;%0A    %7D%0A%0A    public void setKunyomi(String kunyomi) %7B%0A        this.kunyomi = parseIfStringIsNullValue(kunyomi);%0A    %7D%0A%0A    public String getKanji() %7B%0A        return kanji;%0A    %7D%0A%0A    public void setKanji(String kanji) %7B%0A        this.kanji = parseIfStringIsNullValue(kanji);%0A    %7D%0A%0A    public String getType() %7B%0A        return type;%0A    %7D%0A%0A    public void setType(String type) %7B%0A        this.type = parseIfStringIsNullValue(type);
 %0A   
@@ -2527,24 +2527,252 @@
 cts;%0A    %7D%0A%0A
+    private String parseIfStringIsNullValue(String typeString) %7B%0A        if (typeString.equalsIgnoreCase(%22null%22) %7C%7C typeString == null) %7B%0A            return null;%0A        %7D else %7B%0A            return typeString;%0A        %7D%0A    %7D%0A%0A
     @Overrid

Add simplifying helper method in TestDataHolder