<commit_before>package org.kaaproject.kaa.client.notification;

import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.List;

import org.kaaproject.kaa.common.endpoint.gen.Topic;

public class TopicListHashCalculator {
    public static final Integer NULL_LIST_HASH = 0;
    public static final Integer EMPTRY_LIST_HASH = 1;

    public static Integer calculateTopicListHash(List<Topic> topics) {
        if (topics == null)
            return NULL_LIST_HASH;

        int result = EMPTRY_LIST_HASH;
        if (!topics.isEmpty()) {
            List<Topic> newTopics = new LinkedList<>(topics);
            Collections.sort(newTopics, new Comparator<Topic>() {
                @Override
                public int compare(Topic o1, Topic o2) {
                    return o1.getId() < o2.getId() ? -1 : (o1.getId() < o2.getId() ) ? 1 : 0;
                }
            });

            for (Topic topic : newTopics) {<commit_msg>KAA-823: Fix topic list hash calculation algorithm.<commit_after>package org.kaaproject.kaa.client.notification;

import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.List;

import org.kaaproject.kaa.common.endpoint.gen.Topic;

public class TopicListHashCalculator {
    public static final Integer NULL_LIST_HASH = 0;
    public static final Integer EMPTRY_LIST_HASH = 1;

    public static Integer calculateTopicListHash(List<Topic> topics) {
        if (topics == null)
            return NULL_LIST_HASH;

        int result = EMPTRY_LIST_HASH;
        if (!topics.isEmpty()) {
            List<Topic> newTopics = new LinkedList<>(topics);
            Collections.sort(newTopics, new Comparator<Topic>() {
                @Override
                public int compare(Topic o1, Topic o2) {
                    return o1.getId() < o2.getId() ? -1 : (o1.getId() > o2.getId() ) ? 1 : 0;
                }
            });

            for (Topic topic : newTopics) {
{'fraction_non_alphanumeric': 0.10381143430290872, 'fraction_numerical': 0.012537612838515547, 'mean_word_length': 2.4695652173913043, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 12, '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': '2568165', 'n_tokens_mistral': 615, 'n_tokens_neox': 601, 'n_words': 142}