1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package net.sf.json.sample;
18
19 import org.apache.commons.lang.builder.EqualsBuilder;
20 import org.apache.commons.lang.builder.HashCodeBuilder;
21 import org.apache.commons.lang.builder.ToStringBuilder;
22 import org.apache.commons.lang.builder.ToStringStyle;
23
24
25
26
27 public class BeanA {
28 private boolean bool = true;
29 private int integer = 42;
30 private String string = "json";
31
32 public BeanA() {
33 super();
34 }
35
36 public BeanA( boolean bool, int integer, String string ) {
37 super();
38 this.bool = bool;
39 this.integer = integer;
40 this.string = string;
41 }
42
43 public boolean equals( Object obj ) {
44 if( obj == this ){
45 return true;
46 }
47 if( obj == null ){
48 return false;
49 }
50 if( !BeanA.class.isAssignableFrom( obj.getClass() ) ){
51 return false;
52 }
53 return EqualsBuilder.reflectionEquals( this, obj );
54 }
55
56 public int getInteger() {
57 return integer;
58 }
59
60 public String getString() {
61 return string;
62 }
63
64 public int hashCode() {
65 return HashCodeBuilder.reflectionHashCode( this );
66 }
67
68 public boolean isBool() {
69 return bool;
70 }
71
72 public void setBool( boolean bool ) {
73 this.bool = bool;
74 }
75
76 public void setInteger( int integer ) {
77 this.integer = integer;
78 }
79
80 public void setString( String string ) {
81 this.string = string;
82 }
83
84 public String toString() {
85 return ToStringBuilder.reflectionToString( this, ToStringStyle.MULTI_LINE_STYLE );
86 }
87 }