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
-
Method Details
-
name
String name()Supplies the raw name owned by the implementation.- Returns:
- the raw name supplied by the implementation
-
displayName
Returns the display form of the name.- Returns:
- a user-friendly name for display
-
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
-