Class Factory

java.lang.Object
eu.bandm.tools.ramus.ogma.Factory
Direct Known Subclasses:
ParserFactory, ReadingFactory, ReducerFactory

public abstract class Factory extends Object
Base class of configurable factories for parsers and related objects.
  • Field Details

    • PACKAGE_PREFIX

      public static final String PACKAGE_PREFIX
      The package prefix used to distinguish caller code pertaining to the parser construction service from client code.
    • MODULE_NAME

      public static final @Opt String MODULE_NAME
      The module name used to distinguish caller code pertaining to the parser construction service from client code.
    • configuration

      protected final Factory.Configuration configuration
      The configuration to apply when constructing objects.
  • Constructor Details

    • Factory

      protected Factory(Factory.Configuration configuration)
      Creates a new factory.
      Parameters:
      configuration - the configuration to apply when constructing objects
      Throws:
      NullPointerException - if configuration is null
  • Method Details

    • defaultConfiguration

      protected static Factory.Configuration defaultConfiguration()
      Returns a default configuration.

      The default configuration has the following settings:

      capturingCallerLocations
      false
      creationWatcher
      null
      serviceFilter
      filterServicePackage
      Returns:
      a default configuration
    • serviceFilterByPackage

      public static boolean serviceFilterByPackage(StackTraceElement e)
      Checks whether a caller on the stack trace belongs to the parser construction service, by virtue of belonging to the same package.
      Parameters:
      e - a stack trace element
      Returns:
      true if the containing class of the caller represented by e belongs to the same package as this class; false otherwise
      Throws:
      NullPointerException - if e is null
    • serviceFilterByModule

      public static boolean serviceFilterByModule(StackTraceElement e)
      Checks whether a caller on the stack trace belongs to the parser construction service, by virtue of belonging to the same module.
      Parameters:
      e - a stack trace element
      Returns:
      true if the containing class of the caller represented by e belongs to the same module as this class; false otherwise
      Throws:
      NullPointerException - if e is null
    • getConfiguration

      public Factory.Configuration getConfiguration()
      Returns the configuration of this factory.
      Returns:
      the configuration of this factory
    • construct

      protected <O> O construct(Function<? super @Opt Location<String>,? extends O> constructor)
      Manages the construction of an object by this factory.

      Depending on the configuration, a caller location for this construction operation may be obtained, and/or a watcher may be notified of the construction event.

      Type Parameters:
      O - the type of object to construct
      Parameters:
      constructor - the function to construct the new object, given a caller location or null if not available
      Returns:
      the newly constructed object
      Throws:
      NullPointerException - if constructor is null