Interface SyntaxRegistry

All Superinterfaces:
Iterable<SyntaxInfo<?>>, Registry<SyntaxInfo<?>>, ViewProvider<SyntaxRegistry>

public interface SyntaxRegistry extends ViewProvider<SyntaxRegistry>, Registry<SyntaxInfo<?>>
A syntax registry is a central container for all SyntaxInfos.
  • Field Details

  • Method Details

    • empty

      @Contract("-> new") static SyntaxRegistry empty()
      Constructs a default implementation of a syntax registry. This implementation is practically a wrapper around Map<Key<?>, SyntaxRegistry<?>>.
      Returns:
      A syntax registry containing no elements.
    • withOrigin

      static SyntaxRegistry withOrigin(SyntaxRegistry syntaxRegistry, Origin origin)
      Constructs a syntax registry that applies an origin to all syntax infos registered through it with the Origin.UNKNOWN origin.
      Parameters:
      syntaxRegistry - The syntax registry providing the implementation.
      origin - The origin to apply.
      Returns:
      A syntax registry that applies an origin.
    • syntaxes

      <I extends SyntaxInfo<?>> @Unmodifiable Collection<I> syntaxes(SyntaxRegistry.Key<I> key)
      A method to obtain all syntaxes registered under a certain key.
      Type Parameters:
      I - The syntax type.
      Parameters:
      key - The key to obtain syntaxes from.
      Returns:
      An unmodifiable snapshot of all syntaxes registered under key.
    • register

      <I extends SyntaxInfo<?>> void register(SyntaxRegistry.Key<I> key, I info)
      Registers a new syntax under a provided key.
      Type Parameters:
      I - The syntax type.
      Parameters:
      key - The key to register info under.
      info - The syntax info to register.
    • unregister

      void unregister(SyntaxInfo<?> info)
      Unregisters all registrations of a syntax, regardless of the SyntaxRegistry.Key.
      Parameters:
      info - The syntax info to unregister.
      See Also:
    • unregister

      <I extends SyntaxInfo<?>> void unregister(SyntaxRegistry.Key<I> key, I info)
      Unregisters a syntax registered under a provided key.
      Type Parameters:
      I - The syntax type.
      Parameters:
      key - The key the info is registered under.
      info - The syntax info to unregister.
      See Also:
    • unmodifiableView

      @Contract("-> new") default SyntaxRegistry unmodifiableView()
      Constructs an unmodifiable view of this syntax registry. That is, the returned registry will not allow registrations.
      Specified by:
      unmodifiableView in interface ViewProvider<SyntaxRegistry>
      Returns:
      An unmodifiable view of this syntax registry.
    • elements

      @Unmodifiable Collection<SyntaxInfo<?>> elements()
      There are no guarantees on the ordering of the returned collection.
      Specified by:
      elements in interface Registry<SyntaxInfo<?>>
      Returns:
      An unmodifiable snapshot of all syntaxes registered.