private Map < StandardMethod , UnderrideLevel > findUnderriddenMethods ( Iterable < ExecutableElement > methods ) { Map < StandardMethod , ExecutableElement > standardMethods = new LinkedHashMap <> ( ) ; for ( ExecutableElement method : methods ) { Optional < StandardMethod > standardMethod = maybeStandardMethod ( method ) ; if ( standardMethod . isPresent ( ) && isUnderride ( method ) ) { standardMethods . put ( standardMethod . get ( ) , method ) ; } } if ( standardMethods . containsKey ( StandardMethod . EQUALS ) != standardMethods . containsKey ( StandardMethod . HASH_CODE ) ) { ExecutableElement underriddenMethod = standardMethods . containsKey ( StandardMethod . EQUALS ) ? standardMethods . get ( StandardMethod . EQUALS ) : standardMethods . get ( StandardMethod . HASH_CODE ) ; messager . printMessage ( ERROR , "hashCode and equals must be implemented together on FreeBuilder types" , underriddenMethod ) ; } ImmutableMap . Builder < StandardMethod , UnderrideLevel > result = ImmutableMap . builder ( ) ; for ( StandardMethod standardMethod : standardMethods . keySet ( ) ) { if ( standardMethods . get ( standardMethod ) . getModifiers ( ) . contains ( Modifier . FINAL ) ) { result . put ( standardMethod , UnderrideLevel . FINAL ) ; } else { result . put ( standardMethod , UnderrideLevel . OVERRIDEABLE ) ; } } return result . build ( ) ; }
Find any standard methods the user has underridden in their type .