<commit_before>/**
 * Copyright (C) 2009 - 2010 by OpenGamma Inc.
 *
 * Please see distribution for license.
 */
package org.joda.beans.test;

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

import org.joda.beans.Bean;
import org.joda.beans.MetaProperty;

/**
 * Error class used when two beans fail to compare.
 */
class BeanComparisonError extends AssertionError {

    /** Serialization version. */
    private static final long serialVersionUID = 1L;

    /**
     * The expected bean.
     */
    private final Bean _expected;
    /**
     * The actual bean.
     */
    private final Bean _actual;

    /**
     * Creates a new error.
     * 
     * @param message  the message, may be null
     * @param expected  the expected value, not null
     * @param actual  the actual value, not null
     */
    public BeanComparisonError(final String message, final Bean expected, final Bean actual) {
        super(buildMessage(message, expected, actual));
        _expected = expected;
        _actual = actual;
    }

    /**
     * Compares the two beans.
     * 
     * @param message  the message, may be null
     * @param expected  the expected value, not null
     * @param actual  the actual value, not null
     * @return the message, not null
     */
    private static String buildMessage(final String message, final Bean expected, final Bean actual) {
        List<String> diffs = new ArrayList<String>();
        buildMessage(diffs, "", expected, actual);
        StringBuilder buf = new StringBuilder();
        buf.append(message != null ? message + ": " : "");
        buf.append("Bean did not equal expected. Differences:");
        for (String diff : diffs) {
            buf.append('\n').append(diff);
        }
        return buf.toString();
    }

    private static void buildMessage(final List<String> diffs, final String prefix, final Object expected, final Object actual) {
        if (expected == null && actual == null) {
            return;
        }
        if (expected == null && actual != null) {
            diffs.add(prefix + ": Expected null, but was " + buildSummary(actual, true));<commit_msg>Limit comparison messages to 10<commit_after>/**
 * Copyright (C) 2009 - 2010 by OpenGamma Inc.
 *
 * Please see distribution for license.
 */
package org.joda.beans.test;

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

import org.joda.beans.Bean;
import org.joda.beans.MetaProperty;

/**
 * Error class used when two beans fail to compare.
 */
class BeanComparisonError extends AssertionError {

    /** Serialization version. */
    private static final long serialVersionUID = 1L;

    /**
     * The expected bean.
     */
    private final Bean _expected;
    /**
     * The actual bean.
     */
    private final Bean _actual;

    /**
     * Creates a new error.
     * 
     * @param message  the message, may be null
     * @param expected  the expected value, not null
     * @param actual  the actual value, not null
     */
    public BeanComparisonError(final String message, final Bean expected, final Bean actual) {
        super(buildMessage(message, expected, actual));
        _expected = expected;
        _actual = actual;
    }

    /**
     * Compares the two beans.
     * 
     * @param message  the message, may be null
     * @param expected  the expected value, not null
     * @param actual  the actual value, not null
     * @return the message, not null
     */
    private static String buildMessage(final String message, final Bean expected, final Bean actual) {
        List<String> diffs = new ArrayList<String>();
        buildMessage(diffs, "", expected, actual);
        StringBuilder buf = new StringBuilder();
        buf.append(message != null ? message + ": " : "");
        buf.append("Bean did not equal expected. Differences:");
        int size = diffs.size();
        if (size > 10) {
            diffs = diffs.subList(0, 10);
        }
        for (String diff : diffs) {
            buf.append('\n').append(diff);
        }
        if (size > 10) {
            buf.append("\n...and " + (size - 10) + " more differences");
        }
        return buf.toString();
    }

    private static void buildMessage(final List<String> diffs, final String prefix, final Object expected, final Object actual) {
        if (expected == null && actual == null) {
            return;
        }
        if (expected == null && actual != null) {
            diffs.add(prefix + ": Expected null, but was " + buildSummary(actual, true));
{'fraction_non_alphanumeric': 0.10984182776801406, 'fraction_numerical': 0.0063708260105448155, 'mean_word_length': 2.370096225018505, 'pattern_counts': {'":': 4, '<': 9, '<?xml version=': 0, '>': 11, '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': '3137254', 'n_tokens_mistral': 1273, 'n_tokens_neox': 1216, 'n_words': 428}