Class SocialParserContext

java.lang.Object
ovh.mythmc.social.api.context.SocialParserContext
All Implemented Interfaces:
SocialContext
Direct Known Subclasses:
SocialProcessorContext

public class SocialParserContext extends Object implements SocialContext
Represents the parsing context of a message before it is formatted or dispatched.

A SocialParserContext provides all necessary information required during the parsing phase of a message, including:

See Also:
  • Method Details

    • builder

      Creates a new SocialParserContext.SocialParserContextBuilder for the given user and message.
      Parameters:
      user - the user sending the message
      message - the raw message component
      Returns:
      a new builder instance
    • group

      public Optional<SocialParserGroup> group()
      Returns the parser group if present.
      Returns:
      an Optional containing the SocialParserGroup, or empty if none is set
    • injectedValues

      public List<SocialInjectedValue<?,?>> injectedValues()
      Returns an immutable copy of the injected values.
      Returns:
      an unmodifiable list of injected values
    • injectedValues

      public <T extends SocialInjectedValue<?, ?>> List<T> injectedValues(@NotNull @NotNull Class<T> type)
      Returns all injected values of the specified type.
      Type Parameters:
      T - the injected value subtype
      Parameters:
      type - the injected value type
      Returns:
      a list of injected values matching the given type
    • injectValue

      public void injectValue(@NotNull @NotNull SocialInjectedValue<?,?> injectedValue)
      Injects a single value into this context.
      Parameters:
      injectedValue - the value to inject
    • injectValues

      public void injectValues(@NotNull @NotNull Iterable<? extends SocialInjectedValue<?,?>> injectedValues)
      Injects multiple values into this context.
      Parameters:
      injectedValues - the values to inject
    • getInjectedValue

      @Nullable public <V> V getInjectedValue(@NotNull @NotNull String identifier)
      Retrieves an injected value by its identifier.
      Type Parameters:
      V - the value type
      Parameters:
      identifier - the unique identifier
      Returns:
      the injected value, or null if not present
    • getInjectedValue

      @Nullable public <V> V getInjectedValue(@NotNull @NotNull String identifier, V defaultValue)
      Retrieves an injected value by its identifier, returning a default value if none is found.
      Type Parameters:
      V - the value type
      Parameters:
      identifier - the unique identifier
      defaultValue - the value to return if no match is found
      Returns:
      the injected value or defaultValue if not present