<commit_before>package org.infobip.mobile.messaging.mobile.messages;

import org.infobip.mobile.messaging.Message;
import org.infobip.mobile.messaging.api.messages.MessageResponse;
import org.infobip.mobile.messaging.api.messages.SyncMessagesResponse;
import org.infobip.mobile.messaging.api.support.http.serialization.JsonSerializer;
import org.infobip.mobile.messaging.geo.Geo;
import org.infobip.mobile.messaging.mobile.UnsuccessfulResult;
import org.json.JSONException;
import org.json.JSONObject;

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

/**
 * @author pandric
 * @since 09/09/16.
 */
class SyncMessagesResult extends UnsuccessfulResult {

    private List<Message> messages;

    SyncMessagesResult(Throwable exception) {
        super(exception);
    }

    SyncMessagesResult(SyncMessagesResponse syncMessagesResponse) {
        super(null);

        if (syncMessagesResponse == null) {
            return;
        }

        List<MessageResponse> payloads = syncMessagesResponse.getPayloads();
        mapResponseToMessage(payloads);
    }

    @Override
    public boolean hasError() {
        return true;
    }

    private void mapResponseToMessage(List<MessageResponse> payloads) {
        if (payloads == null) return;

        this.messages = new ArrayList<>(payloads.size());
        for (MessageResponse messageResponse : payloads) {
            if (messageResponse == null) {
                continue;
            }

            Message message = responseToMessage(messageResponse);
            this.messages.add(message);
        }
    }

    public List<Message> getMessages() {
        return messages;
    }

    private static Message responseToMessage(MessageResponse response) {
        JSONObject internalData = null;
        try {
            internalData = response.getInternalData() != null ? new JSONObject(response.getInternalData()) : null;
        } catch (JSONException e) {
            e.printStackTrace();
        }
        JSONObject customPayload = null;
        try {
            customPayload = response.getCustomPayload() != null ? new JSONObject(response.getCustomPayload()) : null;
        } catch (JSONException e) {<commit_msg>quickfix - SyncMessagesResult#hasError() default value removed<commit_after>package org.infobip.mobile.messaging.mobile.messages;

import org.infobip.mobile.messaging.Message;
import org.infobip.mobile.messaging.api.messages.MessageResponse;
import org.infobip.mobile.messaging.api.messages.SyncMessagesResponse;
import org.infobip.mobile.messaging.api.support.http.serialization.JsonSerializer;
import org.infobip.mobile.messaging.geo.Geo;
import org.infobip.mobile.messaging.mobile.UnsuccessfulResult;
import org.json.JSONException;
import org.json.JSONObject;

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

/**
 * @author pandric
 * @since 09/09/16.
 */
class SyncMessagesResult extends UnsuccessfulResult {

    private List<Message> messages;

    SyncMessagesResult(Throwable exception) {
        super(exception);
    }

    SyncMessagesResult(SyncMessagesResponse syncMessagesResponse) {
        super(null);

        if (syncMessagesResponse == null) {
            return;
        }

        List<MessageResponse> payloads = syncMessagesResponse.getPayloads();
        mapResponseToMessage(payloads);
    }

    private void mapResponseToMessage(List<MessageResponse> payloads) {
        if (payloads == null) return;

        this.messages = new ArrayList<>(payloads.size());
        for (MessageResponse messageResponse : payloads) {
            if (messageResponse == null) {
                continue;
            }

            Message message = responseToMessage(messageResponse);
            this.messages.add(message);
        }
    }

    public List<Message> getMessages() {
        return messages;
    }

    private static Message responseToMessage(MessageResponse response) {
        JSONObject internalData = null;
        try {
            internalData = response.getInternalData() != null ? new JSONObject(response.getInternalData()) : null;
        } catch (JSONException e) {
            e.printStackTrace();
        }
        JSONObject customPayload = null;
        try {
            customPayload = response.getCustomPayload() != null ? new JSONObject(response.getCustomPayload()) : null;
        } catch (JSONException e) {
{'fraction_non_alphanumeric': 0.09758342922899885, 'fraction_numerical': 0.002761795166858458, 'mean_word_length': 3.0092250922509227, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1701153', 'n_tokens_mistral': 1185, 'n_tokens_neox': 1143, 'n_words': 224}