Class FilteredTypes

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

public class FilteredTypes extends Object implements 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.

  • Method Details

    • query

      public SupportedTypes.Result query()
      Description copied from interface: SupportedTypes
      Query the supported types, the same as calling the supported-types control on the providing container. The same result will be returned unless the data has changed or otherwise refreshed, so object identity can be used to verify any cached data.
      Specified by:
      query in interface SupportedTypes
      Returns:
      supported types result
    • 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(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(Container context, Predicate<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(Container context, Predicate<ComponentType> filter, Supplier<List<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(Container context, Predicate<ComponentType> filter, Supplier<List<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