<commit_before>/* Copyright (c) 2000-2003, jMock.org. See LICENSE.txt */
package org.jmock.constraint;

import org.jmock.Constraint;
import org.jmock.dynamic.framework.DynamicUtil;

import java.util.Arrays;

/**
 * Is the value equal to another value, as tested by the
 * {@link java.lang.Object#equals} method?
 */
public class IsEqual implements Constraint {
    private Object _object;

    public IsEqual(Object equalArg) {
        if (equalArg instanceof Object[]) {
            _object = Arrays.asList((Object[]) equalArg);
        } else {
            _object = equalArg;
        }
    }

    public boolean eval(Object arg) {
        if (arg instanceof Object[]) {
            arg = Arrays.asList((Object[]) arg);
        }
        if (arg == null) {
            return arg == _object;
        }
        return arg.equals(_object);
    }

    public String toString() {
        return " = " + DynamicUtil.toReadableString(_object);
    }

    public boolean equals(Object anObject) {
        return eval(anObject);
    }
}<commit_msg>little bit of duplication removal<commit_after>/* Copyright (c) 2000-2003, jMock.org. See LICENSE.txt */
package org.jmock.constraint;

import org.jmock.Constraint;
import org.jmock.dynamic.framework.DynamicUtil;

import java.util.Arrays;

/**
 * Is the value equal to another value, as tested by the
 * {@link java.lang.Object#equals} method?
 */
public class IsEqual implements Constraint {
    private Object _object;

    public IsEqual(Object equalArg) {
        _object = convertArrayToList(equalArg);
    }

    public boolean eval(Object arg) {
        arg = convertArrayToList(arg);
        if (arg == null) {
            return arg == _object;
        }
        return arg.equals(_object);
    }

    public String toString() {
        return " = " + DynamicUtil.toReadableString(_object);
    }

    public boolean equals(Object anObject) {
        return eval(anObject);
    }

    private Object convertArrayToList(Object equalArg) {
        if (equalArg instanceof Object[]) {
            return Arrays.asList((Object[]) equalArg);
        } else {
            return equalArg;
        }
    }

    
}
{'fraction_non_alphanumeric': 0.10894761242466389, 'fraction_numerical': 0.007417709782104775, 'mean_word_length': 2.4528, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6432315', 'n_tokens_mistral': 632, 'n_tokens_neox': 606, 'n_words': 165}