1   /*
2    * Copyright 2002-2009 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
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   * @author Andres Almiray <aalmiray@users.sourceforge.net>
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  }