Class ProcessScope

  • All Implemented Interfaces:
    Predicate<Object>

    public class ProcessScope
    extends Object
    implements Predicate<Object>
    The scope of supported association types and link types.

    An OSLC application may not necessarily support all available resource types, associations and links. For example LinkType.TRACKS_WORK_ITEM relates to planning and may not make sense for all Change Management applications. The application is also likely to support locally only a subset of available OSLC resource types.

    An application can restrict the supported associations and links to a subset of available ones by changing the ProcessScope at initialization time, using following code:

     ProcessScope.setInstance(ProcessScope.builder() //
             .resourceType(ResourceType.CHANGE_REQUEST) //
             .association(AssociationType.RELATED_TO) //
             .link(LinkType.RELATED_CHANGE_REQUEST) //
             .build());
    
     

    This class implements Predicate so that a domain, resource type, association or link types Stream can easily be filtered with a ProcessScope instance.

    Since:
    1.9.0
    See Also:
    AssociationType, LinkType
    • Method Detail

      • getInstance

        public static ProcessScope getInstance()
        Returns the current scope instance. Default instance supports all available resource types, associations and links.
        Returns:
        the current instance.
        See Also:
        setInstance(ProcessScope)
      • setInstance

        public static void setInstance​(ProcessScope scope)
        Replaces the current scope with the given one.
        Parameters:
        scope - the new scope.
      • builder

        public static ProcessScope.Builder builder()
        Creates a builder to configure and build a new ProcessScope instance.
        Returns:
        a scope builder.
      • contains

        public boolean contains​(Domain domain)
        Determines if the given domain is supported by this scope instance, meaning one that defines a type of artifact that the local application enables managing.
        Parameters:
        domain - the domain
        Returns:
        true if the domain is part of the scope, false otherwise.
        Since:
        3.5.0
      • contains

        public boolean contains​(ResourceType type)
        Determines if the given resource type is supported by this scope instance, meaning one whose artifacts can be managed by that the local application.
        Parameters:
        type - the resource type
        Returns:
        true if the resource type is part of the scope, false otherwise.
        Since:
        3.5.0
      • contains

        public boolean contains​(AssociationType type)
        Determines if the given association type is supported by this scope instance.
        Parameters:
        type - an association type to test.
        Returns:
        true if the link type is part of the scope, false otherwise.
      • contains

        public boolean contains​(LinkType type)
        Determines if the given link type is supported by this scope instance.
        Parameters:
        type - a link type to test.
        Returns:
        true if the link type is part of the scope, false otherwise.
      • test

        public boolean test​(Object object)
        Determines if the given domain, resource type, association type or link type is supported by this scope instance.
        Specified by:
        test in interface Predicate<Object>
        Parameters:
        object - an object to test, which is expected to either be an Domain, ResourceType, AssociationType or LinkType.
        Returns:
        true if the object is part of the scope, false otherwise or if the object is not one of the supported types.