In records, the default behavior of the ``++equals()++`` method is to check the equality by field values. This works well for primitive fields or fields, whose type overrides ``++equals()++``, but this behavior doesn't work as expected for array fields.
By default, array fields are compared by their reference, and overriding ``++equals()++`` is highly appreciated to achieve the deep equality check. The same strategy applies to ``++hashcode()++`` and ``++toString()++`` methods.
This rule reports an issue if a record class has an array field and is not overriding ``++equals()++``, ``++hashcode()++`` or ``++toString()++`` methods.
== Noncompliant Code Example
----
record Person(String[] names, int age) {} // Noncompliant
----
== Compliant Solution
----
record Person(String[] names, int age) {
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Person person = (Person) o;
return age == person.age && Arrays.equals(names, person.names);