1 7 package org.jboss.test.xml.book; 8 9 import java.util.List ; 10 import java.util.ArrayList ; 11 12 18 public class Book 19 { 20 private String isbn; 21 private String title; 22 private String author; 23 private List characters = new ArrayList (); 24 25 public String getIsbn() 26 { 27 return isbn; 28 } 29 30 public void setIsbn(String isbn) 31 { 32 this.isbn = isbn; 33 } 34 35 public String getAuthor() 36 { 37 return author; 38 } 39 40 public void setAuthor(String author) 41 { 42 this.author = author; 43 } 44 45 public String getTitle() 46 { 47 return title; 48 } 49 50 public void setTitle(String title) 51 { 52 this.title = title; 53 } 54 55 public List getCharacters() 56 { 57 return characters; 58 } 59 60 public void setCharacters(List characters) 61 { 62 this.characters = characters; 63 } 64 65 public void addCharacter(BookCharacter character) 66 { 67 characters.add(character); 68 } 69 70 public int getCharactersTotal() 71 { 72 return characters.size(); 73 } 74 75 public String toString() 76 { 77 StringBuffer sb = new StringBuffer (100); 78 sb.append('[') 79 .append("isbn=").append(isbn) 80 .append(", title=").append(title) 81 .append(", author=").append(author) 82 .append(", characters=").append(characters) 83 .append(']'); 84 return sb.toString(); 85 } 86 87 public boolean equals(Object o) 88 { 89 if(this == o) return true; 90 if(!(o instanceof Book)) return false; 91 92 final Book book = (Book)o; 93 94 if(author != null ? !author.equals(book.author) : book.author != null) return false; 95 if(characters != null ? !characters.equals(book.characters) : book.characters != null) return false; 96 if(isbn != null ? !isbn.equals(book.isbn) : book.isbn != null) return false; 97 if(title != null ? !title.equals(book.title) : book.title != null) return false; 98 99 return true; 100 } 101 102 public int hashCode() 103 { 104 int result; 105 result = (isbn != null ? isbn.hashCode() : 0); 106 result = 29 * result + (title != null ? title.hashCode() : 0); 107 result = 29 * result + (author != null ? author.hashCode() : 0); 108 result = 29 * result + (characters != null ? characters.hashCode() : 0); 109 return result; 110 } 111 } 112 | Popular Tags |