Interface Named<T>

Type Parameters:
T - the type of the payload

@API(status=STABLE, since="5.8") public interface Named<T>
Named is a container that associates a name with a given payload.
Since:
5.8
  • Method Summary

    Modifier and Type
    Method
    Description
    Get the name of the payload.
    Get the payload.
    static <T> Named<T>
    named(String name, T payload)
    Factory method for creating an instance of Named based on a name and a payload.
    static <T> Named<T>
    of(String name, T payload)
    Factory method for creating an instance of Named based on a name and a payload.
  • Method Details

    • of

      static <T> Named<T> of(String name, T payload)
      Factory method for creating an instance of Named based on a name and a payload.
      Type Parameters:
      T - the type of the payload
      Parameters:
      name - the name associated with the payload; never null or blank
      payload - the object that serves as the payload; may be null depending on the use case
      Returns:
      an instance of Named; never null
      See Also:
    • named

      static <T> Named<T> named(String name, T payload)
      Factory method for creating an instance of Named based on a name and a payload.

      This method is an alias for of(java.lang.String, T) and is intended to be used when statically imported — for example, via: import static org.junit.jupiter.api.Named.named;

      Type Parameters:
      T - the type of the payload
      Parameters:
      name - the name associated with the payload; never null or blank
      payload - the object that serves as the payload; may be null depending on the use case
      Returns:
      an instance of Named; never null
    • getName

      String getName()
      Get the name of the payload.
      Returns:
      the name of the payload; never null or blank
    • getPayload

      T getPayload()
      Get the payload.
      Returns:
      the payload; may be null depending on the use case