Interface Reference<T>

Type Parameters:
T - the type of the value
All Known Subinterfaces:
TypedKey<T>
All Known Implementing Classes:
Reference.Inline

public sealed interface Reference<T> permits TypedKey<T>, Reference.Inline<T>
A value of a registry, given either by the key it is registered under or inline.

A TypedKey is a reference, so the generated keys can be passed as they are.

Since:
0.1.0
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static final record 
    A value given inline, not registered.
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T> Reference<T>
    inline(T value)
    Returns a reference to a value that is not registered.
    resolve(Registry<T> registry)
    Gets the value, looking it up in registry if this is a key.
  • Method Details

    • inline

      static <T> Reference<T> inline(T value)
      Returns a reference to a value that is not registered.
      Type Parameters:
      T - the type of the value
      Parameters:
      value - the value
      Returns:
      a reference to a value that is not registered
      Since:
      0.1.0
    • resolve

      T resolve(Registry<T> registry)
      Gets the value, looking it up in registry if this is a key.
      Parameters:
      registry - the registry the value belongs to
      Returns:
      the value
      Throws:
      NoSuchElementException - if nothing is registered under the key
      Since:
      0.1.0