package fr.umlv.gui.library;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/** Represents a library of {@link Book Book}s.
 * 
 * @author Rémi Forax
 * @see Book
 */
public class Library {
  /** add a book in the library.
   * @param book the book to add.
   */
  public void add(Book book) {
    books.add(book);
  }
  
  /** Remove a book at a specific index from
   *  the library.
   *  After the removal, all books with an index greater
   *  than <tt>index</tt> have their index decrement by one.
   * @param index the index of the book to remove.
   */
  public void remove(int index) {
    books.remove(index);
  }
  
  /** Returns an unmodifiable list of books
   *  contains in the library.
   * @return the list of books.
   */
  public List<? extends Book> books() {
    return Collections.unmodifiableList(books);
  }
  
  private final ArrayList<Book> books=
    new ArrayList<Book>();
}
