package org.finra.datagenerator.distributor;

import com.google.gson.Gson;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.log4j.Logger;
import org.finra.datagenerator.scxml.PossibleState;

/**
 * Created by robbinbr on 3/14/14.
 */
public class SearchProblem {

    protected static final Logger log = Logger.getLogger(SearchProblem.class);
    private static final Gson gson = new Gson();

    private PossibleState initialState;
    private Set<String> varsOut;
    private Map<String, String> initialVariablesMap;
    private List<String> initialEventsList;
    private int totalNumberOfProblems;
    private int thisProblemIndex;

    public static SearchProblem fromJson(String json) {
        return gson.fromJson(json, SearchProblem.class);
    }

    public SearchProblem(PossibleState initialState, Set<String> varsOut,
            Map<String, String> initialVariablesMap, List<String> initialEventsList,
            int totalNumberOfProblems, int thisProblemIndex) {
        this.initialState = initialState;
        this.varsOut = varsOut;
        this.initialVariablesMap = initialVariablesMap;
        this.initialEventsList = initialEventsList;
        this.totalNumberOfProblems = totalNumberOfProblems;
        this.thisProblemIndex = thisProblemIndex;
    }

    public int getTotalNumberOfProblems() {
        return totalNumberOfProblems;
    }

    public int getThisProblemIndex() {
        return thisProblemIndex;
    }

    public PossibleState getInitialState() {
        return initialState;
    }

    public Set<String> getVarsOut() {
        return varsOut;
    }

    public Map<String, String> getInitialVariablesMap() {
        return initialVariablesMap;
    }

    public List<String> getInitialEventsList() {
        return initialEventsList;
    }

    public String toJson() {
        return gson.toJson(this);
    }
}

@@ -1,8 +1,619 @@
+/*%0A * Copyright 2014 DataGenerator Contributors%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *      http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A
 package 
@@ -904,16 +904,46 @@
 blem %7B%0A%0A
+    /**%0A     * Logger%0A     */%0A
     prot
@@ -1008,24 +1008,82 @@
 blem.class);
+%0A%0A    /**%0A     * Used for json encoding & decoding%0A     */
 %0A    private
@@ -1101,20 +1101,20 @@
 al Gson 
-gson
+GSON
  = new G
@@ -1133,16 +1133,22 @@
 private 
+final 
 Possible
@@ -1179,16 +1179,22 @@
 private 
+final 
 Set%3CStri
@@ -1218,16 +1218,22 @@
 private 
+final 
 Map%3CStri
@@ -1277,16 +1277,22 @@
 private 
+final 
 List%3CStr
@@ -1323,24 +1323,30 @@
     private 
+final 
 int totalNum
@@ -1372,16 +1372,22 @@
 private 
+final 
 int this
@@ -1401,16 +1401,195 @@
 Index;%0A%0A
+    /**%0A     * Decodes a json string and returns a SearchProblem%0A     *%0A     * @param json a String containing a json encoded SearchProblem%0A     * @return a SearchProblem%0A     */%0A
     publ
@@ -1651,20 +1651,20 @@
  return 
-gson
+GSON
 .fromJso
@@ -1692,32 +1692,653 @@
 .class);%0A    %7D%0A%0A
+    /**%0A     * Constructor%0A     *%0A     * @param initialState a PossibleState representing the initial state of the search%0A     * @param varsOut a set of strings containing the names of the output variables%0A     * @param initialVariablesMap a map containing the initial values of variables%0A     * @param initialEventsList a list of events to be fired upon initialization of the state machine%0A     * @param totalNumberOfProblems if this search problem was the result of a BFS search, this variable should contain%0A     * the total number of problems found%0A     * @param thisProblemIndex a zero index of this problem%0A     */%0A
     public Searc
@@ -2346,16 +2346,22 @@
 Problem(
+final 
 Possible
@@ -2379,16 +2379,22 @@
 alState,
+ final
  Set%3CStr
@@ -2419,16 +2419,22 @@
         
+final 
 Map%3CStri
@@ -2465,16 +2465,22 @@
 blesMap,
+ final
  List%3CSt
@@ -2516,16 +2516,22 @@
         
+final 
 int tota
@@ -2548,16 +2548,22 @@
 roblems,
+ final
  int thi
@@ -3379,32 +3379,151 @@
 ntsList;%0A    %7D%0A%0A
+    /**%0A     * Searializes this class into json%0A     *%0A     * @return a String containing the serialized class%0A     */%0A
     public Strin
@@ -3550,20 +3550,20 @@
  return 
-gson
+GSON
 .toJson(

Add header. Apply checkstyle formatting