Class Assert

  • All Implemented Interfaces:
    java.lang.Cloneable, Actor, Executable, FiringsRecordable, Initializable, TypedActor, Changeable, Debuggable, DebugListener, Derivable, Instantiable, ModelErrorHandler, MoMLExportable, Moveable, Nameable

    public class Assert
    extends Expression
    Check that an assertion predicate is satisfied, and throw an exception if not. To use this actor, add any number of input ports. Corresponding output ports will be automatically added. Specify an expression that references the inputs and yields a boolean result. When the actor fires, if the expression evaluates to false, then the actor will throw an exception with the message given by the message parameter. Otherwise, it will copy the inputs to the corresponding output ports.
    Since:
    Ptolemy II 10.0
    Version:
    $Id$
    Author:
    Ilge Akkaya, David Broman, Edward A. Lee
    Pt.AcceptedRating:
    Red (eal)
    Pt.ProposedRating:
    Yellow (eal)
    • Field Detail

      • message

        public StringParameter message
        The error message to display when the assertion is violated. This is a string that defaults to "Assertion failed.".
    • Method Detail

      • fire

        public void fire()
                  throws IllegalActionException
        Override the base class to check the result of the evaluation of the expression. If the result is false, throw an exception. Otherwise, copy the inputs to the corresponding outputs.
        Specified by:
        fire in interface Executable
        Overrides:
        fire in class Expression
        Throws:
        IllegalActionException - If the expression evaluates to false, or if the superclass throws it.
      • _removePort

        protected void _removePort​(Port port)
        Override the base class to remove the corresponding output port, if the specified port is an input port, or the corresponding input port, if the specified port is an output port.
        Overrides:
        _removePort in class Entity<TypedIOPort>
        Parameters:
        port - The port to remove from this entity. name already in the entity.