Class SlugServiceImpl

java.lang.Object
com.example.blogs.app.api.post.service.SlugServiceImpl
All Implemented Interfaces:
SlugService

@Service public class SlugServiceImpl extends Object implements SlugService
Generates unique URL-friendly slugs by combining slugified titles with random suffixes.
  • Constructor Details

    • SlugServiceImpl

      public SlugServiceImpl()
  • Method Details

    • generateSuffix

      public String generateSuffix()
      Description copied from interface: SlugService
      Generates a random unique suffix for slug uniqueness.
      Specified by:
      generateSuffix in interface SlugService
      Returns:
      12-character random suffix
    • generate

      public String generate(String title)
      Description copied from interface: SlugService
      Generates a unique slug from a title with appended suffix.
      Specified by:
      generate in interface SlugService
      Parameters:
      title - the title to convert to slug
      Returns:
      URL-friendly slug with unique suffix