Class Compatibility

  • All Implemented Interfaces:
    ClassCompatibilityChecker, Serializable

    public class Compatibility
    extends Object
    implements Serializable, ClassCompatibilityChecker
    Class that determines compatibility between inputs and outputs.

    An input and output are compatible, if...
    • either output or input is Unknown.class
    • input is Object.class
    • output and input are the same class
    "Strict" mode does not perform any special treatment of Object/Unknown.
    Version:
    $Revision$
    Author:
    fracpete (fracpete at waikato dot ac dot nz)
    See Also:
    Unknown, Serialized Form
    • Field Detail

      • m_Strict

        protected boolean m_Strict
        whether to use strict compatibility, ie, no special handling for Unknown/Object.
    • Constructor Detail

      • Compatibility

        public Compatibility()
        Initializes the checker with non-strict behavior.
      • Compatibility

        public Compatibility​(boolean strict)
        Initializes the checker.
        Parameters:
        strict - whether to perform strict checks or not
        See Also:
        setStrict(boolean)
    • Method Detail

      • setStrict

        public void setStrict​(boolean value)
        Sets whether to use strict or relaxed compatibility checks. "Strict" does not cater for Unknown/Object.
        Parameters:
        value - if true strict mode is enabled
      • isStrict

        public boolean isStrict()
        Returns whether strict or relaxed compatibility checks are used.
        Returns:
        true if strict mode is enabled
      • isCompatible

        public boolean isCompatible​(Class output,
                                    Class input)
        Checks whether the two classes are compatible.
        Specified by:
        isCompatible in interface ClassCompatibilityChecker
        Parameters:
        output - the generated output of the first actor
        input - the accepted input of the second actor
        Returns:
        true if compatible
      • isCompatible

        public boolean isCompatible​(Class[] outCls,
                                    Class[] inCls)
        Checks whether the two class sets are compatible.
        Specified by:
        isCompatible in interface ClassCompatibilityChecker
        Parameters:
        outCls - the classes of the generating actor
        inCls - the classes of the accepting actor
        Returns:
        true if compatible
      • isCompatible

        public boolean isCompatible​(OutputProducer output,
                                    InputConsumer input)
        Checks whether the two actors are compatible.
        Parameters:
        output - the generating actor
        input - the accepting actor
        Returns:
        true if compatible
      • getCompatibleClasses

        public HashSet<Class> getCompatibleClasses​(OutputProducer output,
                                                   InputConsumer input)
        Returns all the classes that the two actors have in common, in producing and consuming.
        Parameters:
        output - the generating actor
        input - the accepting actor
        Returns:
        the classes that are in common
      • toString

        public String toString()
        Returns a short string representation of this object.
        Overrides:
        toString in class Object
        Returns:
        the string representation