Class InverseEnabler

  • All Implemented Interfaces:
    ElementEnabler

    public class InverseEnabler
    extends Object
    implements ElementEnabler

    A specialized implementation of the ElementEnabler interface that wraps another ElementEnabler and inverses the setEnabledState() implementation of this wrapped enabler.

    An instance of this class is initialized with a reference to another ElementEnabler. The setEnabledState(ComponentBuilderData, boolean) implementation delegates to this enabler, but the state argument is inverted. This means if this enabler is told to enable elements, it tells the wrapped enabler to disable its element and vice versa. This is useful for instance for using an existing ElementEnabler in a context where the exactly opposite behavior is required.

    Version:
    $Id: InverseEnabler.java 205 2012-01-29 18:29:57Z oheger $
    Author:
    Oliver Heger
    • Constructor Detail

      • InverseEnabler

        public InverseEnabler​(ElementEnabler wrapped)
        Creates a new instance of InverseEnabler and initializes it with ElementEnabler to be wrapped.
        Parameters:
        wrapped - the wrapped ElementEnabler (must not be null)
        Throws:
        IllegalArgumentException - if the wrapped ElementEnabler is null
    • Method Detail

      • getWrappedEnabler

        public ElementEnabler getWrappedEnabler()
        Returns the ElementEnabler wrapped by this object.
        Returns:
        the wrapped ElementEnabler
      • setEnabledState

        public void setEnabledState​(ComponentBuilderData compData,
                                    boolean state)
                             throws FormBuilderException
        Performs the change of the enabled state. This implementation calls the wrapped ElementEnabler with the inverted state argument.
        Specified by:
        setEnabledState in interface ElementEnabler
        Parameters:
        compData - the ComponentBuilderData instance
        state - the new enabled state
        Throws:
        FormBuilderException - if the wrapped ElementEnabler throws an exception