1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.commons.digester3.annotations.catalog;
19
20 import org.apache.commons.digester3.annotations.rules.BeanPropertySetter;
21 import org.apache.commons.digester3.annotations.rules.FactoryCreate;
22
23
24
25
26 @FactoryCreate( pattern = "catalog/book", factoryClass = BookFactory.class )
27 public final class Book
28 implements Item
29 {
30
31 private final String isbn;
32
33 @BeanPropertySetter( pattern = "catalog/book/title" )
34 private String title;
35
36 @BeanPropertySetter( pattern = "catalog/book/author" )
37 private String author;
38
39 @BeanPropertySetter( pattern = "catalog/book/desc" )
40 private String desc;
41
42 public Book( String isbn )
43 {
44 this.isbn = isbn;
45 }
46
47 public String getTitle()
48 {
49 return this.title;
50 }
51
52 public void setTitle( String title )
53 {
54 this.title = title;
55 }
56
57 public String getAuthor()
58 {
59 return this.author;
60 }
61
62 public void setAuthor( String author )
63 {
64 this.author = author;
65 }
66
67 public String getDesc()
68 {
69 return this.desc;
70 }
71
72 public void setDesc( String desc )
73 {
74 this.desc = desc;
75 }
76
77 public String getIsbn()
78 {
79 return this.isbn;
80 }
81
82 @Override
83 public boolean equals( Object obj )
84 {
85 if ( this == obj )
86 return true;
87 if ( obj == null )
88 return false;
89 if ( getClass() != obj.getClass() )
90 return false;
91 Book other = (Book) obj;
92 if ( this.author == null )
93 {
94 if ( other.getAuthor() != null )
95 return false;
96 }
97 else if ( !this.author.equals( other.getAuthor() ) )
98 return false;
99 if ( this.desc == null )
100 {
101 if ( other.getDesc() != null )
102 return false;
103 }
104 else if ( !this.desc.equals( other.getDesc() ) )
105 return false;
106 if ( this.isbn == null )
107 {
108 if ( other.getIsbn() != null )
109 return false;
110 }
111 else if ( !this.isbn.equals( other.getIsbn() ) )
112 return false;
113 if ( this.title == null )
114 {
115 if ( other.getTitle() != null )
116 return false;
117 }
118 else if ( !this.title.equals( other.getTitle() ) )
119 return false;
120 return true;
121 }
122
123 @Override
124 public String toString()
125 {
126 return "Book [author=" + author + ", desc=" + desc + ", isbn=" + isbn + ", title=" + title + "]";
127 }
128
129 public void print()
130 {
131 System.out.println( this.toString() );
132 }
133
134 }