# Class Book

java.lang.Object
com.university.bookstore.model.Book

All Implemented Interfaces:
  `Comparable<Book>`

public final class Book extends Object implements Comparable<Book>
Represents an immutable book in the bookstore inventory. Books are uniquely identified by their ISBN.

This class is immutable and thread-safe. All fields are validated during construction to ensure data integrity.

Since:
  2024-09-15
Version:
  1.0
Author:
  Navid Mohaghegh

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Book(String isbn, String title, String author, double price, int year)`
  Creates a new Book with validation.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `int`
  `compareTo(Book other)`
  Compares this book with another book based on title (alphabetical order).
  `boolean`
  `equals(Object obj)`
  Checks if this book is equal to another object.
  `String`
  `getAuthor()`
  Gets the author of this book.
  `String`
  `getIsbn()`
  Gets the ISBN of this book.
  `double`
  `getPrice()`
  Gets the price of this book.
  `String`
  `getTitle()`
  Gets the title of this book.
  `int`
  `getYear()`
  Gets the publication year of this book.
  `int`
  `hashCode()`
  Generates hash code based on ISBN.
  `String`
  `toString()`
  Returns a human-readable string representation of this book.

  ### Methods inherited from class java.lang.Object

  `getClass, notify, notifyAll, wait, wait, wait`

- ## Constructor Details

  - ### Book

    public Book(String isbn, String title, String author, double price, int year)
    Creates a new Book with validation.
    Parameters:
      `isbn` - the International Standard Book Number (10 or 13 digits)
      `title` - the book title (non-null, non-blank)
      `author` - the primary author (non-null, non-blank)
      `price` - the price in dollars (non-negative)
      `year` - the publication year (1450 to current year + 1)
    Throws:
      `IllegalArgumentException` - if any parameter is invalid
      `NullPointerException` - if any string parameter is null

- ## Method Details

  - ### getIsbn

    public String getIsbn()
    Gets the ISBN of this book.
    Returns:
      the ISBN (10 or 13 digits)

  - ### getTitle

    public String getTitle()
    Gets the title of this book.
    Returns:
      the book title

  - ### getAuthor

    public String getAuthor()
    Gets the author of this book.
    Returns:
      the author name

  - ### getPrice

    public double getPrice()
    Gets the price of this book.
    Returns:
      the price in dollars

  - ### getYear

    public int getYear()
    Gets the publication year of this book.
    Returns:
      the publication year

  - ### compareTo

    public int compareTo(Book other)
    Compares this book with another book based on title (alphabetical order).
    Specified by:
      `compareTo` in interface `Comparable<Book>`
    Parameters:
      `other` - the book to compare with
    Returns:
      negative if this book comes before, positive if after, 0 if equal

  - ### equals

    public boolean equals(Object obj)
    Checks if this book is equal to another object. Books are considered equal if they have the same ISBN.
    Overrides:
      `equals` in class `Object`
    Parameters:
      `obj` - the object to compare with
    Returns:
      true if the objects are equal (same ISBN), false otherwise

  - ### hashCode

    public int hashCode()
    Generates hash code based on ISBN.
    Overrides:
      `hashCode` in class `Object`
    Returns:
      hash code of the ISBN

  - ### toString

    public String toString()
    Returns a human-readable string representation of this book.
    Overrides:
      `toString` in class `Object`
    Returns:
      formatted string with book details