Class AbstractFactory<E>

java.lang.Object
com.sk89q.worldedit.internal.registry.AbstractFactory<E>
Type Parameters:
E - the element that the factory returns
Direct Known Subclasses:
BlockFactory, ItemFactory, MaskFactory, PatternFactory, TransformFactory

public abstract class AbstractFactory<E> extends Object
An abstract implementation of a factory for internal usage.
  • Field Details

    • worldEdit

      protected final WorldEdit worldEdit
  • Constructor Details

    • AbstractFactory

      protected AbstractFactory(WorldEdit worldEdit, InputParser<E> defaultParser)
      Create a new factory.
      Parameters:
      worldEdit - the WorldEdit instance
      defaultParser - the parser to fall back to
  • Method Details

    • getParsers

      public List<InputParser<E>> getParsers()
      Gets an immutable list of parsers.

      To add parsers, use the register method.

      Returns:
      the parsers
    • parseFromInput

      public E parseFromInput(String input, ParserContext context) throws InputParseException
      Parse a string and context to each InputParser added to this factory. If no result found, throws InputParseException
      Parameters:
      input - input string
      context - input context
      Returns:
      parsed result
      Throws:
      InputParseException - if no result found
    • getSuggestions

      public List<String> getSuggestions(String input)
    • register

      public void register(InputParser<E> inputParser)
      Registers an InputParser to this factory.
      Parameters:
      inputParser - The input parser
    • containsAlias

      public boolean containsAlias(String alias)
      Test all parsers to see if alias is contained by one of them
      Parameters:
      alias - alias to test
      Returns:
      if a parser contains the alias