Class EBookBuilder

java.lang.Object
com.university.bookstore.builder.EBookBuilder
All Implemented Interfaces:
MaterialBuilder<EBook>

public class EBookBuilder extends Object implements MaterialBuilder<EBook>
Builder for creating EBook instances with a fluent interface. Demonstrates the Builder pattern for complex object construction.
Since:
2024-09-15
Version:
3.0
Author:
Navid Mohaghegh
  • Constructor Details

    • EBookBuilder

      public EBookBuilder()
  • Method Details

    • setId

      public EBookBuilder setId(String id)
      Sets the eBook ID.
      Parameters:
      id - the eBook ID
      Returns:
      this builder for method chaining
    • setTitle

      public EBookBuilder setTitle(String title)
      Sets the eBook title.
      Parameters:
      title - the eBook title
      Returns:
      this builder for method chaining
    • setAuthor

      public EBookBuilder setAuthor(String author)
      Sets the eBook author.
      Parameters:
      author - the eBook author
      Returns:
      this builder for method chaining
    • setPrice

      public EBookBuilder setPrice(double price)
      Sets the eBook price.
      Parameters:
      price - the eBook price
      Returns:
      this builder for method chaining
    • setYear

      public EBookBuilder setYear(int year)
      Sets the eBook publication year.
      Parameters:
      year - the publication year
      Returns:
      this builder for method chaining
    • setFileFormat

      public EBookBuilder setFileFormat(String fileFormat)
      Sets the eBook file format.
      Parameters:
      fileFormat - the file format (e.g., "EPUB", "PDF", "MOBI")
      Returns:
      this builder for method chaining
    • setFileSize

      public EBookBuilder setFileSize(double fileSize)
      Sets the eBook file size.
      Parameters:
      fileSize - the file size in MB
      Returns:
      this builder for method chaining
    • setDrmEnabled

      public EBookBuilder setDrmEnabled(boolean drmEnabled)
      Sets the DRM enabled status.
      Parameters:
      drmEnabled - true if DRM is enabled
      Returns:
      this builder for method chaining
    • setWordCount

      public EBookBuilder setWordCount(int wordCount)
      Sets the eBook word count.
      Parameters:
      wordCount - the word count
      Returns:
      this builder for method chaining
    • setQuality

      public EBookBuilder setQuality(Media.MediaQuality quality)
      Sets the eBook quality.
      Parameters:
      quality - the media quality
      Returns:
      this builder for method chaining
    • enableDRM

      public EBookBuilder enableDRM()
      Sets DRM enabled to true.
      Returns:
      this builder for method chaining
    • disableDRM

      public EBookBuilder disableDRM()
      Sets DRM enabled to false.
      Returns:
      this builder for method chaining
    • setHighQuality

      public EBookBuilder setHighQuality()
      Sets the quality to high.
      Returns:
      this builder for method chaining
    • setLowQuality

      public EBookBuilder setLowQuality()
      Sets the quality to low.
      Returns:
      this builder for method chaining
    • build

      public EBook build()
      Description copied from interface: MaterialBuilder
      Builds and returns the material instance.
      Specified by:
      build in interface MaterialBuilder<EBook>
      Returns:
      the built material
    • validate

      public void validate()
      Description copied from interface: MaterialBuilder
      Validates that all required fields are set.
      Specified by:
      validate in interface MaterialBuilder<EBook>
    • reset

      public void reset()
      Description copied from interface: MaterialBuilder
      Resets the builder to its initial state.
      Specified by:
      reset in interface MaterialBuilder<EBook>
    • getId

      public String getId()
      Gets the current ID.
      Returns:
      the current ID
    • getTitle

      public String getTitle()
      Gets the current title.
      Returns:
      the current title
    • getAuthor

      public String getAuthor()
      Gets the current author.
      Returns:
      the current author
    • getPrice

      public double getPrice()
      Gets the current price.
      Returns:
      the current price
    • getYear

      public int getYear()
      Gets the current year.
      Returns:
      the current year
    • getFileFormat

      public String getFileFormat()
      Gets the current file format.
      Returns:
      the current file format
    • getFileSize

      public double getFileSize()
      Gets the current file size.
      Returns:
      the current file size
    • isDrmEnabled

      public boolean isDrmEnabled()
      Gets the current DRM enabled status.
      Returns:
      the current DRM enabled status
    • getWordCount

      public int getWordCount()
      Gets the current word count.
      Returns:
      the current word count
    • getQuality

      public Media.MediaQuality getQuality()
      Gets the current quality.
      Returns:
      the current quality
    • toString

      public String toString()
      Overrides:
      toString in class Object