<commit_before>package io.pcp.parfait.dxm;

import org.hamcrest.BaseMatcher;
import org.hamcrest.Description;
import org.unitils.reflectionassert.ReflectionComparator;
import org.unitils.reflectionassert.ReflectionComparatorMode;
import org.unitils.reflectionassert.difference.Difference;
import org.unitils.reflectionassert.report.impl.DefaultDifferenceReport;

import static org.unitils.reflectionassert.ReflectionComparatorFactory.createRefectionComparator;

public class Matchers {

    static class ReflectiveMatcher extends BaseMatcher<Object> {

        private final Object expected;
        private Difference difference;

        private ReflectiveMatcher(Object expected) {
            this.expected = expected;
        }

        @Override
        public boolean matches(Object actual) {
            ReflectionComparator refectionComparator = createRefectionComparator(ReflectionComparatorMode.LENIENT_ORDER);
            difference = refectionComparator.getDifference(expected, actual);
            return refectionComparator.isEqual(expected, actual);
        }

        @Override
        public void describeTo(Description description) {
            if(difference != null) {
                description.appendText(new DefaultDifferenceReport().createReport(difference));
            }
        }

        static ReflectiveMatcher reflectivelyEqualing(Object expected) {
            return new ReflectiveMatcher(expected);
        }

    }<commit_msg>MMVv2: Prefer use of TypeSafeMatcher for the ReflectiveMatcher<commit_after>package io.pcp.parfait.dxm;

import org.hamcrest.Description;
import org.hamcrest.TypeSafeMatcher;
import org.unitils.reflectionassert.ReflectionComparator;
import org.unitils.reflectionassert.ReflectionComparatorMode;
import org.unitils.reflectionassert.difference.Difference;
import org.unitils.reflectionassert.report.impl.DefaultDifferenceReport;

import static org.unitils.reflectionassert.ReflectionComparatorFactory.createRefectionComparator;

public class Matchers {

    static class ReflectiveMatcher extends TypeSafeMatcher<Object> {

        private final Object expected;
        private Difference difference;

        private ReflectiveMatcher(Object expected) {
            this.expected = expected;
        }

        @Override
        protected boolean matchesSafely(Object actual) {
            ReflectionComparator refectionComparator = createRefectionComparator(ReflectionComparatorMode.LENIENT_ORDER);
            difference = refectionComparator.getDifference(expected, actual);
            return refectionComparator.isEqual(expected, actual);
        }

        @Override
        public void describeTo(Description description) {
            if(difference != null) {
                description.appendText(new DefaultDifferenceReport().createReport(difference));
            }
        }

        static ReflectiveMatcher reflectivelyEqualing(Object expected) {
            return new ReflectiveMatcher(expected);
        }

    }
{'fraction_non_alphanumeric': 0.06646626586506346, 'fraction_numerical': 0.00033400133600534405, 'mean_word_length': 3.496996996996997, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '929127', 'n_tokens_mistral': 725, 'n_tokens_neox': 719, 'n_words': 141}