<commit_before>package pl.allegro.jdd;

import static com.google.common.base.Preconditions.checkNotNull;

public class StructureDiff {
    public Changes calculate(Employee oldCTO, Employee newCTO){
        checkNotNull(oldCTO);
        checkNotNull(newCTO);

        // your code goes here
        throw new UnsupportedOperationException("Please implement me");
    }
}<commit_msg>My solution<commit_after>package pl.allegro.jdd;

import com.google.common.collect.MapDifference;
import com.google.common.collect.TreeTraverser;

import java.util.Map;

import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.Maps.difference;

public class StructureDiff extends TreeTraverser<Employee> {
    public Changes calculate(Employee oldCTO, Employee newCTO) {
        checkNotNull(oldCTO);
        checkNotNull(newCTO);
        MapDifference<Employee, Integer> diff = difference(getSalariesMap(oldCTO), getSalariesMap(newCTO));

        return new Changes(
                diff.entriesOnlyOnLeft().keySet(),
                diff.entriesOnlyOnRight().keySet(),
                diff.entriesDiffering().keySet()
        );
    }

    private Map<Employee, Integer> getSalariesMap(Employee boss) {
        return preOrderTraversal(boss).toMap(Employee::getSalary);
    }

    /*
    Note: if guava's TreeTraverser was a functional interface with default methods
    rather than an abstract class, it would be possible to construct it in a more
    simple way, asigning from a method reference that gets children of a node:

    TreeTraverser<Employee> traverser = Employee::getSubordinates;
     */
    @Override
    public Iterable<Employee> children(Employee node) {
        return node.getSubordinates();
    }
}
{'fraction_non_alphanumeric': 0.08789954337899543, 'fraction_numerical': 0.0, 'mean_word_length': 3.553246753246753, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, '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': '4145529', 'n_tokens_mistral': 507, 'n_tokens_neox': 476, 'n_words': 120}