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–176 unchanged (176 lines)
177 * @return -ve if this is less than the other object, +ve if greater than,
178 * <code>0</code> of equal
179 * @throws ClassCastException if other is not an <code>Enum</code>
180 * @throws NullPointerException if other is <code>null</code>
181 */
182 public int compareTo(Object other) {
183 return iValue - ((ValuedEnum) other).iValue;
184 }
185
186 /**
187 * <p>Use reflection to return an objects value.</p>
188 *
189 * @param other the object to determine the value for
190 * @return the value
191 */
192 // ignore - should never happen
193 // ignore - should never happen
194 // ignore - should never happen
195
196 /**
197 * <p>Human readable description of this <code>Enum</code> item.</p>
198 *
199 * @return String in the form <code>type[name=value]</code>, for example:
200 * <code>JavaVersion[Java 1.0=100]</code>. Note that the package name is
201 * stripped from the type name.
…lines 202–211 unchanged (10 lines)

After

…lines 1–176 unchanged (176 lines)
177 * @return -ve if this is less than the other object, +ve if greater than,
178 * <code>0</code> of equal
179 * @throws ClassCastException if other is not an <code>Enum</code>
180 * @throws NullPointerException if other is <code>null</code>
181 */
182 public int compareTo(Object other) {
183 if (other == this) {
184 return 0;
185 }
186 if (other.getClass() != this.getClass()) {
187 if (other.getClass().getName().equals(this.getClass().getName())) {
188 return iValue - getValueInOtherClassLoader(other);
189 }
190 throw new ClassCastException(
191 "Different enum class '" + ClassUtils.getShortClassName(other.getClass()) + "'");
192 }
193 return iValue - ((ValuedEnum) other).iValue;
194 }
195
196 /**
197 * <p>Use reflection to return an objects value.</p>
198 *
199 * @param other the object to determine the value for
200 * @return the value
201 */
202 private int getValueInOtherClassLoader(Object other) {
203 try {
204 Method mth = other.getClass().getMethod("getValue", null);
205 Integer value = (Integer) mth.invoke(other, null);
206 return value.intValue();
207 } catch (NoSuchMethodException e) {
208 // ignore - should never happen
209 } catch (IllegalAccessException e) {
210 // ignore - should never happen
211 } catch (InvocationTargetException e) {
212 // ignore - should never happen
213 }
214 throw new IllegalStateException("This should not happen");
215 }
216
217 /**
218 * <p>Human readable description of this <code>Enum</code> item.</p>
219 *
220 * @return String in the form <code>type[name=value]</code>, for example:
221 * <code>JavaVersion[Java 1.0=100]</code>. Note that the package name is
…lines 222–232 unchanged (11 lines)

Before

program
block_comment "/*\n * Copyright 2002-2006 The Apache Software Foundation.\n *"...
package_declaration
package "package"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "apache"
. "."
identifier "commons"
. "."
identifier "lang"
. "."
identifier "enums"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "lang"
. "."
identifier "reflect"
. "."
identifier "InvocationTargetException"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "lang"
. "."
identifier "reflect"
. "."
identifier "Method"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "Iterator"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "List"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "apache"
. "."
identifier "commons"
. "."
identifier "lang"
. "."
identifier "ClassUtils"
; ";"
block_comment "/**\n * <p>Abstract superclass for type-safe enums with integ"...
class_declaration
modifiers
public "public"
abstract "abstract"
class "class"
identifier "ValuedEnum"
superclass
extends "extends"
type_identifier "Enum"
class_body
{ "{"
block_comment "/**\n * Required for serialization support.\n * \n "...
field_declaration
modifiers
private "private"
static "static"
final "final"
integral_type
long "long"
variable_declarator
identifier "serialVersionUID"
= "="
unary_expression
- "-"
decimal_integer_literal "7129650521543789085L"
; ";"
block_comment "/**\n * The value contained in enum.\n */"
field_declaration
modifiers
private "private"
final "final"
integral_type
int "int"
variable_declarator
identifier "iValue"
; ";"
block_comment "/**\n * Constructor for enum item.\n *\n * @param n"...
constructor_declaration (+31 nodes collapsed)
block_comment "/**\n * <p>Gets an <code>Enum</code> object by class and "...
method_declaration (+130 nodes collapsed)
block_comment "/**\n * <p>Get value of enum item.</p>\n *\n * @ret"...
method_declaration
modifiers
public "public"
final "final"
integral_type
int "int"
identifier "getValue"
formal_parameters
( "("
) ")"
block
{ "{"
return_statement
return "return"
identifier "iValue"
; ";"
} "}"
block_comment "/**\n * <p>Tests for order.</p>\n *\n * <p>The defa"...
method_declaration
modifiers
public "public"
integral_type
int "int"
identifier "compareTo"
formal_parameters
( "("
formal_parameter
type_identifier "Object"
identifier "other"
) ")"
block
{ "{"
return_statement
return "return"
binary_expression
identifier "iValue"
- "-"
field_access
parenthesized_expression
( "("
cast_expression
( "("
type_identifier "ValuedEnum"
) ")"
identifier "other"
) ")"
. "."
identifier "iValue"
; ";"
} "}"
block_comment "/**\n * <p>Use reflection to return an objects value.</p>"...
line_comment "// ignore - should never happen"
line_comment "// ignore - should never happen"
line_comment "// ignore - should never happen"
block_comment "/**\n * <p>Human readable description of this <code>Enum<"...
method_declaration (+83 nodes collapsed)
} "}"

After

program
block_comment "/*\n * Copyright 2002-2006 The Apache Software Foundation.\n *"...
package_declaration
package "package"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "apache"
. "."
identifier "commons"
. "."
identifier "lang"
. "."
identifier "enums"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "lang"
. "."
identifier "reflect"
. "."
identifier "InvocationTargetException"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "lang"
. "."
identifier "reflect"
. "."
identifier "Method"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "Iterator"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "List"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "apache"
. "."
identifier "commons"
. "."
identifier "lang"
. "."
identifier "ClassUtils"
; ";"
block_comment "/**\n * <p>Abstract superclass for type-safe enums with integ"...
class_declaration
modifiers
public "public"
abstract "abstract"
class "class"
identifier "ValuedEnum"
superclass
extends "extends"
type_identifier "Enum"
class_body
{ "{"
block_comment "/**\n * Required for serialization support.\n * \n "...
field_declaration
modifiers
private "private"
static "static"
final "final"
integral_type
long "long"
variable_declarator
identifier "serialVersionUID"
= "="
unary_expression
- "-"
decimal_integer_literal "7129650521543789085L"
; ";"
block_comment "/**\n * The value contained in enum.\n */"
field_declaration
modifiers
private "private"
final "final"
integral_type
int "int"
variable_declarator
identifier "iValue"
; ";"
block_comment "/**\n * Constructor for enum item.\n *\n * @param n"...
constructor_declaration (+31 nodes collapsed)
block_comment "/**\n * <p>Gets an <code>Enum</code> object by class and "...
method_declaration (+130 nodes collapsed)
block_comment "/**\n * <p>Get value of enum item.</p>\n *\n * @ret"...
method_declaration
modifiers
public "public"
final "final"
integral_type
int "int"
identifier "getValue"
formal_parameters
( "("
) ")"
block
{ "{"
return_statement
return "return"
identifier "iValue"
; ";"
} "}"
block_comment "/**\n * <p>Tests for order.</p>\n *\n * <p>The defa"...
method_declaration
modifiers
public "public"
integral_type
int "int"
identifier "compareTo"
formal_parameters
( "("
formal_parameter
type_identifier "Object"
identifier "other"
) ")"
block
{ "{"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "other"
== "=="
this "this"
) ")"
block
{ "{"
return_statement
return "return"
decimal_integer_literal "0"
; ";"
} "}"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
method_invocation
identifier "other"
. "."
identifier "getClass"
argument_list
( "("
) ")"
!= "!="
method_invocation
this "this"
. "."
identifier "getClass"
argument_list
( "("
) ")"
) ")"
block
{ "{"
if_statement
if "if"
parenthesized_expression
( "("
method_invocation
method_invocation
method_invocation
identifier "other"
. "."
identifier "getClass"
argument_list
( "("
) ")"
. "."
identifier "getName"
argument_list
( "("
) ")"
. "."
identifier "equals"
argument_list
( "("
method_invocation
method_invocation
this "this"
. "."
identifier "getClass"
argument_list
( "("
) ")"
. "."
identifier "getName"
argument_list
( "("
) ")"
) ")"
) ")"
block
{ "{"
return_statement
return "return"
binary_expression
identifier "iValue"
- "-"
method_invocation
identifier "getValueInOtherClassLoader"
argument_list
( "("
identifier "other"
) ")"
; ";"
} "}"
throw_statement
throw "throw"
object_creation_expression
new "new"
type_identifier "ClassCastException"
argument_list
( "("
binary_expression
binary_expression
string_literal
" "\""
string_fragment "Different enum class '"
" "\""
+ "+"
method_invocation
identifier "ClassUtils"
. "."
identifier "getShortClassName"
argument_list
( "("
method_invocation
identifier "other"
. "."
identifier "getClass"
argument_list
( "("
) ")"
) ")"
+ "+"
string_literal
" "\""
string_fragment "'"
" "\""
) ")"
; ";"
} "}"
return_statement
return "return"
binary_expression
identifier "iValue"
- "-"
field_access
parenthesized_expression
( "("
cast_expression
( "("
type_identifier "ValuedEnum"
) ")"
identifier "other"
) ")"
. "."
identifier "iValue"
; ";"
} "}"
block_comment "/**\n * <p>Use reflection to return an objects value.</p>"...
method_declaration
modifiers
private "private"
integral_type
int "int"
identifier "getValueInOtherClassLoader"
formal_parameters
( "("
formal_parameter
type_identifier "Object"
identifier "other"
) ")"
block
{ "{"
try_statement
try "try"
block
{ "{"
local_variable_declaration
type_identifier "Method"
variable_declarator
identifier "mth"
= "="
method_invocation
method_invocation
identifier "other"
. "."
identifier "getClass"
argument_list
( "("
) ")"
. "."
identifier "getMethod"
argument_list
( "("
string_literal
" "\""
string_fragment "getValue"
" "\""
, ","
null_literal "null"
) ")"
; ";"
local_variable_declaration
type_identifier "Integer"
variable_declarator
identifier "value"
= "="
cast_expression
( "("
type_identifier "Integer"
) ")"
method_invocation
identifier "mth"
. "."
identifier "invoke"
argument_list
( "("
identifier "other"
, ","
null_literal "null"
) ")"
; ";"
return_statement
return "return"
method_invocation
identifier "value"
. "."
identifier "intValue"
argument_list
( "("
) ")"
; ";"
} "}"
catch_clause
catch "catch"
( "("
catch_formal_parameter
catch_type
type_identifier "NoSuchMethodException"
identifier "e"
) ")"
block
{ "{"
line_comment "// ignore - should never happen"
} "}"
catch_clause
catch "catch"
( "("
catch_formal_parameter
catch_type
type_identifier "IllegalAccessException"
identifier "e"
) ")"
block
{ "{"
line_comment "// ignore - should never happen"
} "}"
catch_clause
catch "catch"
( "("
catch_formal_parameter
catch_type
type_identifier "InvocationTargetException"
identifier "e"
) ")"
block
{ "{"
line_comment "// ignore - should never happen"
} "}"
throw_statement
throw "throw"
object_creation_expression
new "new"
type_identifier "IllegalStateException"
argument_list
( "("
string_literal
" "\""
string_fragment "This should not happen"
" "\""
) ")"
; ";"
} "}"
block_comment "/**\n * <p>Human readable description of this <code>Enum<"...
method_declaration (+83 nodes collapsed)
} "}"