Class ContextOr

  • All Implemented Interfaces:
    ContextListener

    public class ContextOr
    extends Context
    implements ContextListener
    This class is a compound context defined by two other contexts and the context is active when at least one of the related contexts are active (OR operation). The class extends the base class Context.
    The context active value is updated using the setActive method. The current value of the context can always be checked using the isActive method of the context.
    If the application needs to track the changes in the active value of the context then the application should implement also the ContextListener interface {@see eu.h2020.helios_social.core.context.ContextListener} and register the context for the listener.
    • Constructor Detail

      • ContextOr

        public ContextOr​(java.lang.String name,
                         @NonNull
                         Context contextA,
                         @NonNull
                         Context contextB)
        Creates an OrContext
        Parameters:
        name - the name of the context
        contextA - the first context
        contextB - the second context
      • ContextOr

        public ContextOr​(java.lang.String id,
                         java.lang.String name,
                         @NonNull
                         Context contextA,
                         @NonNull
                         Context contextB)
        Creates an OrContext
        Parameters:
        id - the identifier of the context
        name - the name of the context
        contextA - the first context
        contextB - the second context
    • Method Detail

      • contextChanged

        public void contextChanged​(boolean active)
        Description copied from interface: ContextListener
        This method is called when context active value changed.
        Specified by:
        contextChanged in interface ContextListener
        Parameters:
        active - the context active value
      • getContextA

        public Context getContextA()
        Returns the first context of ContextOr
        Returns:
        the contextA
      • getContextB

        public Context getContextB()
        Returns the second context of ContextOr
        Returns:
        the contextB