Class FilteredTypes

java.lang.Object
org.praxislive.base.FilteredTypes
All Implemented Interfaces:
org.praxislive.core.protocols.SupportedTypes

public class FilteredTypes extends Object implements org.praxislive.core.protocols.SupportedTypes
An implementation of SupportedTypes that can be included in the lookup of a container. The implementation automatically searches the parent lookup for other SupportedTypes, or otherwise a ComponentRegistry.

Results can be subject to further filtering, or additional types can be included.

The result is cached. The FilteredTypes must be reset() on hierarchy changes, and in any circumstances where the behaviour of the filter or additional types supplier changes.

  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.praxislive.core.protocols.SupportedTypes

    org.praxislive.core.protocols.SupportedTypes.Result
  • Method Summary

    Modifier and Type
    Method
    Description
    create(org.praxislive.core.Container context)
    Create a FilteredTypes for the provided context.
    create(org.praxislive.core.Container context, Predicate<org.praxislive.core.ComponentType> filter)
    Create a FilteredTypes for the provided context, additionally filtering the available types from the parent by the passed in filter.
    create(org.praxislive.core.Container context, Predicate<org.praxislive.core.ComponentType> filter, Supplier<List<org.praxislive.core.ComponentType>> additional)
    Create a FilteredTypes for the provided context, additionally filtering the available types from the parent by the passed in filter, and adding in types from the supplied list.
    create(org.praxislive.core.Container context, Predicate<org.praxislive.core.ComponentType> filter, Supplier<List<org.praxislive.core.ComponentType>> additional, boolean includeParentAdditional)
    Create a FilteredTypes for the provided context, additionally filtering the available types from the parent by the passed in filter, and adding in types from the supplied list.
    org.praxislive.core.protocols.SupportedTypes.Result
     
    void
    Reset and cause the result to be recalculated on the next call to query().

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • query

      public org.praxislive.core.protocols.SupportedTypes.Result query()
      Specified by:
      query in interface org.praxislive.core.protocols.SupportedTypes
    • reset

      public void reset()
      Reset and cause the result to be recalculated on the next call to query(). The FilteredTypes should be reset on hierarchy changes of the container, and in any circumstances where the behaviour of the filter or additional types supplier changes.
    • create

      public static FilteredTypes create(org.praxislive.core.Container context)
      Create a FilteredTypes for the provided context. If no SupportedTypes is found in the parent lookup, then the implementation will attempt to filter the ComponentRegistry result according to the root type.
      Parameters:
      context - container this will be added to
      Returns:
      instance
    • create

      public static FilteredTypes create(org.praxislive.core.Container context, Predicate<org.praxislive.core.ComponentType> filter)
      Create a FilteredTypes for the provided context, additionally filtering the available types from the parent by the passed in filter.

      If the filter is null then a default filter will be used according to root type - see create(org.praxislive.core.Container).

      Parameters:
      context - container this will be added to
      filter - filtering to apply to parent result
      Returns:
      instance
    • create

      public static FilteredTypes create(org.praxislive.core.Container context, Predicate<org.praxislive.core.ComponentType> filter, Supplier<List<org.praxislive.core.ComponentType>> additional)
      Create a FilteredTypes for the provided context, additionally filtering the available types from the parent by the passed in filter, and adding in types from the supplied list.

      If the filter is null then a default filter will be used according to root type - see create(org.praxislive.core.Container).

      Parameters:
      context - container this will be added to
      filter - filtering to apply to parent result
      additional - supplier of a list of additional types
      Returns:
      instance
    • create

      public static FilteredTypes create(org.praxislive.core.Container context, Predicate<org.praxislive.core.ComponentType> filter, Supplier<List<org.praxislive.core.ComponentType>> additional, boolean includeParentAdditional)
      Create a FilteredTypes for the provided context, additionally filtering the available types from the parent by the passed in filter, and adding in types from the supplied list.

      The boolean flag allows to filter out additional types added by the parent, if the parent is also using an instance of FilteredTypes.

      If the filter is null then a default filter will be used according to root type - see create(org.praxislive.core.Container).

      Parameters:
      context - container this will be added to
      filter - filtering to apply to parent result
      additional - supplier of a list of additional types
      includeParentAdditional - whether to include additional types from the parent
      Returns:
      instance