// Path: core/src/main/java/io/appflate/restmock/utils/RequestMatcher.java
// public abstract class RequestMatcher extends TypeSafeMatcher<RecordedRequest> {
// 
//     private final String description;
// 
//     public RequestMatcher(String description) {
//         this.description = description;
//     }
// 
//     @Override
//     public void describeTo(Description description) {
//         description.appendText(this.description);
//     }
// }
// 
// Path: core/src/main/java/io/appflate/restmock/utils/RestMockUtils.java
// public final class RestMockUtils {
// 
//     public static MockResponse createResponseFromFile(RESTMockFileParser RESTMockFileParser, String jsonFilePath,
//                                                       int responseCode) throws Exception {
//         String fileContents = RESTMockFileParser.readJsonFile(jsonFilePath);
//         return new MockResponse().setResponseCode(responseCode).setBody(fileContents);
//     }
// 
//     /**
//      * Extract query parameters from a {@link URL}.
//      *
//      * @param url The {@link URL} to retrieve query parameters for.
//      * @return A {@link List} of {@link QueryParam} objects. Each parameter has one key, and zero or
//      * more values.
//      * @throws UnsupportedEncodingException If unable to decode from UTF-8. This should never happen.
//      */
//     public static List<QueryParam> splitQuery(URL url) throws UnsupportedEncodingException {
//         final Map<String, List<String>> queryPairs = new LinkedHashMap<>();
// 
//         String query = url.getQuery();
//         if (query == null || query.trim().length() == 0) {
//             return Collections.emptyList();
//         }
// 
//         final String[] pairs = query.split("&");
//         for (String pair : pairs) {
//             final int idx = pair.indexOf("=");
//             final String key = idx > 0 ? URLDecoder.decode(pair.substring(0, idx), "UTF-8") : pair;
//             List<String> valueList = new LinkedList<>();
// 
//             if (queryPairs.containsKey(key)) {
//                 valueList = queryPairs.get(key);
//             }
// 
//             final String value = idx > 0 && pair.length() > idx + 1 ? URLDecoder.decode(pair.substring(idx + 1), "UTF-8") : null;
//             valueList.add(value);
// 
//             queryPairs.put(key, valueList);
//         }
// 
//         List<QueryParam> finalParamList = new LinkedList<>();
//         for (Map.Entry<String, List<String>> entry : queryPairs.entrySet()) {
//             QueryParam nextFinalParam = new QueryParam(entry.getKey(), entry.getValue());
//             finalParamList.add(nextFinalParam);
//         }
// 
//         return finalParamList;
//     }
// 
//     private RestMockUtils() {
//         throw new UnsupportedOperationException("(╯‵Д′)╯ PLEASE STAHP!");
// 
//     }
// }


import org.hamcrest.Matcher;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import io.appflate.restmock.utils.RequestMatcher;
import io.appflate.restmock.utils.RestMockUtils;
import okhttp3.mockwebserver.MockResponse;
import okhttp3.mockwebserver.RecordedRequest;
     *
     * <p>If you specify more than one response, each consecutive call to server will return next response from the list, if number of
     * requests exceeds number of specified responses, the last response will be repeated</p>
     *
     * @param jsonFiles a comma-separated list of files' path to return. {@link RESTMockFileParser} is responsible of reading files for
     *                  given paths.
     * @return a {@link MatchableCall} that will return given {@code jsonFile} as a response.
     */
    public MatchableCall thenReturnFile(String... jsonFiles) {
        return thenReturnFile(200, jsonFiles);
    }

    /**
     * Makes this MatchableCall return the {@code jsonFile}'s contents with the {@code responseCode} as a http status code.
     *
     * <p>This {@code MatchableCall} will be automatically scheduled within the {@code RESTMockServer} if you want to prevent that, see
     * {@link MatchableCall#dontSet()}</p>
     *
     * <p>If you specify more than one response, each consecutive call to server will return next response from the list, if number of
     * requests exceeds number of specified responses, the last response will be repeated</p>
     *
     * @param responseCode http status code
     * @param jsonFiles    a comma-separated list of json files' paths that will be returned. {@link RESTMockFileParser} is responsible of
     *                     reading files for given paths.
     * @return this {@code MatchableCall}
     */
    public MatchableCall thenReturnFile(int responseCode, String... jsonFiles) {
        List<MockResponse> responseFromFiles = new ArrayList<>(jsonFiles.length);
        for (String jsonFile : jsonFiles) {
            try {
// Path: core/src/main/java/io/appflate/restmock/utils/RequestMatcher.java
// public abstract class RequestMatcher extends TypeSafeMatcher<RecordedRequest> {
// 
//     private final String description;
// 
//     public RequestMatcher(String description) {
//         this.description = description;
//     }
// 
//     @Override
//     public void describeTo(Description description) {
//         description.appendText(this.description);
//     }
// }
// 
// Path: core/src/main/java/io/appflate/restmock/utils/RestMockUtils.java
// public final class RestMockUtils {
// 
//     public static MockResponse createResponseFromFile(RESTMockFileParser RESTMockFileParser, String jsonFilePath,
//                                                       int responseCode) throws Exception {
//         String fileContents = RESTMockFileParser.readJsonFile(jsonFilePath);
//         return new MockResponse().setResponseCode(responseCode).setBody(fileContents);
//     }
// 
//     /**
//      * Extract query parameters from a {@link URL}.
//      *
//      * @param url The {@link URL} to retrieve query parameters for.
//      * @return A {@link List} of {@link QueryParam} objects. Each parameter has one key, and zero or
//      * more values.
//      * @throws UnsupportedEncodingException If unable to decode from UTF-8. This should never happen.
//      */
//     public static List<QueryParam> splitQuery(URL url) throws UnsupportedEncodingException {
//         final Map<String, List<String>> queryPairs = new LinkedHashMap<>();
// 
//         String query = url.getQuery();
//         if (query == null || query.trim().length() == 0) {
//             return Collections.emptyList();
//         }
// 
//         final String[] pairs = query.split("&");
//         for (String pair : pairs) {
//             final int idx = pair.indexOf("=");
//             final String key = idx > 0 ? URLDecoder.decode(pair.substring(0, idx), "UTF-8") : pair;
//             List<String> valueList = new LinkedList<>();
// 
//             if (queryPairs.containsKey(key)) {
//                 valueList = queryPairs.get(key);
//             }
// 
//             final String value = idx > 0 && pair.length() > idx + 1 ? URLDecoder.decode(pair.substring(idx + 1), "UTF-8") : null;
//             valueList.add(value);
// 
//             queryPairs.put(key, valueList);
//         }
// 
//         List<QueryParam> finalParamList = new LinkedList<>();
//         for (Map.Entry<String, List<String>> entry : queryPairs.entrySet()) {
//             QueryParam nextFinalParam = new QueryParam(entry.getKey(), entry.getValue());
//             finalParamList.add(nextFinalParam);
//         }
// 
//         return finalParamList;
//     }
// 
//     private RestMockUtils() {
//         throw new UnsupportedOperationException("(╯‵Д′)╯ PLEASE STAHP!");
// 
//     }
// }


// Path: core/src/main/java/io/appflate/restmock/MatchableCall.java
import org.hamcrest.Matcher;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import io.appflate.restmock.utils.RequestMatcher;
import io.appflate.restmock.utils.RestMockUtils;
import okhttp3.mockwebserver.MockResponse;
import okhttp3.mockwebserver.RecordedRequest;

     *
     * <p>If you specify more than one response, each consecutive call to server will return next response from the list, if number of
     * requests exceeds number of specified responses, the last response will be repeated</p>
     *
     * @param jsonFiles a comma-separated list of files' path to return. {@link RESTMockFileParser} is responsible of reading files for
     *                  given paths.
     * @return a {@link MatchableCall} that will return given {@code jsonFile} as a response.
     */
    public MatchableCall thenReturnFile(String... jsonFiles) {
        return thenReturnFile(200, jsonFiles);
    }

    /**
     * Makes this MatchableCall return the {@code jsonFile}'s contents with the {@code responseCode} as a http status code.
     *
     * <p>This {@code MatchableCall} will be automatically scheduled within the {@code RESTMockServer} if you want to prevent that, see
     * {@link MatchableCall#dontSet()}</p>
     *
     * <p>If you specify more than one response, each consecutive call to server will return next response from the list, if number of
     * requests exceeds number of specified responses, the last response will be repeated</p>
     *
     * @param responseCode http status code
     * @param jsonFiles    a comma-separated list of json files' paths that will be returned. {@link RESTMockFileParser} is responsible of
     *                     reading files for given paths.
     * @return this {@code MatchableCall}
     */
    public MatchableCall thenReturnFile(int responseCode, String... jsonFiles) {
        List<MockResponse> responseFromFiles = new ArrayList<>(jsonFiles.length);
        for (String jsonFile : jsonFiles) {
            try {
                responseFromFiles.add(RestMockUtils.createResponseFromFile(RESTMockFileParser, jsonFile, responseCode));