Code view:

A painting is a person's account of this edit as text, recorded independently of the node mapping - a rendering often has several equally defensible answers where the mapping has one. Deletions and insertions carry no position on the opposite side in a painting, so that panel draws no caret for them.

Before

…lines 1–12 unchanged (12 lines)
13 * @param field
14 * @return
15 */
16 public Class getGenericType(Field field) {
17 Type generic = field.getGenericType();
18 if (generic != null && generic instanceof ParameterizedType) {
19 Type actual = ((ParameterizedType) generic).getActualTypeArguments()[0];
20 return (Class) actual;
21 //in case of nested generics we don't go deep
22 }
23
24 return Object.class;
25 }
26}
27

After

…lines 1–13 unchanged (13 lines)
14 * @return
15 */
16 public Class getGenericType(Field field) {
17 Type generic = field.getGenericType();
18 if (generic != null && generic instanceof ParameterizedType) {
19 Type actual = ((ParameterizedType) generic).getActualTypeArguments()[0];
20 if (actual instanceof Class) {
21 return (Class) actual;
22 } else if (actual instanceof ParameterizedType) {
23 //in case of nested generics we don't go deep
24 return (Class) ((ParameterizedType) actual).getRawType();
25 }
26 }
27
28 return Object.class;
29 }
30}
31

Before

program
package_declaration
package "package"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "mockito"
. "."
identifier "internal"
. "."
identifier "util"
. "."
identifier "reflection"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "lang"
. "."
identifier "reflect"
. "."
identifier "Field"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "lang"
. "."
identifier "reflect"
. "."
identifier "ParameterizedType"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "lang"
. "."
identifier "reflect"
. "."
identifier "Type"
; ";"
class_declaration
modifiers
annotation
@ "@"
identifier "SuppressWarnings"
annotation_argument_list
( "("
string_literal
" "\""
string_fragment "unchecked"
" "\""
) ")"
public "public"
class "class"
identifier "GenericMaster"
class_body
{ "{"
block_comment "/**\r\n * Finds the generic type (parametrized type) of th"...
method_declaration
modifiers
public "public"
type_identifier "Class"
identifier "getGenericType"
formal_parameters
( "("
formal_parameter
type_identifier "Field"
identifier "field"
) ")"
block
{ "{"
local_variable_declaration
type_identifier "Type"
variable_declarator
identifier "generic"
= "="
method_invocation
identifier "field"
. "."
identifier "getGenericType"
argument_list
( "("
) ")"
; ";"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
binary_expression
identifier "generic"
!= "!="
null_literal "null"
&& "&&"
instanceof_expression
identifier "generic"
instanceof "instanceof"
type_identifier "ParameterizedType"
) ")"
block
{ "{"
local_variable_declaration (+24 nodes collapsed)
return_statement
return "return"
cast_expression
( "("
type_identifier "Class"
) ")"
identifier "actual"
; ";"
line_comment "//in case of nested generics we don't go deep\r"
} "}"
return_statement
return "return"
class_literal
type_identifier "Object"
. "."
class "class"
; ";"
} "}"
} "}"

After

program
package_declaration
package "package"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "mockito"
. "."
identifier "internal"
. "."
identifier "util"
. "."
identifier "reflection"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "lang"
. "."
identifier "reflect"
. "."
identifier "Field"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "lang"
. "."
identifier "reflect"
. "."
identifier "ParameterizedType"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "lang"
. "."
identifier "reflect"
. "."
identifier "Type"
; ";"
class_declaration
modifiers
annotation
@ "@"
identifier "SuppressWarnings"
annotation_argument_list
( "("
string_literal
" "\""
string_fragment "unchecked"
" "\""
) ")"
public "public"
class "class"
identifier "GenericMaster"
class_body
{ "{"
block_comment "/**\r\n * Finds the generic type (parametrized type) of th"...
method_declaration
modifiers
public "public"
type_identifier "Class"
identifier "getGenericType"
formal_parameters
( "("
formal_parameter
type_identifier "Field"
identifier "field"
) ")"
block
{ "{"
local_variable_declaration
type_identifier "Type"
variable_declarator
identifier "generic"
= "="
method_invocation
identifier "field"
. "."
identifier "getGenericType"
argument_list
( "("
) ")"
; ";"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
binary_expression
identifier "generic"
!= "!="
null_literal "null"
&& "&&"
instanceof_expression
identifier "generic"
instanceof "instanceof"
type_identifier "ParameterizedType"
) ")"
block
{ "{"
local_variable_declaration (+24 nodes collapsed)
if_statement
if "if"
parenthesized_expression
( "("
instanceof_expression
identifier "actual"
instanceof "instanceof"
type_identifier "Class"
) ")"
block
{ "{"
return_statement
return "return"
cast_expression
( "("
type_identifier "Class"
) ")"
identifier "actual"
; ";"
} "}"
else "else"
if_statement
if "if"
parenthesized_expression
( "("
instanceof_expression
identifier "actual"
instanceof "instanceof"
type_identifier "ParameterizedType"
) ")"
block
{ "{"
line_comment "//in case of nested generics we don't go deep\r"
return_statement
return "return"
cast_expression
( "("
type_identifier "Class"
) ")"
method_invocation
parenthesized_expression
( "("
cast_expression
( "("
type_identifier "ParameterizedType"
) ")"
identifier "actual"
) ")"
. "."
identifier "getRawType"
argument_list
( "("
) ")"
; ";"
} "}"
} "}"
return_statement
return "return"
class_literal
type_identifier "Object"
. "."
class "class"
; ";"
} "}"
} "}"