Class OptionalExamples.User

java.lang.Object
net.jrodolfo.java_evolution.java08.OptionalExamples.User
Enclosing class:
OptionalExamples

public static class OptionalExamples.User extends Object
Small Java 8-style data class used by the Optional examples.

This deliberately allows a nullable email so the examples can demonstrate how Optional represents missing data.

  • Constructor Details

    • User

      public User(String name, String email)
      Creates a user. The email is intentionally nullable so the examples can demonstrate converting legacy nullable data into Optional.
      Parameters:
      name - the user's display name
      email - the user's email, or null when it is missing
  • Method Details

    • name

      public String name()
      Returns:
      the user's display name
    • email

      public String email()
      Returns:
      the user's email, which may be null