@Override
  public Description matchMethodInvocation(MethodInvocationTree t, VisitorState state) {
    String arg1;
    String arg2;
    if (instanceEqualsMatcher.matches(t, state)) {
      arg1 = state.getSourceForNode(((JCFieldAccess) t.getMethodSelect()).getExpression());
      arg2 = state.getSourceForNode(t.getArguments().get(0));
    } else if (staticEqualsMatcher.matches(t, state)) {
      arg1 = state.getSourceForNode(t.getArguments().get(0));
      arg2 = state.getSourceForNode(t.getArguments().get(1));
    } else {
      return NO_MATCH;
    }

    Fix fix =
        SuggestedFix.builder()
            .replace(t, "Arrays.equals(" + arg1 + ", " + arg2 + ")")
            .addImport("java.util.Arrays")
            .build();
    return describeMatch(t, fix);
  }
@ Override public Description matchMethodInvocation ( MethodInvocationTree t , VisitorState state ) { String arg1 ; String arg2 ; if ( instanceEqualsMatcher . matches ( t , state ) ) { arg1 = state . getSourceForNode ( ( ( JCFieldAccess ) t . getMethodSelect ( ) ) . getExpression ( ) ) ; arg2 = state . getSourceForNode ( t . getArguments ( ) . get ( 0 ) ) ; } else if ( staticEqualsMatcher . matches ( t , state ) ) { arg1 = state . getSourceForNode ( t . getArguments ( ) . get ( 0 ) ) ; arg2 = state . getSourceForNode ( t . getArguments ( ) . get ( 1 ) ) ; } else { return NO_MATCH ; } Fix fix = SuggestedFix . builder ( ) . replace ( t , "Arrays.equals(" + arg1 + ", " + arg2 + ")" ) . addImport ( "java.util.Arrays" ) . build ( ) ; return describeMatch ( t , fix ) ; }
Suggests replacing with Arrays.equals(a, b). Also adds the necessary import statement for
java.util.Arrays.