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 UnstandardBean {
28     private boolean bool = true;
29     private int id;
30     private int integer = 42;
31     private String string = "json";
32  
33     public UnstandardBean( int id ) {
34        this.id = id;
35     }
36  
37     public boolean equals( Object obj ) {
38        if( obj == this ){
39           return true;
40        }
41        if( obj == null ){
42           return false;
43        }
44        if( !UnstandardBean.class.isAssignableFrom( obj.getClass() ) ){
45           return false;
46        }
47        return EqualsBuilder.reflectionEquals( this, obj );
48     }
49  
50     public int getId() {
51        return id;
52     }
53  
54     public int getInteger() {
55        return integer;
56     }
57  
58     public String getString() {
59        return string;
60     }
61  
62     public int hashCode() {
63        return HashCodeBuilder.reflectionHashCode( this );
64     }
65  
66     public boolean isBool() {
67        return bool;
68     }
69  
70     public void setBool( boolean bool ) {
71        this.bool = bool;
72     }
73  
74     public void setInteger( int integer ) {
75        this.integer = integer;
76     }
77  
78     public void setString( String string ) {
79        this.string = string;
80     }
81  
82     public String toString() {
83        return ToStringBuilder.reflectionToString( this, ToStringStyle.MULTI_LINE_STYLE );
84     }
85  }