Interface DefaultMethodExamples.Named

All Known Implementing Classes:
DefaultMethodExamples.AdminUser, DefaultMethodExamples.RegularUser
Enclosing class:
DefaultMethodExamples

public static interface DefaultMethodExamples.Named
Interface with one abstract method and two default methods.

Implementations only need to provide name(), while displayName() and initials() are inherited automatically.

  • Method Summary

    Modifier and Type
    Method
    Description
    default String
    Returns the display form of the name.
    default String
    Builds initials from the display name without requiring each implementation to duplicate the same string-processing logic.
    Supplies the raw name owned by the implementation.
  • Method Details

    • name

      String name()
      Supplies the raw name owned by the implementation.
      Returns:
      the raw name supplied by the implementation
    • displayName

      default String displayName()
      Returns the display form of the name.
      Returns:
      a user-friendly name for display
    • initials

      default String initials()
      Builds initials from the display name without requiring each implementation to duplicate the same string-processing logic.
      Returns:
      the first letter of each name part in uppercase