001/* $Id: Book.java 1102402 2011-05-12 18:03:26Z simonetripodi $ 002 * 003 * Licensed to the Apache Software Foundation (ASF) under one or more 004 * contributor license agreements. See the NOTICE file distributed with 005 * this work for additional information regarding copyright ownership. 006 * The ASF licenses this file to You under the Apache License, Version 2.0 007 * (the "License"); you may not use this file except in compliance with 008 * the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018package org.apache.commons.digester3.annotations.catalog; 019 020import org.apache.commons.digester3.annotations.rules.BeanPropertySetter; 021import org.apache.commons.digester3.annotations.rules.FactoryCreate; 022 023/** 024 * @since 2.1 025 */ 026@FactoryCreate( pattern = "catalog/book", factoryClass = BookFactory.class ) 027public final class Book 028 implements Item 029{ 030 031 private final String isbn; 032 033 @BeanPropertySetter( pattern = "catalog/book/title" ) 034 private String title; 035 036 @BeanPropertySetter( pattern = "catalog/book/author" ) 037 private String author; 038 039 @BeanPropertySetter( pattern = "catalog/book/desc" ) 040 private String desc; 041 042 public Book( String isbn ) 043 { 044 this.isbn = isbn; 045 } 046 047 public String getTitle() 048 { 049 return this.title; 050 } 051 052 public void setTitle( String title ) 053 { 054 this.title = title; 055 } 056 057 public String getAuthor() 058 { 059 return this.author; 060 } 061 062 public void setAuthor( String author ) 063 { 064 this.author = author; 065 } 066 067 public String getDesc() 068 { 069 return this.desc; 070 } 071 072 public void setDesc( String desc ) 073 { 074 this.desc = desc; 075 } 076 077 public String getIsbn() 078 { 079 return this.isbn; 080 } 081 082 @Override 083 public boolean equals( Object obj ) 084 { 085 if ( this == obj ) 086 return true; 087 if ( obj == null ) 088 return false; 089 if ( getClass() != obj.getClass() ) 090 return false; 091 Book other = (Book) obj; 092 if ( this.author == null ) 093 { 094 if ( other.getAuthor() != null ) 095 return false; 096 } 097 else if ( !this.author.equals( other.getAuthor() ) ) 098 return false; 099 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}